|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
namespace IntegerNet\GlobalCustomLayout\Test\Integration; |
|
5
|
|
|
|
|
6
|
|
|
use Magento\Framework\App\DeploymentConfig\Reader; |
|
7
|
|
|
use Magento\Framework\App\DeploymentConfig\Writer; |
|
8
|
|
|
use Magento\Framework\Config\File\ConfigFilePool; |
|
9
|
|
|
use Magento\Framework\Exception\FileSystemException; |
|
10
|
|
|
use Magento\Framework\Exception\LocalizedException; |
|
11
|
|
|
use Magento\Framework\Exception\RuntimeException; |
|
12
|
|
|
use Magento\Framework\Module\Status as ModuleStatus; |
|
13
|
|
|
use Magento\Framework\ObjectManagerInterface; |
|
14
|
|
|
use Magento\Framework\View\LayoutInterface; |
|
15
|
|
|
use Magento\TestFramework\Helper\Bootstrap; |
|
|
|
|
|
|
16
|
|
|
use Magento\TestFramework\TestCase\AbstractController; |
|
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @magentoAppIsolation enabled |
|
20
|
|
|
* @magentoAppArea frontend |
|
21
|
|
|
* @magentoComponentsDir ../../../../vendor/integer-net/magento2-global-custom-layout/tests/Integration/_files/app/code/IntegerNet |
|
22
|
|
|
*/ |
|
23
|
|
|
abstract class AbstractFrontendControllerTest extends AbstractController |
|
24
|
|
|
{ |
|
25
|
|
|
/** @var int */ |
|
26
|
|
|
const STORE_ID = 0; |
|
27
|
|
|
|
|
28
|
|
|
/** @var string */ |
|
29
|
|
|
const GLOBAL_TEST_FILE = 'globalfile'; |
|
30
|
|
|
|
|
31
|
|
|
/** @var string */ |
|
32
|
|
|
const DEFAULT_TEST_FILE = 'defaultfile'; |
|
33
|
|
|
|
|
34
|
|
|
/** @var int */ |
|
35
|
|
|
const GLOBAL_IDENTIFIER = 0; |
|
36
|
|
|
|
|
37
|
|
|
/** @var ObjectManagerInterface */ |
|
38
|
|
|
protected $objectManager; |
|
39
|
|
|
|
|
40
|
|
|
/** @var LayoutInterface */ |
|
41
|
|
|
protected $layout; |
|
42
|
|
|
|
|
43
|
|
|
/** @var ModuleStatus */ |
|
44
|
|
|
protected $moduleStatus; |
|
45
|
|
|
|
|
46
|
|
|
/** @var Reader */ |
|
47
|
|
|
protected $configReader; |
|
48
|
|
|
|
|
49
|
|
|
/** @var Writer */ |
|
50
|
|
|
protected $configWriter; |
|
51
|
|
|
|
|
52
|
|
|
/** @var array */ |
|
53
|
|
|
protected $initialConfig; |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* @inheritdoc |
|
57
|
|
|
* @throws LocalizedException |
|
58
|
|
|
* @magentoComponentsDir ../../../../vendor/integer-net/magento2-global-custom-layout/tests/Integration/_files/app/code/IntegerNet |
|
59
|
|
|
*/ |
|
60
|
|
|
protected function setUp(): void |
|
61
|
|
|
{ |
|
62
|
|
|
$this->objectManager = Bootstrap::getObjectManager(); |
|
63
|
|
|
$this->layout = $this->objectManager->get(LayoutInterface::class); |
|
64
|
|
|
$this->configWriter = $this->objectManager->get(Writer::class); |
|
65
|
|
|
|
|
66
|
|
|
$this->backupInitialConfig(); |
|
67
|
|
|
$this->enableTestModuleInConfig(); |
|
68
|
|
|
|
|
69
|
|
|
parent::setUp(); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
protected function enableTestModuleInConfig() |
|
73
|
|
|
{ |
|
74
|
|
|
$this->moduleStatus = $this->objectManager->create(ModuleStatus::class); |
|
75
|
|
|
$this->moduleStatus->setIsEnabled(true, ['IntegerNet_GlobalCustomLayoutTest']); |
|
76
|
|
|
|
|
77
|
|
|
$this->objectManager->removeSharedInstance(\Magento\Framework\Module\Manager::class); |
|
|
|
|
|
|
78
|
|
|
$this->objectManager->removeSharedInstance(\Magento\Framework\Module\ModuleList::class); |
|
79
|
|
|
$this->objectManager->removeSharedInstance(\Magento\Framework\View\Model\Layout\Merge::class); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @throws FileSystemException |
|
84
|
|
|
*/ |
|
85
|
|
|
protected function tearDown(): void |
|
86
|
|
|
{ |
|
87
|
|
|
$this->restoreInitialConfig(); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
/** |
|
91
|
|
|
* @throws FileSystemException |
|
92
|
|
|
*/ |
|
93
|
|
|
protected function restoreInitialConfig(): void |
|
94
|
|
|
{ |
|
95
|
|
|
$this->configWriter->saveConfig( |
|
96
|
|
|
[ConfigFilePool::APP_CONFIG => ['modules' => $this->initialConfig['modules']]], |
|
97
|
|
|
true |
|
98
|
|
|
); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* @throws FileSystemException |
|
103
|
|
|
* @throws RuntimeException |
|
104
|
|
|
*/ |
|
105
|
|
|
protected function backupInitialConfig(): void |
|
106
|
|
|
{ |
|
107
|
|
|
if (!$this->initialConfig) { |
|
|
|
|
|
|
108
|
|
|
$this->configReader = $this->objectManager->get(Reader::class); |
|
109
|
|
|
$this->initialConfig = $this->configReader->load(); |
|
110
|
|
|
} |
|
111
|
|
|
} |
|
112
|
|
|
} |
|
113
|
|
|
|
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