Exemplo n.º 1
0
 /**
  * @param Server $server
  */
 public function __construct(Server $server)
 {
     $this->server = $server;
     $this->tubeStatus = new TubeStatus();
     $this->commandFactory = CommandFactory::instance();
     $this->jobFactory = JobFactory::instance();
 }
Exemplo n.º 2
0
 /**
  * @param string $tubeName
  * @param Server $server
  * @param JobFactory|null $jobFactory
  */
 public function __construct($tubeName, Server $server, JobFactory $jobFactory = null)
 {
     $this->tubeStatus = new TubeStatus();
     $this->tubeStatus->setCurrentTube($tubeName);
     $this->server = $server;
     $this->jobFactory = $jobFactory ?: JobFactory::instance();
     $this->commandFactory = CommandFactory::instance();
 }
Exemplo n.º 3
0
 /**
  * @param int $id
  * @param mixed $data
  * @param Server $server
  * @param null|string $state
  */
 public function __construct($id, $data, Server $server, $state = self::STATE_UNKNOWN)
 {
     $this->id = (int) $id;
     $this->data = $data;
     $this->server = $server;
     $this->state = $state;
     $this->commandFactory = CommandFactory::instance();
 }
Exemplo n.º 4
0
 public function testCreateFromCommand_createsJob()
 {
     $serverMock = $this->getServerMock(['dispatchCommand']);
     $command = CommandFactory::instance()->create(CommandInterface::COMMAND_PEEK, [self::TEST_ID]);
     $response = new Response(Response::RESPONSE_FOUND, ['id' => self::TEST_ID, 'data' => self::TEST_DATA], $serverMock);
     $serverMock->expects($this->once())->method('dispatchCommand')->with($this->callback(function (CommandInterface $command) {
         return $command->getCommandLine() == sprintf('%s %s', CommandInterface::COMMAND_PEEK, self::TEST_ID);
     }))->willReturn($this->oath($response));
     $JobFactory = new JobFactory();
     $job = $JobFactory->createFromCommand($command, $serverMock)->invoke();
     $this->assertEquals(Job::STATE_UNKNOWN, $job->getState());
     $this->assertEquals(self::TEST_ID, $job->getId());
     $this->assertEquals(self::TEST_DATA, $job->getData());
 }
Exemplo n.º 5
0
 public function transformCommandsProvider()
 {
     $commandFactory = CommandFactory::instance();
     return ['identical' => [Beanie::DEFAULT_TUBE, [Beanie::DEFAULT_TUBE], Beanie::DEFAULT_TUBE, [Beanie::DEFAULT_TUBE], TubeStatus::TRANSFORM_BOTH, []], 'overlapping-watch' => [Beanie::DEFAULT_TUBE, ['1only1', '1only2', 'shared1', 'shared2', '1only3'], Beanie::DEFAULT_TUBE, ['2only1', 'shared1', 'shared2', '2only2'], TubeStatus::TRANSFORM_BOTH, [$commandFactory->create(CommandInterface::COMMAND_IGNORE, ['1only1']), $commandFactory->create(CommandInterface::COMMAND_IGNORE, ['1only2']), $commandFactory->create(CommandInterface::COMMAND_IGNORE, ['1only3']), $commandFactory->create(CommandInterface::COMMAND_WATCH, ['2only1']), $commandFactory->create(CommandInterface::COMMAND_WATCH, ['2only2'])]], 'only-additions' => [Beanie::DEFAULT_TUBE, ['shared1', 'shared2'], Beanie::DEFAULT_TUBE, ['2only1', 'shared1', 'shared2', '2only2'], TubeStatus::TRANSFORM_BOTH, [$commandFactory->create(CommandInterface::COMMAND_WATCH, ['2only1']), $commandFactory->create(CommandInterface::COMMAND_WATCH, ['2only2'])]], 'only-removals' => [Beanie::DEFAULT_TUBE, ['1only1', '1only2', 'shared1', 'shared2', '1only3'], Beanie::DEFAULT_TUBE, ['shared1', 'shared2'], TubeStatus::TRANSFORM_BOTH, [$commandFactory->create(CommandInterface::COMMAND_IGNORE, ['1only1']), $commandFactory->create(CommandInterface::COMMAND_IGNORE, ['1only2']), $commandFactory->create(CommandInterface::COMMAND_IGNORE, ['1only3'])]], 'different-use' => [self::TEST_TUBE, [Beanie::DEFAULT_TUBE], Beanie::DEFAULT_TUBE, [Beanie::DEFAULT_TUBE], TubeStatus::TRANSFORM_BOTH, [$commandFactory->create(CommandInterface::COMMAND_USE, [Beanie::DEFAULT_TUBE])]], 'different-use-ignored' => [self::TEST_TUBE, [Beanie::DEFAULT_TUBE], Beanie::DEFAULT_TUBE, [Beanie::DEFAULT_TUBE], TubeStatus::TRANSFORM_WATCHED, []], 'different-watch-ignored' => [Beanie::DEFAULT_TUBE, ['shared1', 'shared2'], Beanie::DEFAULT_TUBE, ['2only1', 'shared1', 'shared2', '2only2'], TubeStatus::TRANSFORM_USE, []], 'all-different' => [self::TEST_TUBE, ['shared1', 'shared2'], Beanie::DEFAULT_TUBE, ['2only1', 'shared1', 'shared2', '2only2'], TubeStatus::TRANSFORM_BOTH, [$commandFactory->create(CommandInterface::COMMAND_USE, [Beanie::DEFAULT_TUBE]), $commandFactory->create(CommandInterface::COMMAND_WATCH, ['2only1']), $commandFactory->create(CommandInterface::COMMAND_WATCH, ['2only2'])]], 'all-different-only-use' => [self::TEST_TUBE, ['shared1', 'shared2'], Beanie::DEFAULT_TUBE, ['2only1', 'shared1', 'shared2', '2only2'], TubeStatus::TRANSFORM_USE, [$commandFactory->create(CommandInterface::COMMAND_USE, [Beanie::DEFAULT_TUBE])]], 'all-different-only-watched' => [self::TEST_TUBE, ['shared1', 'shared2'], Beanie::DEFAULT_TUBE, ['2only1', 'shared1', 'shared2', '2only2'], TubeStatus::TRANSFORM_WATCHED, [$commandFactory->create(CommandInterface::COMMAND_WATCH, ['2only1']), $commandFactory->create(CommandInterface::COMMAND_WATCH, ['2only2'])]]];
 }
Exemplo n.º 6
0
 public function testInstance_returnsSame()
 {
     CommandFactory::unsetInstance();
     $firstInstance = CommandFactory::instance();
     $this->assertSame($firstInstance, CommandFactory::instance());
 }
Exemplo n.º 7
0
 /**
  * @param Pool $pool
  */
 public function __construct(Pool $pool)
 {
     $this->pool = $pool;
     $this->tubeStatus = new TubeStatus();
     $this->commandFactory = CommandFactory::instance();
 }
Exemplo n.º 8
0
 public function __construct()
 {
     $this->commandFactory = CommandFactory::instance();
 }
Exemplo n.º 9
0
 public function setUp()
 {
     $this->commandFactory = CommandFactory::instance();
 }