/**
  * {@inheritdoc}
  */
 public function submitPrintJob(Printer $printer, FileInterface $file)
 {
     $title = 'file-' . $file->getId();
     $parameters = ['printerid' => $printer->getVendorId(), 'title' => $title, 'ticket' => '{ "version": "1.0", "print": {} }', 'content' => new PostFile('content', fopen($file->getLocalPath(), 'r'))];
     $response = $this->postRequest('submit', $parameters);
     $setAt = new \DateTime();
     $setAt->setTimestamp(substr($response['job']['createTime'], 0, 10));
     $job = new Job();
     $job->setFile($file)->setJobId($response['job']['id'])->setMetadata($response['job'])->setPrinter($printer)->setSentAt($setAt)->setStatus($response['job']['status'])->setTitle($response['job']['title']);
     return $job;
 }
 public function testSubmitJob()
 {
     $googleClient = $this->getMock('Google_Client');
     $service = $this->getMock('PrintService\\Service\\GoogleCloudPrintService', ['postRequest'], [$googleClient]);
     $service->expects($this->once())->method('postRequest')->will($this->returnValue($this->printJobData));
     $printer = new Printer();
     $printer->setVendorId('9c11268c-4dd8-c8f4-e63e-3a5f26f0fc8f');
     $exampleFile = realpath(__DIR__ . '/../fixtures/example.pdf');
     $file = new File();
     $file->setLocalPath($exampleFile);
     $rp = new \ReflectionProperty($file, 'id');
     $rp->setAccessible(true);
     $rp->setValue($file, 853);
     $rp->setAccessible(false);
     $job = $service->submitPrintJob($printer, $file);
     $this->assertSame('4f616ca1-6979-e090-e3a3-705ec5db4d21', $job->getJobId());
     $this->assertSame('file-853', $job->getTitle());
     $this->assertSame($printer, $job->getPrinter());
     $this->assertSame($file, $job->getFile());
     $this->assertSame('QUEUED', $job->getStatus());
     $this->assertEquals(new \DateTime('2014-04-08 03:58:13'), $job->getSentAt());
     $this->assertSame($this->printJobData['job'], $job->getMetadata());
 }