public function testAddJobs() { $queue = ['jobs' => []]; $this->reader->expects($this->at(0))->method('read')->willReturn(''); $queue['jobs'][] = ['name' => 'job A', 'params' => []]; $this->writer->expects($this->at(0))->method('write')->with(json_encode($queue, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); $this->reader->expects($this->at(1))->method('read')->willReturn(json_encode($queue, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); $queue['jobs'][] = ['name' => 'job B', 'params' => []]; $this->writer->expects($this->at(1))->method('write')->with(json_encode($queue, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); $this->queue->addJobs([['name' => 'job A', 'params' => []], ['name' => 'job B', 'params' => []]]); }
/** * @dataProvider popQueueJobInvalidQueueFormatProvider * @param string $queueJson * @param string $expectedExceptionMessage */ public function testPopQueueJobInvalidQueueFormat($queueJson, $expectedExceptionMessage) { $this->setExpectedException('\\RuntimeException', $expectedExceptionMessage); $this->queueReaderMock->expects($this->once())->method('read')->willReturn($queueJson); $this->queue->popQueuedJobs(); }