10
10
use Magento \Catalog \Api \Data \ProductInterface ;
11
11
use Magento \Catalog \Api \ProductRepositoryInterface ;
12
12
use Magento \Catalog \Model \Session ;
13
+ use Magento \Catalog \Test \Fixture \Category ;
14
+ use Magento \Catalog \Test \Fixture \Product ;
13
15
use Magento \Framework \Registry ;
14
16
use Magento \TestFramework \Catalog \Model \ProductLayoutUpdateManager ;
17
+ use Magento \TestFramework \Fixture \DataFixture ;
18
+ use Magento \TestFramework \Fixture \DataFixtureStorage ;
19
+ use Magento \TestFramework \Fixture \DataFixtureStorageManager ;
15
20
use Magento \TestFramework \Helper \Bootstrap ;
16
21
use Magento \TestFramework \Helper \Xpath ;
17
22
use Magento \TestFramework \TestCase \AbstractController ;
@@ -34,6 +39,11 @@ class ProductTest extends AbstractController
34
39
/** @var Session */
35
40
private $ session ;
36
41
42
+ /**
43
+ * @var DataFixtureStorage
44
+ */
45
+ private $ fixture ;
46
+
37
47
/**
38
48
* @inheritdoc
39
49
*/
@@ -53,6 +63,7 @@ protected function setUp(): void
53
63
$ this ->registry = $ this ->_objectManager ->get (Registry::class);
54
64
$ this ->productRepository = $ this ->_objectManager ->get (ProductRepositoryInterface::class);
55
65
$ this ->session = $ this ->_objectManager ->get (Session::class);
66
+ $ this ->fixture = DataFixtureStorageManager::getStorage ();
56
67
}
57
68
58
69
/**
@@ -255,4 +266,33 @@ public function testViewWithCustomUpdate(): void
255
266
->getHandles ();
256
267
$ this ->assertContains ("catalog_product_view_selectable_ {$ sku }_ {$ file }" , $ handles );
257
268
}
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
+ }
258
298
}
0 commit comments