1010use Magento \Catalog \Api \Data \ProductInterface ;
1111use Magento \Catalog \Api \ProductRepositoryInterface ;
1212use Magento \Catalog \Model \Session ;
13+ use Magento \Catalog \Test \Fixture \Category ;
14+ use Magento \Catalog \Test \Fixture \Product ;
1315use Magento \Framework \Registry ;
1416use Magento \TestFramework \Catalog \Model \ProductLayoutUpdateManager ;
17+ use Magento \TestFramework \Fixture \DataFixture ;
18+ use Magento \TestFramework \Fixture \DataFixtureStorage ;
19+ use Magento \TestFramework \Fixture \DataFixtureStorageManager ;
1520use Magento \TestFramework \Helper \Bootstrap ;
1621use Magento \TestFramework \Helper \Xpath ;
1722use Magento \TestFramework \TestCase \AbstractController ;
@@ -34,6 +39,11 @@ class ProductTest extends AbstractController
3439 /** @var Session */
3540 private $ session ;
3641
42+ /**
43+ * @var DataFixtureStorage
44+ */
45+ private $ fixture ;
46+
3747 /**
3848 * @inheritdoc
3949 */
@@ -53,6 +63,7 @@ protected function setUp(): void
5363 $ this ->registry = $ this ->_objectManager ->get (Registry::class);
5464 $ this ->productRepository = $ this ->_objectManager ->get (ProductRepositoryInterface::class);
5565 $ this ->session = $ this ->_objectManager ->get (Session::class);
66+ $ this ->fixture = DataFixtureStorageManager::getStorage ();
5667 }
5768
5869 /**
@@ -255,4 +266,33 @@ public function testViewWithCustomUpdate(): void
255266 ->getHandles ();
256267 $ this ->assertContains ("catalog_product_view_selectable_ {$ sku }_ {$ file }" , $ handles );
257268 }
269+
270+ #[
271+ DataFixture(Category::class, as: 'category ' ),
272+ DataFixture(
273+ Product::class,
274+ ['category_ids ' => ['$category.id$ ' ], 'short_description ' => 'Product Short Description ' ],
275+ as: 'product '
276+ )
277+ ]
278+ public function testItempropOnProductPage ()
279+ {
280+ $ product = $ this ->fixture ->get ('product ' );
281+ $ this ->dispatch (sprintf ('catalog/product/view/id/%s ' , $ product ->getEntityId ()));
282+ $ html = $ this ->getResponse ()->getBody ();
283+ $ this ->assertEquals (
284+ 1 ,
285+ Xpath::getElementsCountForXpath (
286+ '//*[@itemprop="image"] ' ,
287+ $ html
288+ )
289+ );
290+ $ this ->assertEquals (
291+ 1 ,
292+ Xpath::getElementsCountForXpath (
293+ '//*[@itemprop="description"] ' ,
294+ $ html
295+ )
296+ );
297+ }
258298}
0 commit comments