/** * @test */ public function executes() { $filelib = new FileLibrary(new MemoryStorageAdapter(), new MemoryBackendAdapter()); $this->assertFileNotExists(ROOT_TESTS . '/data/temp/ping.txt'); $strategy = new PekkisQueueExecutionStrategy($this->queue); $strategy->attachTo($filelib); $strategy->execute('\\touchMyTrallala', [6]); $this->assertFileNotExists(ROOT_TESTS . '/data/temp/ping.txt'); $processor = new Processor(new EventDispatchingQueue($strategy->getQueue(), $filelib->getEventDispatcher())); $processor->registerHandler(new FilelibMessageHandler()); $result = $processor->process(); $this->assertTrue($result); $this->assertFileExists(ROOT_TESTS . '/data/temp/ping.txt'); }
/** * @test * @group loso */ public function handlesDequeueError() { $ed = $this->prophesize(EventDispatcherInterface::class); $queue = $this->prophesize(EventDispatchingQueue::class); $e = new RuntimeException('Xoo'); $e->setContext(['tussenhofer', 'identificado']); $queue->getEventDispatcher()->willReturn($ed->reveal()); $queue->dequeue()->shouldBeCalled()->willThrow($e); $processor = new Processor($queue->reveal()); $this->assertEquals(0, $this->counter); $processor->process(function (Processor $p, RuntimeException $e) use($processor) { $this->assertSame($processor, $p); $this->assertEquals(['tussenhofer', 'identificado'], $e->getContext()); $this->counter += 1; }); $this->assertEquals(1, $this->counter); }