Skip to content

Commit 4e44cb9

Browse files
committed
12696 Delete all test modules after integration tests
Several test modules are created on the fly during startup of every integration test run, but they have never been deleted. This commit changes this, modules are deleted when the process ends
1 parent 80469a6 commit 4e44cb9

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

dev/tests/integration/framework/deployTestModules.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,25 @@
3838
foreach ($files as $file) {
3939
include $file;
4040
}
41+
42+
register_shutdown_function('deleteTestModules', $pathToCommittedTestModules, $pathToInstalledMagentoInstanceModules);
43+
44+
/**
45+
* Delete all test module directories which have been created before
46+
*
47+
* @param string $pathToCommittedTestModules
48+
* @param string $pathToInstalledMagentoInstanceModules
49+
*/
50+
function deleteTestModules($pathToCommittedTestModules, $pathToInstalledMagentoInstanceModules)
51+
{
52+
$filesystem = new \Symfony\Component\Filesystem\Filesystem();
53+
$iterator = new DirectoryIterator($pathToCommittedTestModules);
54+
/** @var SplFileInfo $file */
55+
foreach ($iterator as $file) {
56+
if ($file->isDir() && !in_array($file->getFilename(), ['.', '..'])) {
57+
$targetDirPath = $pathToInstalledMagentoInstanceModules . '/' . $file->getFilename();
58+
$filesystem->remove($targetDirPath);
59+
}
60+
}
61+
unset($iterator, $file);
62+
}

0 commit comments

Comments
 (0)