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 testRemoveWithFilters() { $originalPath = 'foo/bar/test.jpg'; $filters = array('filter1', 'filter2', 'chaud_cacao'); $this->configResolver->expects($this->never())->method('getParameter')->with('image_variations')->will($this->returnValue(array())); $this->variationPathGenerator->expects($this->exactly(count($filters)))->method('getVariationPath')->will($this->returnValueMap(array(array('foo/bar/test.jpg', 'filter1', 'foo/bar/test_filter1.jpg '), array('foo/bar/test.jpg', 'filter2', 'foo/bar/test_filter2.jpg '), array('foo/bar/test.jpg', 'chaud_cacao', 'foo/bar/test_chaud_cacao.jpg')))); $fileToDelete = 'foo/bar/test_chaud_cacao.jpg'; $this->ioService->expects($this->exactly(count($filters)))->method('exists')->will($this->returnValueMap(array(array('foo/bar/test_filter1.jpg', false), array('foo/bar/test_filter2.jpg', false), array($fileToDelete, true)))); $binaryFile = new BinaryFile(array('id' => $fileToDelete)); $this->ioService->expects($this->once())->method('loadBinaryFile')->with($fileToDelete)->will($this->returnValue($binaryFile)); $this->ioService->expects($this->once())->method('deleteBinaryFile')->with($binaryFile); $this->imageResolver->remove(array($originalPath), $filters); }