1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
namespace IntegerNet\GlobalCustomLayout\Test\Integration; |
5
|
|
|
|
6
|
|
|
use IntegerNet\GlobalCustomLayout\Test\Util\CategoryLayoutUpdateManager; |
7
|
|
|
use Magento\Catalog\Api\CategoryRepositoryInterface; |
8
|
|
|
use Magento\Framework\Exception\CouldNotSaveException; |
9
|
|
|
use Magento\Framework\Exception\NoSuchEntityException; |
10
|
|
|
use Magento\TestFramework\Helper\Bootstrap; |
|
|
|
|
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Tests whether global layout handles are correctly saved on categories |
14
|
|
|
* and retrieved on the frontend on Category views |
15
|
|
|
*/ |
16
|
|
|
class CategoryFrontendControllerTest extends AbstractFrontendControllerTest |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* Check that Global Custom Layout Update files work for Category views. |
20
|
|
|
* |
21
|
|
|
* @return void |
22
|
|
|
* @throws CouldNotSaveException |
23
|
|
|
* @throws NoSuchEntityException |
24
|
|
|
* |
25
|
|
|
* @magentoDataFixture Magento/CatalogUrlRewrite/_files/categories_with_product_ids.php |
26
|
|
|
*/ |
27
|
|
|
public function testViewWithGlobalCustomUpdate(): void |
28
|
|
|
{ |
29
|
|
|
//Setting a fake file for the category. |
30
|
|
|
$file = 'test-file'; |
31
|
|
|
$categoryId = 5; |
32
|
|
|
|
33
|
|
|
/** @var CategoryLayoutUpdateManager $layoutManager */ |
34
|
|
|
$layoutManager = $this->objectManager->get(CategoryLayoutUpdateManager::class); |
35
|
|
|
$layoutManager->setCategoryFakeFiles(0, [$file]); |
36
|
|
|
|
37
|
|
|
/** @var CategoryRepositoryInterface $categoryRepo */ |
38
|
|
|
$categoryRepo = $this->objectManager->create(CategoryRepositoryInterface::class); |
39
|
|
|
$category = $categoryRepo->get($categoryId); |
40
|
|
|
|
41
|
|
|
//Updating the custom attribute. |
42
|
|
|
$category->setCustomAttribute('custom_layout_update_file', $file); |
43
|
|
|
$categoryRepo->save($category); |
44
|
|
|
|
45
|
|
|
//Viewing the category |
46
|
|
|
$this->dispatch("catalog/category/view/id/$categoryId"); |
47
|
|
|
|
48
|
|
|
//Layout handles must contain the file. |
49
|
|
|
$handles = $this->layoutInterface |
50
|
|
|
->getUpdate() |
51
|
|
|
->getHandles(); |
52
|
|
|
$this->assertContains("catalog_category_view_selectable_0_{$file}", $handles); |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths