Skip to content

Commit 19dbedd

Browse files
committed
ACP2E-2266: add itemprop for main image for all product types
1 parent 59f898d commit 19dbedd

File tree

1 file changed

+56
-10
lines changed

1 file changed

+56
-10
lines changed

dev/tests/integration/testsuite/Magento/Catalog/Controller/ProductTest.php

Lines changed: 56 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@
77

88
namespace Magento\Catalog\Controller;
99

10+
use Magento\Bundle\Test\Fixture\Link as BundleSelectionFixture;
11+
use Magento\Bundle\Test\Fixture\Option as BundleOptionFixture;
12+
use Magento\Bundle\Test\Fixture\Product as BundleProductFixture;
1013
use Magento\Catalog\Api\Data\ProductInterface;
1114
use Magento\Catalog\Api\ProductRepositoryInterface;
15+
use Magento\ConfigurableProduct\Test\Fixture\Attribute as AttributeFixture;
16+
use Magento\ConfigurableProduct\Test\Fixture\Product as ConfigurableProductFixture;
1217
use Magento\Catalog\Model\Session;
1318
use Magento\Catalog\Test\Fixture\Category;
1419
use Magento\Catalog\Test\Fixture\Product;
@@ -267,32 +272,73 @@ public function testViewWithCustomUpdate(): void
267272
$this->assertContains("catalog_product_view_selectable_{$sku}_{$file}", $handles);
268273
}
269274

275+
/**
276+
* Validate itemprop generation on different product types' page
277+
*
278+
* @return void
279+
*/
270280
#[
271281
DataFixture(Category::class, as: 'category'),
272282
DataFixture(
273283
Product::class,
274284
['category_ids' => ['$category.id$'], 'short_description' => 'Product Short Description'],
275-
as: 'product'
276-
)
285+
as: 'sp'
286+
),
287+
DataFixture(AttributeFixture::class, ['options' => [['label' => 'option1', 'sort_order' => 0]]], as: 'attr'),
288+
DataFixture(
289+
ConfigurableProductFixture::class,
290+
[
291+
'short_description' => 'Configurable Product Short Description',
292+
'_options' => ['$attr$'],
293+
'_links' => ['$sp$']
294+
],
295+
as: 'cp'
296+
),
297+
DataFixture(BundleSelectionFixture::class, ['sku' => '$sp.sku$'], 'link1'),
298+
DataFixture(BundleOptionFixture::class, ['product_links' => ['$link1$']], 'opt1'),
299+
DataFixture(
300+
BundleProductFixture::class,
301+
[
302+
'short_description' => 'Bundle Product Short Description',
303+
'sku' => 'bundle1',
304+
'_options' => ['$opt1$']
305+
],
306+
as:'bp'
307+
),
277308
]
278309
public function testItempropOnProductPage()
279310
{
280-
$product = $this->fixture->get('product');
281-
$this->dispatch(sprintf('catalog/product/view/id/%s', $product->getEntityId()));
311+
$product = $this->fixture->get('sp');
312+
$this->checkItemProp($product);
313+
$bundleProduct = $this->fixture->get('bp');
314+
$this->checkItemProp($bundleProduct);
315+
$configurableProduct = $this->fixture->get('cp');
316+
$this->checkItemProp($configurableProduct);
317+
}
318+
319+
/**
320+
* Validate presence of itemprop for image and description
321+
*
322+
* @param ProductInterface $product
323+
* @return void
324+
*/
325+
private function checkItemProp(ProductInterface $product)
326+
{
327+
$this->dispatch(sprintf('catalog/product/view/id/%s', $product->getId()));
282328
$html = $this->getResponse()->getBody();
283-
$this->assertEquals(
284-
1,
329+
$this->assertNotEmpty(
285330
Xpath::getElementsCountForXpath(
286331
'//*[@itemprop="image"]',
287332
$html
288-
)
333+
),
334+
'itemprop image doesn\'t match for product type '.$product->getTypeId()
289335
);
290-
$this->assertEquals(
291-
1,
336+
$this->assertNotEmpty(
292337
Xpath::getElementsCountForXpath(
293338
'//*[@itemprop="description"]',
294339
$html
295-
)
340+
),
341+
'itemprop description doesn\'t match for product type '.$product->getTypeId()
296342
);
297343
}
298344
}

0 commit comments

Comments
 (0)