Skip to content

Commit 9ab5791

Browse files
committed
MAGETWO-88409: Builds stabilization for PR
- setup integration tests fix
1 parent 2f19204 commit 9ab5791

File tree

1 file changed

+21
-9
lines changed
  • dev/tests/setup-integration/framework/Magento/TestFramework/Annotation

1 file changed

+21
-9
lines changed

dev/tests/setup-integration/framework/Magento/TestFramework/Annotation/CopyModules.php

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,33 @@ public function endTest(\PHPUnit\Framework\TestCase $test)
6666
{
6767
$annotations = $test->getAnnotations();
6868
//This annotation can be declared only on method level
69-
if (isset($annotations['method']['moduleName'])) {
69+
if (!empty($annotations['method']['moduleName'])) {
7070
foreach ($annotations['method']['moduleName'] as $moduleName) {
7171
$path = MAGENTO_MODULES_PATH .
7272
//Take only module name from Magento_ModuleName
7373
explode("_", $moduleName)[1];
74-
7574
File::rmdirRecursive($path);
75+
$this->unsergisterModuleFromComponentRegistrar($moduleName);
7676
}
77-
78-
$reflection = new \ReflectionClass(ComponentRegistrar::class);
79-
$reflectionProperty = $reflection->getProperty('paths');
80-
$reflectionProperty->setAccessible(true);
81-
$value = $reflectionProperty->getValue();
82-
$value[ComponentRegistrar::MODULE] = [];
83-
$reflectionProperty->setValue($value);
8477
}
8578
}
79+
80+
/**
81+
* Unregister module from component registrar.
82+
* The component registrar uses static private variable and does not provide unregister method,
83+
* however unregister is required to remove registered modules after they are deleted from app/code.
84+
*
85+
* @param $moduleName
86+
*
87+
* @return void
88+
*/
89+
private function unsergisterModuleFromComponentRegistrar($moduleName)
90+
{
91+
$reflection = new \ReflectionClass(ComponentRegistrar::class);
92+
$reflectionProperty = $reflection->getProperty('paths');
93+
$reflectionProperty->setAccessible(true);
94+
$value = $reflectionProperty->getValue();
95+
unset($value[ComponentRegistrar::MODULE][$moduleName]);
96+
$reflectionProperty->setValue($value);
97+
}
8698
}

0 commit comments

Comments
 (0)