Exemple #1
0
 /**
  * Run entire test suite of scenarios
  */
 public function run()
 {
     $this->_reportFiles = array();
     $scenarios = $this->_getOptimizedScenarioList();
     foreach ($scenarios as $scenario) {
         /** @var $scenario Magento_Performance_Scenario */
         $this->_application->applyFixtures($scenario->getFixtures());
         $this->_notifyScenarioRun($scenario);
         /* warm up cache, if any */
         $settings = $scenario->getSettings();
         if (empty($settings[self::SETTING_SKIP_WARM_UP])) {
             try {
                 $scenarioWarmUp = new Magento_Performance_Scenario($scenario->getTitle(), $scenario->getFile(), $this->_warmUpArguments + $scenario->getArguments(), $scenario->getSettings(), $scenario->getFixtures());
                 $this->_scenarioHandler->run($scenarioWarmUp);
             } catch (Magento_Performance_Scenario_FailureException $scenarioFailure) {
                 // do not notify about failed warm up
             }
         }
         /* full run with reports recording */
         $reportFile = $this->_getScenarioReportFile($scenario);
         try {
             $this->_scenarioHandler->run($scenario, $reportFile);
         } catch (Magento_Performance_Scenario_FailureException $scenarioFailure) {
             $this->_notifyScenarioFailure($scenarioFailure);
         }
     }
 }
Exemple #2
0
 public function testApplyFixturesIncompatibleSetReinstallation()
 {
     $this->_shell->expects($this->at(0))->method('execute')->with($this->stringContains('--uninstall'), $this->contains($this->_installerScript));
     $this->_shell->expects($this->at(1))->method('execute')->with($this->logicalNot($this->stringContains('--uninstall')), $this->contains($this->_installerScript));
     $this->_shell->expects($this->at(2))->method('execute')->with($this->stringContains('--uninstall'), $this->contains($this->_installerScript));
     $this->_shell->expects($this->at(3))->method('execute')->with($this->logicalNot($this->stringContains('--uninstall')), $this->contains($this->_installerScript));
     $fixtures = $this->_getFixtureFiles(array('fixture1', 'fixture2'));
     $this->_object->applyFixtures($fixtures);
     $incompatibleSet = $this->_getFixtureFiles(array('fixture1'));
     $this->_object->applyFixtures($incompatibleSet);
 }
Exemple #3
0
 /**
  * Run entire test suite of scenarios
  *
  * @throws Magento_Exception
  */
 public function run()
 {
     $scenarios = $this->_getOptimizedScenarioList();
     foreach ($scenarios as $scenarioFile) {
         $scenarioArguments = $this->_config->getScenarioArguments($scenarioFile);
         $scenarioSettings = $this->_config->getScenarioSettings($scenarioFile);
         $scenarioFixtures = $this->_config->getScenarioFixtures($scenarioFile);
         $this->_application->applyFixtures($scenarioFixtures);
         /* warm up cache, if any */
         if (empty($scenarioSettings[self::SETTING_SKIP_WARM_UP])) {
             $warmUpArgs = new Magento_Performance_Scenario_Arguments($this->_warmUpArguments + (array) $scenarioArguments);
             $this->_scenarioHandler->run($scenarioFile, $warmUpArgs);
         }
         /* full run with reports recording */
         $scenarioName = preg_replace('/\\..+?$/', '', basename($scenarioFile));
         $reportFile = $this->_config->getReportDir() . DIRECTORY_SEPARATOR . $scenarioName . '.jtl';
         if (!$this->_scenarioHandler->run($scenarioFile, $scenarioArguments, $reportFile)) {
             throw new Magento_Exception("Unable to run scenario '{$scenarioFile}', format is not supported.");
         }
     }
 }
 /**
  * Test application of fixtures, asserting that proper fixtures have been applied,
  * and application events have happened
  *
  * @param Magento_Application|PHPUnit_Framework_MockObject_MockObject $application
  * @param array $fixtures
  * @param array $expectedFixtures
  * @param array $expectedEvents
  * @param string $message
  */
 protected function _testApplyFixtures($application, $fixtures, $expectedFixtures, $expectedEvents, $message)
 {
     // Prepare
     $nameToPathFunc = function ($fixture) {
         return __DIR__ . "/_files/application_test/{$fixture}.php";
     };
     $fixtures = array_map($nameToPathFunc, $fixtures);
     $this->_appEvents = array();
     $this->_fixtureEvents = array();
     // Run
     $GLOBALS['applicationTestForFixtures'] = $this;
     // Expose itself to fixtures
     try {
         $application->applyFixtures($fixtures);
         // Assert expectations
         $fixtureEvents = array_keys($this->_fixtureEvents);
         sort($fixtureEvents);
         sort($expectedFixtures);
         $this->assertEquals($expectedFixtures, $fixtureEvents, "{$message} - fixtures applied are wrong");
         $appEvents = array_keys($this->_appEvents);
         sort($appEvents);
         sort($expectedEvents);
         $this->assertEquals($expectedEvents, $appEvents, "{$message} - application management is wrong");
         unset($GLOBALS['applicationTestForFixtures']);
     } catch (Exception $e) {
         unset($GLOBALS['applicationTestForFixtures']);
         throw $e;
     }
 }