removeTestModules.php 971 Bytes
Newer Older
Ketan's avatar
Ketan committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

/**
 * @var $testFrameworkDir string - Must be defined in parent script.
 */

/**
 * Copy test modules to app/code/Magento to make them visible for Magento instance.
 */
$pathToCommittedTestModules = $testFrameworkDir . '/../_files/Magento';
$pathToInstalledMagentoInstanceModules = $testFrameworkDir . '/../../../../app/code/Magento';
$iterator = new RecursiveIteratorIterator(
    new RecursiveDirectoryIterator($pathToCommittedTestModules, RecursiveDirectoryIterator::FOLLOW_SYMLINKS)
);

//collect test modules dirs name
$testModuleNames = array_diff(scandir($pathToCommittedTestModules), ['..', '.']);

//remove test modules from magento codebase
foreach ($testModuleNames as $name) {
    $folder = $pathToInstalledMagentoInstanceModules . '/' . $name;
    if (is_dir($folder)) {
        \Magento\Framework\Filesystem\Io\File::rmdirRecursive($folder);
    }
}