Ejemplo n.º 1
0
 protected function setUp()
 {
     $this->node = new \TYPO3\Surf\Domain\Model\Node('Test node');
     $this->application = new \TYPO3\Surf\Domain\Model\Application('Test application');
     $this->deployment = new \TYPO3\Surf\Domain\Model\Deployment('Test deployment');
     /** @var \Psr\Log\LoggerInterface $logger */
     $logger = $this->getMock('Psr\\Log\\LoggerInterface');
     $this->deployment->setLogger($logger);
     $this->task = $this->getMock(\TYPO3\Surf\Domain\Model\Task::class);
     $this->taskManager = $this->getMock(\TYPO3\Surf\Domain\Service\TaskManager::class, array('createTaskInstance'));
     $this->taskManager->expects($this->any())->method('createTaskInstance')->will($this->returnValue($this->task));
 }
 /**
  * @param string $deploymentName The deployment name
  * @param string $configurationPath Path for deployment configuration files
  * @param int $logLevel
  *
  * @return void
  *
  * @throws TaskExecutionException
  */
 protected function initializeDeployment($deploymentName, $configurationPath = null, $logLevel = LOG_INFO)
 {
     $this->deployment = $this->deploymentService->getDeployment($deploymentName, $configurationPath);
     if ($this->deployment->getLogger() === null) {
         $logger = $this->surfCommandController->createDefaultLogger($deploymentName, $logLevel);
         $this->deployment->setLogger($logger);
     }
 }
Ejemplo n.º 3
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();
 }