Ejemplo n.º 1
0
 /**
  * @test
  */
 public function executePassePrefixedDefinedTaskOptionsToDefinedTask()
 {
     $globalOptions = array('MyVendor\\MyPackage\\DefinedTask\\TaskGroup\\MyTask[taskOption]' => 'Foo');
     $this->deployment->setOptions($globalOptions);
     $this->task->expects($this->atLeastOnce())->method('execute')->with($this->anything(), $this->anything(), $this->anything(), $this->arrayHasKey('taskOption'));
     $localOptions = array();
     $this->taskManager->execute('MyVendor\\MyPackage\\Task\\TaskGroup\\MyTask', $this->node, $this->application, $this->deployment, 'test', $localOptions, 'MyVendor\\MyPackage\\DefinedTask\\TaskGroup\\MyTask');
 }
Ejemplo n.º 2
0
 /**
  * Set up test dependencies
  *
  * This sets up a stubbed shell command service to record command executions
  * and return predefined command responses.
  */
 protected function setUp()
 {
     $this->commands = array('executed' => array());
     $commands =& $this->commands;
     $this->responses = array();
     $responses =& $this->responses;
     /** @var \TYPO3\Surf\Domain\Service\ShellCommandService|\PHPUnit_Framework_MockObject_MockObject $shellCommandService */
     $shellCommandService = $this->getMock('TYPO3\\Surf\\Domain\\Service\\ShellCommandService');
     $shellCommandService->expects($this->any())->method('execute')->will($this->returnCallback(function ($command) use(&$commands, &$responses) {
         if (is_array($command)) {
             $commands['executed'] = array_merge($commands['executed'], $command);
         } else {
             $commands['executed'][] = $command;
             if (isset($responses[$command])) {
                 return $responses[$command];
             }
         }
         return '';
     }));
     $shellCommandService->expects($this->any())->method('executeOrSimulate')->will($this->returnCallback(function ($command) use(&$commands, $responses) {
         if (is_array($command)) {
             $commands['executed'] = array_merge($commands['executed'], $command);
         } else {
             $commands['executed'][] = $command;
             if (isset($responses[$command])) {
                 return $responses[$command];
             }
         }
         return '';
     }));
     $this->task = $this->createTask();
     if ($this->task instanceof ShellCommandServiceAwareInterface) {
         $this->task->setShellCommandService($shellCommandService);
     }
     $this->node = new \TYPO3\Surf\Domain\Model\Node('TestNode');
     $this->node->setHostname('hostname');
     $this->deployment = new \TYPO3\Surf\Domain\Model\Deployment('TestDeployment');
     /** @var \Psr\Log\LoggerInterface|\PHPUnit_Framework_MockObject_MockObject $mockLogger */
     $mockLogger = $this->getMock('Psr\\Log\\LoggerInterface');
     $this->deployment->setLogger($mockLogger);
     $this->deployment->setWorkspacesBasePath('./Data/Surf');
     $this->application = new \TYPO3\Surf\Domain\Model\Application('TestApplication');
     $this->deployment->initialize();
 }