assertInstanceOf(ApiDocSampleSeeder::class, new ApiDocSampleService); } #[Test] public function 이커머스_핵심_도메인_대표_샘플_맵을_반환한다(): void { // 회원 소유 도메인(orders/reviews/inquiries/addresses/mileage)은 실측 사용자를 // 전제한다 — 실측 커맨드 컨텍스트(코어 완전 샘플 사용자)를 재현하기 위해 먼저 생성. User::factory()->create(); $map = (new ApiDocSampleService)->seed(); // 핵심 상세 GET 대상 도메인 키가 모두 존재 foreach (['products', 'categories', 'orders', 'reviews', 'settings'] as $domain) { $this->assertArrayHasKey($domain, $map, "도메인 '{$domain}' 누락"); } $this->assertSame(Product::class, $map['products']['model']); $this->assertNotEmpty($map['products']['value']); } #[Test] public function 문자열_path_param_실측용_맵을_제공한다(): void { $map = (new ApiDocSampleService)->seed(); // products: 공개 show(id)·admin show(identifier/code)·상품 하위(productId) $product = Product::query()->where('product_code', self::SAMPLE_PRODUCT_CODE)->firstOrFail(); $params = $map['products']['path_params']; $this->assertSame((string) $product->getKey(), $params['id']); $this->assertSame((string) $product->getKey(), $params['identifier']); $this->assertSame(self::SAMPLE_PRODUCT_CODE, $params['code']); $this->assertSame((string) $product->getKey(), $params['productId']); // categories: 공개 show 는 slug $this->assertSame(self::SAMPLE_CATEGORY_SLUG, $map['categories']['path_params']['slug']); // settings: 레코드 없이 유효 카테고리 문자열 고정 $this->assertSame('basic_info', $map['settings']['path_params']['category']); } #[Test] public function 공개_상세_실측용_상품은_전시_상태다(): void { (new ApiDocSampleService)->seed(); $product = Product::query()->where('product_code', self::SAMPLE_PRODUCT_CODE)->firstOrFail(); // products/{id} 공개 show 는 display_status===visible 필터 → 실측 가능해야 함 $this->assertSame('visible', $product->display_status->value); $this->assertSame('on_sale', $product->sales_status->value); } #[Test] public function 공개_slug_조회용_카테고리는_활성이며_slug를_갖는다(): void { (new ApiDocSampleService)->seed(); $category = Category::query()->where('slug', self::SAMPLE_CATEGORY_SLUG)->firstOrFail(); $this->assertTrue((bool) $category->is_active); $this->assertSame(self::SAMPLE_CATEGORY_SLUG, $category->slug); } #[Test] public function 재실행_시_샘플이_중복_생성되지_않는다(): void { $service = new ApiDocSampleService; $service->seed(); $service->seed(); $this->assertSame( 1, Product::query()->where('product_code', self::SAMPLE_PRODUCT_CODE)->count() ); $this->assertSame( 1, Category::query()->where('slug', self::SAMPLE_CATEGORY_SLUG)->count() ); } }