/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { try { Files::setInstance(new Files($input->getOption(self::INPUT_KEY_DIRECTORY))); $this->buildReport($input->getOption(self::INPUT_KEY_OUTPUT)); $output->writeln('<info>Report successfully processed.</info>'); } catch (\Exception $e) { $output->writeln( '<error>Please check the path you provided. Dependencies report generator failed with error: ' . $e->getMessage() . '</error>' ); } }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { try { /** @var \Magento\Framework\Component\ComponentRegistrar $componentRegistrar */ $componentRegistrar = $this->objectManager->get('Magento\\Framework\\Component\\ComponentRegistrar'); /** @var \Magento\Framework\Component\DirSearch $dirSearch */ $dirSearch = $this->objectManager->get('Magento\\Framework\\Component\\DirSearch'); /** @var \Magento\Framework\View\Design\Theme\ThemePackageList $themePackageList */ $themePackageList = $this->objectManager->get('Magento\\Framework\\View\\Design\\Theme\\ThemePackageList'); Files::setInstance(new Files($componentRegistrar, $dirSearch, $themePackageList)); $this->buildReport($input->getOption(self::INPUT_KEY_OUTPUT)); $output->writeln('<info>Report successfully processed.</info>'); } catch (\Exception $e) { $output->writeln('<error>Please check the path you provided. Dependencies report generator failed with error: ' . $e->getMessage() . '</error>'); } }
<?php /** * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ require __DIR__ . '/autoload.php'; \Magento\Framework\App\Utility\Files::setInstance(new \Magento\Framework\App\Utility\Files(BP));
} else { $shell = new \Magento\Framework\Shell(new \Magento\Framework\Shell\CommandRenderer()); } $installConfigFile = $settings->getAsConfigFile('TESTS_INSTALL_CONFIG_FILE'); if (!file_exists($installConfigFile)) { $installConfigFile .= '.dist'; } $globalConfigFile = $settings->getAsConfigFile('TESTS_GLOBAL_CONFIG_FILE'); if (!file_exists($globalConfigFile)) { $globalConfigFile .= '.dist'; } $sandboxUniqueId = md5(sha1_file($installConfigFile)); $installDir = TESTS_TEMP_DIR . "/sandbox-{$settings->get('TESTS_PARALLEL_THREAD', 0)}-{$sandboxUniqueId}"; $application = new \Magento\TestFramework\Application($shell, $installDir, $installConfigFile, $globalConfigFile, $settings->get('TESTS_GLOBAL_CONFIG_DIR'), $settings->get('TESTS_MAGENTO_MODE'), AutoloaderRegistry::getAutoloader(), true); $bootstrap = new \Magento\TestFramework\Bootstrap($settings, new \Magento\TestFramework\Bootstrap\Environment(), new \Magento\TestFramework\Bootstrap\DocBlock("{$testsBaseDir}/testsuite"), new \Magento\TestFramework\Bootstrap\Profiler(new \Magento\Framework\Profiler\Driver\Standard()), $shell, $application, new \Magento\TestFramework\Bootstrap\MemoryFactory($shell)); $bootstrap->runBootstrap(); if ($settings->getAsBoolean('TESTS_CLEANUP')) { $application->cleanup(); } if (!$application->isInstalled()) { $application->install(); } $application->initialize([]); \Magento\TestFramework\Helper\Bootstrap::setInstance(new \Magento\TestFramework\Helper\Bootstrap($bootstrap)); \Magento\Framework\App\Utility\Files::setInstance(new Magento\Framework\App\Utility\Files($magentoBaseDir)); /* Unset declared global variables to release the PHPUnit from maintaining their values between tests */ unset($testsBaseDir, $magentoBaseDir, $logWriter, $settings, $shell, $application, $bootstrap); } catch (\Exception $e) { echo $e . PHP_EOL; exit(1); }
} foreach ($files as $file) { include $file; } /* Bootstrap the application */ $settings = new \Magento\TestFramework\Bootstrap\Settings($testsBaseDir, get_defined_constants()); $shell = new \Magento\Framework\Shell(new \Magento\Framework\Shell\CommandRenderer(), $logger); $installConfigFile = $settings->getAsConfigFile('TESTS_INSTALL_CONFIG_FILE'); if (!file_exists($installConfigFile)) { $installConfigFile = $installConfigFile . '.dist'; } $globalConfigFile = $settings->getAsConfigFile('TESTS_GLOBAL_CONFIG_FILE'); if (!file_exists($installConfigFile)) { $installConfigFile = $installConfigFile . '.dist'; } $dirList = new \Magento\Framework\App\Filesystem\DirectoryList(BP); $application = new \Magento\TestFramework\WebApiApplication($shell, $dirList->getPath(DirectoryList::VAR_DIR), $installConfigFile, $globalConfigFile, BP . '/app/etc/', $settings->get('TESTS_MAGENTO_MODE'), AutoloaderRegistry::getAutoloader()); if (defined('TESTS_MAGENTO_INSTALLATION') && TESTS_MAGENTO_INSTALLATION === 'enabled') { if (defined('TESTS_CLEANUP') && TESTS_CLEANUP === 'enabled') { $application->cleanup(); } $application->install(); } $bootstrap = new \Magento\TestFramework\Bootstrap($settings, new \Magento\TestFramework\Bootstrap\Environment(), new \Magento\TestFramework\Bootstrap\WebapiDocBlock("{$integrationTestsDir}/testsuite"), new \Magento\TestFramework\Bootstrap\Profiler(new \Magento\Framework\Profiler\Driver\Standard()), $shell, $application, new \Magento\TestFramework\Bootstrap\MemoryFactory($shell)); $bootstrap->runBootstrap(); $application->initialize(); \Magento\TestFramework\Helper\Bootstrap::setInstance(new \Magento\TestFramework\Helper\Bootstrap($bootstrap)); $dirSearch = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\Component\\DirSearch'); $themePackageList = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Framework\\View\\Design\\Theme\\ThemePackageList'); \Magento\Framework\App\Utility\Files::setInstance(new \Magento\Framework\App\Utility\Files(new \Magento\Framework\Component\ComponentRegistrar(), $dirSearch, $themePackageList)); unset($bootstrap, $application, $settings, $shell);
<?php /** * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ require_once __DIR__ . '/bootstrap.php'; use Magento\Framework\App\Utility\Files; use Magento\Tools\Dependency\ServiceLocator; try { $console = new \Zend_Console_Getopt(['directory|d=s' => 'Path to base directory for parsing']); $console->parse(); $directory = $console->getOption('directory') ?: BP; Files::setInstance(new \Magento\Framework\App\Utility\Files($directory)); $filesForParse = Files::init()->getComposerFiles('code', false); ServiceLocator::getCircularDependenciesReportBuilder()->build(['parse' => ['files_for_parse' => $filesForParse], 'write' => ['report_filename' => 'modules-circular-dependencies.csv']]); fwrite(STDOUT, PHP_EOL . 'Report successfully processed.' . PHP_EOL); } catch (\Zend_Console_Getopt_Exception $e) { fwrite(STDERR, $e->getUsageMessage() . PHP_EOL); exit(1); } catch (\Exception $e) { fwrite(STDERR, 'Please, check passed path. Dependencies report generator failed: ' . $e->getMessage() . PHP_EOL); exit(1); }
public static function tearDownAfterClass() { Files::setInstance(); }
$application = new Application($shell, $installDir, $installConfigFile, $globalConfigFile, $settings->get('TESTS_GLOBAL_CONFIG_DIR'), $settings->get('TESTS_MAGENTO_MODE'), AutoloaderRegistry::getAutoloader()); // Create a bootstrapper which will do most of the work of setting up the // M2 environment for the application to run. $bootstrap = new Bootstrap($settings, new Environment(), new BehatDocBlock("{$testsBaseDir}/testsuite"), new Profiler(new StandardProfilerDriver()), $shell, $application, new MemoryFactory($shell)); // Setup for environment HTTP and session emulation, profiling, memory // limits, and event registration (through a somewhat dubious side-effect // of DocBlock annotation registration). $bootstrap->runBootstrap(); // cleanup and install ensure the M2 environment is clean before running // tests - uninstalls M2 and then reinstalls it using the test configuration. // @TODO This may need to be extended to also include any initial data needed // for the tests. if ($settings->getAsBoolean('TESTS_CLEANUP')) { $application->cleanup(); } if (!$application->isInstalled()) { $application->install(); } // Initialize the application. Largely responsible for setting up the // object manager instance - including updating relevant configuration for // the object manager to use test configuration - and replacing some // dependencies from the core Magento framework with alternatives from the // test framework. $application->initialize(); BootstrapHelper::setInstance(new BootstrapHelper($bootstrap)); AppFilesUtility::setInstance(new AppFilesUtility($magentoBaseDir)); } catch (\Exception $e) { echo $e . PHP_EOL; exit(1); } });
protected function tearDown() { Files::setInstance(); }
<?php /** * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ require __DIR__ . '/autoload.php'; \Magento\Framework\App\Utility\Files::setInstance(new \Magento\Framework\App\Utility\Files(realpath('../..'))); error_reporting(E_ALL); ini_set('display_errors', 1);