Esempio n. 1
0
 * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
require_once __DIR__ . '/../../../../app/bootstrap.php';
require_once __DIR__ . '/../../static/framework/Magento/TestFramework/Utility/Classes.php';
require_once __DIR__ . '/../../static/framework/Magento/TestFramework/Utility/AggregateInvoker.php';
$testsBaseDir = dirname(__DIR__);
$testsTmpDir = "{$testsBaseDir}/tmp";
$magentoBaseDir = realpath("{$testsBaseDir}/../../../");
(new \Magento\Framework\Autoload\IncludePath())->addIncludePath(array("{$testsBaseDir}/framework", "{$testsBaseDir}/testsuite"));
function tool_autoloader($className)
{
    if (strpos($className, 'Magento\\Tools\\') === false) {
        return false;
    }
    $filePath = str_replace('\\', '/', $className);
    $filePath = BP . '/dev/tools/' . $filePath . '.php';
    if (file_exists($filePath)) {
        include_once $filePath;
    } else {
        return false;
    }
}
spl_autoload_register('tool_autoloader');
/* Bootstrap the application */
$invariantSettings = array('TESTS_LOCAL_CONFIG_EXTRA_FILE' => 'etc/integration-tests-config.xml');
$bootstrap = new \Magento\TestFramework\Bootstrap(new \Magento\TestFramework\Bootstrap\Settings($testsBaseDir, $invariantSettings + get_defined_constants()), new \Magento\TestFramework\Bootstrap\Environment(), new \Magento\TestFramework\Bootstrap\DocBlock("{$testsBaseDir}/testsuite"), new \Magento\TestFramework\Bootstrap\Profiler(new \Magento\Framework\Profiler\Driver\Standard()), new \Magento\Framework\Shell(new \Magento\Framework\Shell\CommandRenderer()), $testsTmpDir);
$bootstrap->runBootstrap();
\Magento\TestFramework\Helper\Bootstrap::setInstance(new \Magento\TestFramework\Helper\Bootstrap($bootstrap));
Magento\TestFramework\Utility\Files::setInstance(new Magento\TestFramework\Utility\Files($magentoBaseDir));
/* Unset declared global variables to release the PHPUnit from maintaining their values between tests */
unset($bootstrap);
Esempio n. 2
0
USAGE
);
$options = getopt('p:h');
if (isset($options['h'])) {
    echo USAGE;
    exit(0);
}
require_once realpath(dirname(dirname(dirname(dirname(dirname(__DIR__)))))) . '/dev/tests/static/framework/bootstrap.php';
require_once realpath(dirname(dirname(dirname(dirname(dirname(__DIR__)))))) . '/dev/tests/static/framework/Magento/TestFramework/Utility/Classes.php';
require_once realpath(dirname(dirname(dirname(dirname(dirname(__DIR__)))))) . '/lib/internal/Zend/Json.php';
$magentoBaseDir = dirname(__DIR__) . '/../../../../';
if (isset($options['p'])) {
    $magentoBaseDir = $options['p'];
}
$utilityFiles = new Magento\TestFramework\Utility\Files($magentoBaseDir);
$map = array();
$compositeModules = getFilesCombinedArray(__DIR__ . '/aliases_map', '/^composite_modules_.*\\.php$/');
// PHP code
foreach ($utilityFiles->getPhpFiles(true, true, true, false) as $file) {
    $content = file_get_contents($file);
    $classes = \Magento\TestFramework\Utility\Classes::collectPhpCodeClasses($content);
    if ($classes) {
        $factoryNames = array_filter($classes, 'isFactoryName');
        foreach ($factoryNames as $factoryName) {
            list($module, $name) = getModuleName($factoryName, $compositeModules);
            $patterns = array('::getModel(\'%s\'' => 'Model', '::getSingleton(\'%s\'' => 'Model', '::getResourceModel(\'%s\'' => 'Model_Resource', '::getResourceSingleton(\'%s\'' => 'Model_Resource', 'addBlock(\'%s\'' => 'Block', 'createBlock(\'%s\'' => 'Block', 'getBlockClassName(\'%s\'' => 'Block', 'getBlockSingleton(\'%s\'' => 'Block');
            foreach ($patterns as $pattern => $classType) {
                if (isPatternExist($content, $pattern, $factoryName)) {
                    if (!isset($map[$classType])) {
                        $map[$classType] = array();