Example #1
0
 public function testRun()
 {
     $expectedQuoteChar = substr(escapeshellarg(' '), 0, 1);
     $expectedCmd = 'phpmd' . ' "some/test/dir with space,some/test/file with space.php"' . ' xml' . ' "some/ruleset/file.xml"' . ' --reportfile "some/report/file.xml"';
     $expectedCmd = str_replace('"', $expectedQuoteChar, $expectedCmd);
     $this->_cmd->expects($this->once())->method('_execShellCmd')->with($expectedCmd);
     $this->_cmd->run(array('some/test/dir with space', 'some/test/file with space.php'));
 }
 public function testRun()
 {
     $this->_cmd->expects($this->any())->method('_getHostScript')->will($this->returnValue('cscript'));
     $this->_cmd->expects($this->any())->method('_getJsHintPath')->will($this->returnValue('jshint-path'));
     $this->_cmd->expects($this->any())->method('getFileName')->will($this->returnValue('mage.js'));
     $this->_cmd->expects($this->once())->method('_execShellCmd')->with('cscript "jshint-path" "mage.js" ');
     $this->_cmd->run([]);
 }
Example #3
0
 public function testRun()
 {
     $expectedQuoteChar = substr(escapeshellarg(' '), 0, 1);
     $expectedCmd = 'phpcpd' . ' --log-pmd "some/report/file.xml"' . ' --min-lines 5' . ' --min-tokens 50' . ' "some/test/dir with space" "some/test/file with space.php"';
     $expectedCmd = str_replace('"', $expectedQuoteChar, $expectedCmd);
     $this->_cmd->expects($this->at(0))->method('_execShellCmd')->with($expectedCmd);
     $this->_cmd->run(array('some/test/dir with space', 'some/test/file with space.php'));
 }
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);
 }
 /**
  * This test ensures that caller will be saved to delegatee on first call("entry") and will be used afterwards.
  * So there will be no difference in delegating from inside delegate or from outside call
  * @test
  */
 public function createsDelegateeOnFirstCall()
 {
     $this->subject = $this->getMockBuilder('ZloeSabo\\SimpleDelegatorTest\\ExecuteEverythingOnCallerBehalfTarget')->setMethods(['getCaller'])->getMock();
     $caller = $this->getMockBuilder('\\stdClass')->setMethods(['firstFunction', 'secondFunction'])->getMock();
     $caller->expects($this->at(0))->method('firstFunction');
     $caller->expects($this->at(1))->method('secondFunction');
     $this->subject->expects($this->once())->method('getCaller')->willReturn($caller);
     $this->subject->run();
     //Delegatee should be created after first function call
 }
Example #6
0
 /**
  * @expectedException \Magento\TestFramework\Performance\Scenario\FailureException
  * @expectedExceptionMessage command failure message
  */
 public function testRunException()
 {
     $failure = new \Magento\Framework\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->_scenario);
 }
Example #7
0
 /**
  * @param string $scenarioFile
  * @param string $reportFile
  * @param string $expectedException
  * @param string $expectedExceptionMsg
  * @dataProvider runExceptionDataProvider
  */
 public function testRunException($scenarioFile, $reportFile, $expectedException, $expectedExceptionMsg = '')
 {
     $this->setExpectedException($expectedException, $expectedExceptionMsg);
     $scenario = new Magento_Performance_Scenario('Scenario', $scenarioFile, array(), array(), array());
     $this->_object->run($scenario, $reportFile);
 }
Example #8
0
 /**
  * @param PHPUnit_Framework_MockObject_MockObject $commandManagerMock
  * @param int|null                                $forks
  */
 protected function _runCommandManagerMock(PHPUnit_Framework_MockObject_MockObject $commandManagerMock, $forks = null)
 {
     $forksArgument = isset($forks) ? '--forks=' . $forks : null;
     /** @var CM_Cli_CommandManager $commandManagerMock */
     $commandManagerMock->run(new CM_Cli_Arguments(array('', 'package-mock', 'command-mock', $forksArgument)));
 }
Example #9
0
 /**
  * @param string $scenarioFile
  * @param string $reportFile
  * @param string $expectedException
  * @param string $expectedExceptionMsg
  * @dataProvider runExceptionDataProvider
  */
 public function testRunException($scenarioFile, $reportFile, $expectedException, $expectedExceptionMsg = '')
 {
     $this->setExpectedException($expectedException, $expectedExceptionMsg);
     $scenario = new \Magento\TestFramework\Performance\Scenario('Scenario', $scenarioFile, [], [], []);
     $this->_object->run($scenario, $reportFile);
 }
 /**
  * @test
  */
 public function testWritingFileHeader()
 {
     $this->task->fileHeader(array("This is the header"));
     $this->expectOneSerializerCall(array(), "This is the header");
     $this->task->run();
 }
Example #11
0
 /**
  * @param string $scenarioFile
  * @param array $scenarioParams
  * @param string $expectedExceptionMsg
  * @dataProvider runExceptionDataProvider
  * @expectedException Magento_Exception
  */
 public function testRunException($scenarioFile, array $scenarioParams, $expectedExceptionMsg = '')
 {
     $this->setExpectedException('Magento_Exception', $expectedExceptionMsg);
     $this->_object->run($scenarioFile, $scenarioParams);
 }
 /**
  * @test
  * @dataProvider runDataProvider
  */
 public function runExecutesCorrectAction($parameters, $action)
 {
     $this->subject->expects(self::once())->method($action);
     $this->subject->run($parameters);
 }
Example #13
0
 /**
  * @param string $scenarioFile
  * @param string $reportFile
  * @param string $expectedException
  * @param string $expectedExceptionMsg
  * @dataProvider runExceptionDataProvider
  */
 public function testRunException($scenarioFile, $reportFile, $expectedException, $expectedExceptionMsg = '')
 {
     $this->setExpectedException($expectedException, $expectedExceptionMsg);
     $this->_object->run($scenarioFile, $this->_scenarioArgs, $reportFile);
 }
Example #14
0
 /**
  * @depends testRun
  */
 public function testRunWithExtensions()
 {
     $this->assertSame($this->_cmd, $this->_cmd->setExtensions(array('txt', 'xml')));
     $this->_cmd->expects($this->once())->method('_execShellCmd')->with($this->stringContains(' --extensions=txt,xml '));
     $this->_cmd->run(array());
 }