Example #1
0
 public function testCleanup()
 {
     $expectedSqlFile = __DIR__ . DIRECTORY_SEPARATOR . 'drop_create_database.sql';
     $this->_model->expects($this->once())->method('_createScript')->with($expectedSqlFile, 'DROP DATABASE `schema`; CREATE DATABASE `schema`');
     $this->_shell->expects($this->once())->method('execute')->with('mysql --protocol=TCP --host=%s --user=%s --password=%s %s < %s', array('host', 'user', 'pass', 'schema', $expectedSqlFile));
     $this->_model->cleanup();
 }
Example #2
0
 public function testInstall()
 {
     $this->_shell->expects($this->once())->method('execute')->with('php -f %s -- --option1 %s --option2 %s', array($this->_installerScript, 'value1', 'value 2'));
     $this->_object->expects($this->once())->method('_bootstrap');
     $this->_object->expects($this->once())->method('_reindex');
     $this->_object->install(array('option1' => 'value1', 'option2' => 'value 2'));
 }
Example #3
0
 /**
  * Builds application mocked object, so it will produce tracked events, used for fixture application testing
  *
  * @return Magento_Application|PHPUnit_Framework_MockObject_MockObject
  */
 protected function _buildApplicationForFixtures()
 {
     $test = $this;
     $funcShellEvent = function ($command, $arguments) use($test) {
         $command = vsprintf($command, $arguments);
         if (strpos($command, 'uninstall') !== false) {
             $test->addAppEvent('uninstall');
         } else {
             if (strpos($command, 'install') !== false) {
                 $test->addAppEvent('install');
             }
         }
     };
     $this->_shell->expects($this->any())->method('execute')->will($this->returnCallback($funcShellEvent));
     $app = $this->getMock('Magento_Application', array('_bootstrap', '_reindex', '_updateFilesystemPermissions', '_cleanupMage'), array($this->_config, $this->_shell));
     // @codingStandardsIgnoreStart
     $app->expects($this->any())->method('_bootstrap')->will($this->returnCallback(function () use($test, $app) {
         $test->addAppEvent('bootstrap');
         return $app;
     }));
     $app->expects($this->any())->method('_reindex')->will($this->returnCallback(function () use($test, $app) {
         $test->addAppEvent('reindex');
         return $app;
     }));
     $app->expects($this->any())->method('_updateFilesystemPermissions')->will($this->returnCallback(function () use($test, $app) {
         $test->addAppEvent('updateFilesystemPermissions');
         return $app;
     }));
     // @codingStandardsIgnoreEnd
     return $app;
 }
Example #4
0
 public function testRunWithScripts()
 {
     $scenarioFile = realpath(__DIR__ . '/_files/scenario_with_scripts.jmx');
     $scriptBefore = realpath(__DIR__ . '/_files/scenario_with_scripts_before.php');
     $scriptAfter = realpath(__DIR__ . '/_files/scenario_with_scripts_after.php');
     $this->_shell->expects($this->at(0))->method('execute')->with('php %s', array($scriptBefore))->will($this->returnValue('fixture output'));
     $this->_shell->expects($this->at(3))->method('execute')->with('php %s --beforeOutput=%s --scenarioExecutions=%s', array($scriptAfter, 'fixture output', 4));
     $this->_object->run($scenarioFile, $this->_scenarioParams);
 }
Example #5
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);
 }
Example #6
0
 public function testRunReport()
 {
     $this->_shell->expects($this->once())->method('execute')->with('jmeter -n -t %s -l %s %s %s %s %s', array($this->_scenarioFile, $this->_reportFile, '-Jhost=127.0.0.1', '-Jpath=/', '-Jusers=2', '-Jloops=3'));
     $this->_object->run($this->_scenario, $this->_reportFile);
 }
Example #7
0
 public function testRun()
 {
     $this->_shell->expects($this->at(0))->method('execute')->with('java -jar %s -n -t %s %s %s %s %s', array('JMeter.jar', $this->_scenarioFile, '-Jhost=127.0.0.1', '-Jpath=/', '-Jusers=1', '-Jloops=2'));
     $this->_shell->expects($this->at(1))->method('execute')->with('java -jar %s -n -t %s -l %s %s %s %s %s', array('JMeter.jar', $this->_scenarioFile, $this->_reportFile, '-Jhost=127.0.0.1', '-Jpath=/', '-Jusers=2', '-Jloops=1'));
     $this->_object->run($this->_scenarioFile, $this->_scenarioParams);
 }
Example #8
0
 /**
  * @expectedException Magento_Performance_Scenario_FailureException
  * @expectedExceptionMessage command failure message
  */
 public function testRunException()
 {
     $failure = new Magento_Exception('Command returned non-zero exit code.', 0, new Exception('command failure message', 1));
     $this->_shell->expects($this->any())->method('execute')->will($this->throwException($failure));
     $this->_object->run($this->_scenarioFile, $this->_scenarioArgs);
 }