|
6 | 6 |
|
7 | 7 | use Magento\Catalog\Api\Data\CategoryInterface; |
8 | 8 | use Magento\Catalog\Block\Product\ListProduct; |
| 9 | +use Magento\Catalog\Model\Category; |
| 10 | +use Magento\CatalogWidget\Block\Product\ProductsList; |
| 11 | +use Magento\Eav\Model\Entity\Collection\AbstractCollection; |
| 12 | +use Magento\Framework\App\Response\Http; |
9 | 13 | use Yireo\GoogleTagManager2\Test\Integration\FixtureTrait\GetCategory; |
10 | 14 | use Yireo\GoogleTagManager2\Test\Integration\FixtureTrait\Reindex; |
11 | 15 | use Yireo\GoogleTagManager2\Test\Integration\PageTestCase; |
@@ -35,18 +39,23 @@ public function testValidDataLayerWithOneCategory() |
35 | 39 | { |
36 | 40 | $this->assertEnabledFlagIsWorking(); |
37 | 41 |
|
| 42 | + /** @var Category $category */ |
38 | 43 | $category = $this->getCategoryByName('Category 999'); |
39 | 44 |
|
| 45 | + /** @var AbstractCollection $productCollection */ |
40 | 46 | $productCollection = $category->getProductCollection(); |
41 | 47 | $this->assertTrue($productCollection->count() >= 3, 'Product count is '.$productCollection->count()); |
42 | 48 |
|
43 | 49 | $this->dispatch('catalog/category/view/id/' . $category->getId()); |
44 | 50 | $this->assertRequestActionName('view'); |
45 | 51 |
|
46 | | - $body = $this->getResponse()->getBody(); |
| 52 | + /** @var Http $response */ |
| 53 | + $response = $this->getResponse(); |
| 54 | + $body = $response->getBody(); |
47 | 55 | $this->assertStringContainsString($category->getName(), $body); |
48 | 56 | $this->assertStringContainsString('"view_item_list"', $body); |
49 | 57 |
|
| 58 | + /** @var ListProduct $productListBlock */ |
50 | 59 | $productListBlock = $this->layout->getBlock('category.products.list'); |
51 | 60 | $productListBlock->setCollection($productCollection); |
52 | 61 | $this->assertInstanceOf(ListProduct::class, $productListBlock); |
@@ -82,7 +91,7 @@ public function testValidDataLayerWithOneCategory() |
82 | 91 | } |
83 | 92 | } |
84 | 93 |
|
85 | | - private function getProductsByCategory(CategoryInterface $category): array |
| 94 | + private function getProductsByCategory(Category $category): array |
86 | 95 | { |
87 | 96 | return $category->getProductCollection()->toArray(); |
88 | 97 | } |
|
0 commit comments