public function testPopQueuedJobEmptyAfter()
 {
     $this->reader->expects($this->once())->method('read')->willReturn('{"jobs": [{"name": "job A", "params" : []}]}');
     $job = $this->getMockForAbstractClass('Magento\\Update\\Queue\\AbstractJob', [], '', false);
     $this->jobFactory->expects($this->once())->method('create')->with('job A', [])->willReturn($job);
     $this->writer->expects($this->once())->method('write')->with('');
     $this->assertEquals($job, $this->queue->popQueuedJob());
 }
 public function testPopQueueJob()
 {
     $queueJson = file_get_contents(__DIR__ . '/_files/update_queue_valid.json');
     $this->queueReaderMock->expects($this->once())->method('read')->willReturn($queueJson);
     $jobMock = $this->getMockBuilder('Magento\\Update\\Queue\\AbstractJob')->disableOriginalConstructor()->getMockForAbstractClass();
     $this->jobFactoryMock->expects($this->exactly(4))->method('create')->willReturn($jobMock);
     /** Ensure that arguments are passed correctly to the job factory */
     $this->jobFactoryMock->expects($this->at(0))->method('create')->with('backup', []);
     $this->queueReaderMock->expects($this->once())->method('clearQueue');
     $jobs = $this->queue->popQueuedJobs();
     $this->assertCount(4, $jobs);
     $this->assertInternalType('array', $jobs);
     $this->assertSame($jobMock, $jobs[3]);
 }