v7.0.0 release
This commit is contained in:
1 parent
0e7fa04b03
commit
c4ea9a6cd1
3582 files changed
+626189
-160151
No files matched your search
@@ -82,7 +82,7 @@ class EcommerceModuleSeoTest extends ModuleTestCase
|
||||
'description' => ['ko' => '한국어 설명', 'en' => 'English description'],
|
||||
'thumbnail_url' => 'https://example.com/p.jpg',
|
||||
'selling_price' => 129000,
|
||||
'in_stock' => true,
|
||||
'sales_status' => 'on_sale',
|
||||
],
|
||||
],
|
||||
];
|
||||
@@ -94,4 +94,112 @@ class EcommerceModuleSeoTest extends ModuleTestCase
|
||||
$this->assertSame('한국어 설명', $schema['description']);
|
||||
$this->assertSame('129000', $schema['offers']['price']);
|
||||
}
|
||||
|
||||
/**
|
||||
* seoOgDefaultMeta 가 데이터 경로(연결 칩) + 다국어 라벨을 선언한다.
|
||||
*/
|
||||
public function test_product_seo_og_default_meta_declares_data_path_and_label(): void
|
||||
{
|
||||
$meta = $this->module->seoOgDefaultMeta('product');
|
||||
|
||||
// label 은 번역 키(언어팩 대응) — __() 로 해석돼 한국어로 표시된다.
|
||||
$this->assertSame('{{product.data.thumbnail_url}}', $meta['image']['expr']);
|
||||
$this->assertSame('sirsoft-ecommerce::seo.auto_value.product_image', $meta['image']['label']);
|
||||
$this->assertSame('상품 대표 이미지', __($meta['image']['label'], [], 'ko'));
|
||||
$this->assertSame('Product image', __($meta['image']['label'], [], 'en'));
|
||||
$this->assertSame('{{product.data.name}}', $meta['image_alt']['expr']);
|
||||
|
||||
// category 도 자기 데이터 경로 선언.
|
||||
$catMeta = $this->module->seoOgDefaultMeta('category');
|
||||
$this->assertSame('{{category.data.thumbnail_url}}', $catMeta['image']['expr']);
|
||||
|
||||
// 도메인 외 page_type 은 빈 배열(평문 폴백).
|
||||
$this->assertSame([], $this->module->seoOgDefaultMeta('shop_index'));
|
||||
}
|
||||
|
||||
/**
|
||||
* seoStructuredDataMeta 가 점 경로 키별 데이터 경로를 선언한다.
|
||||
*/
|
||||
public function test_product_structured_data_meta_declares_dotted_paths(): void
|
||||
{
|
||||
$meta = $this->module->seoStructuredDataMeta('product');
|
||||
|
||||
$this->assertSame('{{product.data.name}}', $meta['name']['expr']);
|
||||
$this->assertSame('{{product.data.selling_price}}', $meta['offers.price']['expr']);
|
||||
$this->assertSame('{{product.data.sku}}', $meta['sku']['expr']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 정합성: 메타가 선언한 키는 운영 declaration 이 산출 가능한 키여야 한다(키 드리프트 차단).
|
||||
* og.image/image_alt 는 declaration 키 집합에 존재해야 하고, structured 점 경로는 평탄화한
|
||||
* declaration 키에 존재해야 한다(파생값 제외는 허용 — 메타 ⊆ declaration).
|
||||
*/
|
||||
public function test_meta_keys_are_subset_of_declaration_keys(): void
|
||||
{
|
||||
$context = [
|
||||
'product' => [
|
||||
'data' => [
|
||||
'name' => '키정합 상품',
|
||||
'short_description' => '설명',
|
||||
'thumbnail_url' => 'https://example.com/p.jpg',
|
||||
'sku' => 'SKU-1',
|
||||
'selling_price' => 1000,
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$ogKeys = array_keys($this->module->seoOgDefaults('product', $context));
|
||||
foreach (array_keys($this->module->seoOgDefaultMeta('product')) as $metaKey) {
|
||||
$this->assertContains($metaKey, $ogKeys, "og 메타 키 '{$metaKey}' 는 declaration 키여야 합니다");
|
||||
}
|
||||
|
||||
$flatStructured = $this->flattenKeys($this->module->seoStructuredData('product', $context));
|
||||
foreach (array_keys($this->module->seoStructuredDataMeta('product')) as $metaKey) {
|
||||
$this->assertContains($metaKey, $flatStructured, "structured 메타 키 '{$metaKey}' 는 declaration 평탄 키여야 합니다");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 결함(라이브 검수 2026-06-14): structured offers.availability 가 존재하지 않는 'in_stock' 키를
|
||||
* 참조해 **모든 상품이 OutOfStock** 으로 출력됨. ProductResource 실제 키는 sales_status(enum value)
|
||||
* 와 stock_quantity. sales_status='on_sale' → InStock 이어야 한다.
|
||||
*/
|
||||
public function test_product_structured_availability_uses_sales_status_not_missing_in_stock_key(): void
|
||||
{
|
||||
$base = [
|
||||
'name' => '재고 상품',
|
||||
'selling_price' => 1000,
|
||||
];
|
||||
|
||||
// 판매중(on_sale) → InStock.
|
||||
$onSale = $this->module->seoStructuredData('product', ['product' => ['data' => $base + ['sales_status' => 'on_sale', 'stock_quantity' => 320]]]);
|
||||
$this->assertSame('https://schema.org/InStock', $onSale['offers']['availability'], '판매중 상품은 InStock');
|
||||
|
||||
// 품절(sold_out) → OutOfStock.
|
||||
$soldOut = $this->module->seoStructuredData('product', ['product' => ['data' => $base + ['sales_status' => 'sold_out', 'stock_quantity' => 0]]]);
|
||||
$this->assertSame('https://schema.org/OutOfStock', $soldOut['offers']['availability'], '품절 상품은 OutOfStock');
|
||||
|
||||
// 판매중지(suspended) → OutOfStock.
|
||||
$suspended = $this->module->seoStructuredData('product', ['product' => ['data' => $base + ['sales_status' => 'suspended']]]);
|
||||
$this->assertSame('https://schema.org/OutOfStock', $suspended['offers']['availability'], '판매중지 상품은 OutOfStock');
|
||||
}
|
||||
|
||||
/** 중첩 배열을 점 경로 키 목록으로 평탄화(@type/@context 제외). */
|
||||
private function flattenKeys(array $block, string $prefix = ''): array
|
||||
{
|
||||
$out = [];
|
||||
foreach ($block as $k => $v) {
|
||||
if ($k === '@type' || $k === '@context') {
|
||||
continue;
|
||||
}
|
||||
$path = $prefix === '' ? (string) $k : "{$prefix}.{$k}";
|
||||
if (is_array($v) && ! array_is_list($v)) {
|
||||
$out = array_merge($out, $this->flattenKeys($v, $path));
|
||||
} else {
|
||||
$out[] = $path;
|
||||
}
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user