loadImages() public method

Load images
public loadImages ( Imbo\EventManager\EventInterface $event )
$event Imbo\EventManager\EventInterface An event instance
Beispiel #1
0
 /**
  * @covers Imbo\EventListener\DatabaseOperations::loadImages
  */
 public function testCanLoadImages()
 {
     $images = [['added' => new DateTime(), 'updated' => new DateTime(), 'size' => 123, 'width' => 50, 'height' => 50, 'imageIdentifier' => 'identifier1', 'checksum' => 'checksum1', 'originalChecksum' => 'checksum1', 'mime' => 'image/png', 'extension' => 'png', 'user' => $this->user, 'metadata' => []], ['added' => new DateTime(), 'updated' => new DateTime(), 'size' => 456, 'width' => 60, 'height' => 60, 'imageIdentifier' => 'identifier2', 'checksum' => 'checksum2', 'originalChecksum' => 'checksum2', 'mime' => 'image/png', 'extension' => 'png', 'user' => $this->user, 'metadata' => []], ['added' => new DateTime(), 'updated' => new DateTime(), 'size' => 789, 'width' => 70, 'height' => 70, 'imageIdentifier' => 'identifier3', 'checksum' => 'checksum3', 'originalChecksum' => 'checksum3', 'mime' => 'image/png', 'extension' => 'png', 'user' => $this->user, 'metadata' => []]];
     $date = new DateTime();
     $query = $this->getMock('Symfony\\Component\\HttpFoundation\\ParameterBag');
     $query->expects($this->at(0))->method('has')->with('page')->will($this->returnValue(true));
     $query->expects($this->at(1))->method('get')->with('page')->will($this->returnValue(1));
     $query->expects($this->at(2))->method('has')->with('limit')->will($this->returnValue(true));
     $query->expects($this->at(3))->method('get')->with('limit')->will($this->returnValue(5));
     $query->expects($this->at(4))->method('has')->with('metadata')->will($this->returnValue(true));
     $query->expects($this->at(5))->method('get')->with('metadata')->will($this->returnValue(true));
     $query->expects($this->at(6))->method('has')->with('from')->will($this->returnValue(true));
     $query->expects($this->at(7))->method('get')->with('from')->will($this->returnValue(1355156488));
     $query->expects($this->at(8))->method('has')->with('to')->will($this->returnValue(true));
     $query->expects($this->at(9))->method('get')->with('to')->will($this->returnValue(1355176488));
     $query->expects($this->at(10))->method('has')->with('sort')->will($this->returnValue(true));
     $query->expects($this->at(11))->method('get')->with('sort')->will($this->returnValue(['size:desc']));
     $query->expects($this->at(12))->method('has')->with('ids')->will($this->returnValue(true));
     $query->expects($this->at(13))->method('get')->with('ids')->will($this->returnValue(['identifier1', 'identifier2', 'identifier3']));
     $query->expects($this->at(14))->method('has')->with('checksums')->will($this->returnValue(true));
     $query->expects($this->at(15))->method('get')->with('checksums')->will($this->returnValue(['checksum1', 'checksum2', 'checksum3']));
     $query->expects($this->at(16))->method('has')->with('originalChecksums')->will($this->returnValue(true));
     $query->expects($this->at(17))->method('get')->with('originalChecksums')->will($this->returnValue(['checksum1', 'checksum2', 'checksum3']));
     $this->request->query = $query;
     $imagesQuery = $this->getMock('Imbo\\Resource\\Images\\Query');
     $this->listener->setImagesQuery($imagesQuery);
     $this->database->expects($this->once())->method('getImages')->with([$this->user], $imagesQuery)->will($this->returnValue($images));
     $this->database->expects($this->once())->method('getLastModified')->with([$this->user])->will($this->returnValue($date));
     $this->response->expects($this->once())->method('setModel')->with($this->isInstanceOf('Imbo\\Model\\Images'))->will($this->returnSelf());
     $this->response->expects($this->once())->method('setLastModified')->with($date);
     $this->listener->loadImages($this->event);
 }