deployTestModules.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. /**
  7. * @var $testFrameworkDir string - Must be defined in parent script.
  8. */
  9. /** Copy test modules to app/code/Magento to make them visible for Magento instance */
  10. $pathToCommittedTestModules = $testFrameworkDir . '/../_files/Magento';
  11. $pathToInstalledMagentoInstanceModules = $testFrameworkDir . '/../../../../app/code/Magento';
  12. $iterator = new RecursiveIteratorIterator(
  13. new RecursiveDirectoryIterator($pathToCommittedTestModules, RecursiveDirectoryIterator::FOLLOW_SYMLINKS)
  14. );
  15. /** @var SplFileInfo $file */
  16. foreach ($iterator as $file) {
  17. if (!$file->isDir()) {
  18. $source = $file->getPathname();
  19. $relativePath = substr($source, strlen($pathToCommittedTestModules));
  20. $destination = $pathToInstalledMagentoInstanceModules . $relativePath;
  21. $targetDir = dirname($destination);
  22. if (!is_dir($targetDir)) {
  23. mkdir($targetDir, 0755, true);
  24. }
  25. copy($source, $destination);
  26. }
  27. }
  28. unset($iterator, $file);
  29. // Register the modules under '_files/'
  30. $pathPattern = $pathToInstalledMagentoInstanceModules . '/TestModule*/registration.php';
  31. $files = glob($pathPattern, GLOB_NOSORT);
  32. if ($files === false) {
  33. throw new \RuntimeException('glob() returned error while searching in \'' . $pathPattern . '\'');
  34. }
  35. foreach ($files as $file) {
  36. include $file;
  37. }