Пример #1
0
 /**
  * @covers \Magento\TestFramework\Application::getTempDir
  * @covers \Magento\TestFramework\Application::getDbInstance()
  * @covers \Magento\TestFramework\Application::getInitParams()
  */
 public function testConstructor()
 {
     $shell = $this->getMock('\\Magento\\Framework\\Shell', [], [], '', false);
     $autoloadWrapper = $this->getMockBuilder('Magento\\Framework\\Autoload\\ClassLoaderWrapper')->disableOriginalConstructor()->getMock();
     $tempDir = '/temp/dir';
     $appMode = \Magento\Framework\App\State::MODE_DEVELOPER;
     $object = new \Magento\TestFramework\Application($shell, $tempDir, 'config.php', 'global-config.php', '', $appMode, $autoloadWrapper);
     $this->assertEquals($tempDir, $object->getTempDir(), 'Temp directory is not set in Application');
     $initParams = $object->getInitParams();
     $this->assertInternalType('array', $initParams, 'Wrong initialization parameters type');
     $this->assertArrayHasKey(Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS, $initParams, 'Directories are not configured');
     $this->assertArrayHasKey(State::PARAM_MODE, $initParams, 'Application mode is not configured');
     $this->assertEquals(\Magento\Framework\App\State::MODE_DEVELOPER, $initParams[State::PARAM_MODE], 'Wrong application mode configured');
 }
Пример #2
0
 /**
  * @covers \Magento\TestFramework\Application::getInstallDir()
  * @covers \Magento\TestFramework\Application::getDbInstance()
  * @covers \Magento\TestFramework\Application::getInitParams()
  */
 public function testConstructor()
 {
     $dbInstance = $this->getMockForAbstractClass('Magento\\TestFramework\\Db\\AbstractDb', array(), '', false);
     $installDir = '/install/dir';
     $appMode = \Magento\Framework\App\State::MODE_DEVELOPER;
     $directoryList = new \Magento\Framework\App\Filesystem\DirectoryList(BP);
     $filesystem = new \Magento\Framework\App\Filesystem($directoryList, new \Magento\Framework\Filesystem\Directory\ReadFactory(), new \Magento\Framework\Filesystem\Directory\WriteFactory(), new \Magento\Framework\Filesystem\File\ReadFactory(new \Magento\Framework\Filesystem\DriverFactory($directoryList)), new \Magento\Framework\Filesystem\File\WriteFactory(new \Magento\Framework\Filesystem\DriverFactory($directoryList)));
     $object = new \Magento\TestFramework\Application($dbInstance, $installDir, new \Magento\Framework\Simplexml\Element('<data/>'), '', array(), $appMode, $filesystem);
     $this->assertSame($dbInstance, $object->getDbInstance(), 'Db instance is not set in Application');
     $this->assertEquals($installDir, $object->getInstallDir(), 'Install directory is not set in Application');
     $initParams = $object->getInitParams();
     $this->assertInternalType('array', $initParams, 'Wrong initialization parameters type');
     $this->assertArrayHasKey(\Magento\Framework\App\Filesystem::PARAM_APP_DIRS, $initParams, 'Directories are not configured');
     $this->assertArrayHasKey(State::PARAM_MODE, $initParams, 'Application mode is not configured');
     $this->assertEquals(\Magento\Framework\App\State::MODE_DEVELOPER, $initParams[State::PARAM_MODE], 'Wrong application mode configured');
 }
Пример #3
0
        $logWriter->setFormatter(new \Zend_Log_Formatter_Simple('%message%' . PHP_EOL));
        $shell = new \Magento\Framework\Shell(new \Magento\Framework\Shell\CommandRenderer(), new \Zend_Log($logWriter));
    } 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;