public function testTransformTubeStatusTo_respectsMode() { $tubeStatus = new TubeStatus(); $tubeStatus->setCurrentTube(self::TEST_TUBE); $tube = new Tube(Beanie::DEFAULT_TUBE, $this->getServerMock()); $tube->transformTubeStatusTo($tubeStatus, TubeStatus::TRANSFORM_WATCHED); $this->assertEquals(Beanie::DEFAULT_TUBE, $tube->getTubeStatus()->getCurrentTube()); $this->assertEquals([Beanie::DEFAULT_TUBE], $tube->getTubeStatus()->getWatchedTubes()); $this->assertNotSame($tubeStatus, $tube->getTubeStatus()); }
public function testTransformTubeStatusTo_updatesTubeStatus() { $testTube = new TubeStatus(); $testTube->setCurrentTube('TEST'); $testTube->addWatchedTube('TEST'); /** @var \PHPUnit_Framework_MockObject_MockObject|Pool $poolMock */ $poolMock = $this->getMockBuilder(Pool::class)->disableOriginalConstructor()->setMethods(['dispatchCommand'])->getMock(); $poolMock->expects($this->never())->method('dispatchCommand'); $producer = new Producer($poolMock); $producer->transformTubeStatusTo($testTube, TubeStatus::TRANSFORM_BOTH); $this->assertEquals($testTube->getCurrentTube(), $producer->getTubeStatus()->getCurrentTube()); $this->assertEquals($testTube->getWatchedTubes(), $producer->getTubeStatus()->getWatchedTubes()); }
/** * @param TubeStatus $goal * @param int $mode * @return $this */ public function transformTubeStatusTo(TubeStatus $goal, $mode = TubeStatus::TRANSFORM_BOTH) { foreach ($this->tubeStatus->transformTo($goal, $mode) as $transformCommand) { $this->dispatchCommand($transformCommand)->invoke(); } return $this; }
public function testRemoveWatchTube_fromMultiple() { $tubeStatus = new TubeStatus(); $tubeStatus->addWatchedTube('tube-1'); $tubeStatus->addWatchedTube('tube-2'); $tubeStatus->addWatchedTube('tube-3'); $tubeStatus->removeWatchedTube('tube-2'); $this->assertEquals([Beanie::DEFAULT_TUBE, 'tube-1', 'tube-3'], $tubeStatus->getWatchedTubes()); }
/** * @return string */ public function getName() { return $this->tubeStatus->getCurrentTube(); }
public function testTransformTubeStatusTo_willDispatchCommand() { $tubeStatus = new TubeStatus(); $tubeStatus->setCurrentTube('test')->addWatchedTube('test'); /** @var \PHPUnit_Framework_MockObject_MockObject|Server $serverStub */ $serverStub = $this->getMockBuilder(Server::class)->setMethods(['dispatchCommand'])->getMock(); $serverStub->expects($this->exactly(2))->method('dispatchCommand')->willReturn($this->getMockBuilder(ResponseOath::class)->disableOriginalConstructor()->setMethods(['invoke'])->getMock()); $serverStub->transformTubeStatusTo($tubeStatus); }
/** * @param TubeStatus $goal * @param int $mode * @return \Beanie\Command\CommandInterface[] */ public function calculateTransformationTo(TubeStatus $goal, $mode = self::TRANSFORM_BOTH) { $commands = []; if ($mode & self::TRANSFORM_WATCHED) { $commands = $this->calculateTransformWatched($goal->getWatchedTubes()); } if ($mode & self::TRANSFORM_USE && $goal->getCurrentTube() !== $this->currentTube) { $commands[] = $this->commandFactory->create(CommandInterface::COMMAND_USE, [$goal->getCurrentTube()]); } return $commands; }