public function testDoesNotPurgeNotExistingItem()
 {
     $purger = $this->createPurger(array('path/to/file.png'));
     $this->pathGeneratorMock->expects($this->once())->method('getVariationPath')->will($this->returnValue('path/to/file_large.png'));
     $this->ioServiceMock->expects($this->once())->method('exists')->will($this->returnValue(false));
     $this->ioServiceMock->expects($this->never())->method('loadBinaryFile');
     $this->ioServiceMock->expects($this->never())->method('deleteBinaryFile');
     $purger->purge(array('large'));
 }
 public function testRespondsToIoUri()
 {
     $uri = '/var/test/storage/images/image.png';
     $request = $this->createRequest($uri);
     $event = $this->createEvent($request);
     $binaryFile = new BinaryFile(array('mtime' => new DateTime()));
     $this->ioServiceMock->expects($this->once())->method('loadBinaryFileByUri')->with($uri)->will($this->returnValue($binaryFile));
     $this->eventListener->onKernelRequest($event);
     self::assertTrue($event->hasResponse());
     self::assertEquals(new BinaryStreamResponse($binaryFile, $this->ioServiceMock), $event->getResponse());
 }
Exemplo n.º 3
0
 public function testNewBinaryCreateStructFromUploadedFile()
 {
     $struct = new BinaryFileCreateStruct();
     $this->publishedIoServiceMock->expects($this->once())->method('newBinaryCreateStructFromUploadedFile')->with(array())->will($this->returnValue($struct));
     $this->draftIoServiceMock->expects($this->never())->method('newBinaryCreateStructFromUploadedFile');
     self::assertEquals($struct, $this->service->newBinaryCreateStructFromUploadedFile(array()));
 }