public function testCheckTimeToLive_returnsFalseWhenNotLivingTooLong() { $this->getNativeFunctionMock(['time'])->expects($this->exactly(2))->method('time')->willReturnOnConsecutiveCalls(\time() - QManConfig::DEFAULT_MAX_TIME_ALIVE + 1, \time()); /** @var \PHPUnit_Framework_MockObject_MockObject|Beanie $beanieMock */ $beanieMock = $this->getMockBuilder(Beanie::class)->disableOriginalConstructor()->setMethods(['workers'])->getMock(); $beanieMock->expects($this->once())->method('workers')->willReturn([]); /** @var \PHPUnit_Framework_MockObject_MockObject|EventLoop $eventLoopMock */ $eventLoopMock = $this->getMockBuilder(EventLoop::class)->disableOriginalConstructor()->setMethods(['run'])->getMock(); $workerBuilder = new WorkerBuilder(); $workerBuilder->withEventLoop($eventLoopMock); /** @var \PHPUnit_Framework_MockObject_MockObject|Worker $workerStub */ $workerStub = $this->getMockBuilder(Worker::class)->setMethods(['registerWatchers', 'shutdown'])->setConstructorArgs($workerBuilder->getConstructorArguments($beanieMock))->getMock(); $workerStub->run(); $this->assertFalse($workerStub->checkTimeToLive()); }
public function testBuild_withEventLoop() { $eventLoop = new EventLoop(); $this->workerBuilder->withEventLoop($eventLoop); $this->assertContains($eventLoop, $this->workerBuilder->getConstructorArguments($this->getBeanieMock())); }