module = app(\App\Extension\ModuleManager::class)->getModule('sirsoft-board') ?? new Module(base_path('modules/sirsoft-board')); } /** * 회귀: PostResource toArray() 의 'thumbnail' 키에서 og:image URL 추출. */ public function test_post_seo_og_defaults_uses_thumbnail_key(): void { $context = [ 'post' => [ 'data' => [ 'subject' => '회귀 테스트 게시글', 'thumbnail' => '/api/modules/sirsoft-board/boards/free/attachment/abc123/preview', ], ], ]; $og = $this->module->seoOgDefaults('post', $context); $this->assertArrayHasKey('image', $og, 'thumbnail 키가 있으면 og:image 가 출력되어야 합니다'); $this->assertStringContainsString('/api/modules/sirsoft-board/', $og['image']); } /** * 회귀: thumbnail 부재 시에도 throw 없이 image 키 생략. */ public function test_post_seo_og_defaults_without_thumbnail(): void { $context = [ 'post' => ['data' => ['subject' => '이미지 없는 게시글']], ]; $og = $this->module->seoOgDefaults('post', $context); $this->assertArrayNotHasKey('image', $og); $this->assertSame('article', $og['type']); $this->assertSame('이미지 없는 게시글', $og['image_alt']); } }