public function testExecute() { $this->mockGenerator()->orphanize('__construct'); $deployer = new \mock\Spy\Timeline\Spread\Deployer(); $deployer->getMockController()->getSpreads = array(); $container = new \mock\Symfony\Component\DependencyInjection\ContainerInterface(); $container->getMockController()->get = function ($v) use($deployer) { if ($v == 'spy_timeline.spread.deployer') { return $deployer; } }; $command = new TestedCommand(); $command->setContainer($container); $application = new Application(); $application->add($command); $command = $application->find('spy_timeline:spreads'); $commandTester = new CommandTester($command); $commandTester->execute(array('command' => $command->getName()), array()); $this->string($commandTester->getDisplay())->isEqualTo('There is 0 timeline spread(s) defined' . chr(10)); // one spread $spread = new \mock\Spy\TimelineBundle\Spread\SpreadInterface(); $deployer->getMockController()->getSpreads = array($spread); $commandTester = new CommandTester($command); $commandTester->execute(array('command' => $command->getName()), array()); $this->string($commandTester->getDisplay())->isEqualTo('There is 1 timeline spread(s) defined' . chr(10) . '- mock\\Spy\\TimelineBundle\\Spread\\SpreadInterface' . chr(10)); }
public function testOneTimeline() { $actionManager = new \mock\Spy\Timeline\Driver\ActionManagerInterface(); $this->mockGenerator()->orphanize('__construct'); $deployer = new \mock\Spy\Timeline\Spread\Deployer(); $action = new \mock\Spy\Timeline\Model\ActionInterface(); $action->getMockController()->getId = 1; $actionManager->getMockController()->findActionsWithStatusWantedPublished = array($action); $container = new \mock\Symfony\Component\DependencyInjection\ContainerInterface(); $container->getMockController()->get = function ($v) use($actionManager, $deployer) { if ($v == 'spy_timeline.action_manager') { return $actionManager; } elseif ($v == 'spy_timeline.spread.deployer') { return $deployer; } }; $command = new TestedCommand(); $command->setContainer($container); $application = new Application(); $application->add($command); $command = $application->find('spy_timeline:deploy'); $commandTester = new CommandTester($command); $commandTester->execute(array('command' => $command->getName()), array()); $this->mock($actionManager)->call('findActionsWithStatusWantedPublished')->once(); $this->string($commandTester->getDisplay())->isEqualTo('There is 1 action(s) to deploy' . chr(10) . 'Deploy action 1' . chr(10) . 'Done' . chr(10)); }
protected function getContainer($loopMock, $socketMock, $httpServerMock) { $this->mockGenerator->orphanize('__construct'); $this->mockGenerator->shuntParentClassCalls(); $mockContainer = new \mock\Symfony\Component\DependencyInjection\ContainerInterface(); $mockContainer->getMockController()->get = function ($serviceName) use($loopMock, $socketMock, $httpServerMock) { switch ($serviceName) { case 'm6_web_php_pm.react.loop': return $loopMock; break; case 'm6_web_php_pm.react.socket': return $socketMock; break; case 'm6_web_php_pm.react.http_server': return $httpServerMock; break; } }; return $mockContainer; }