/** * Should pre-process and transfer an image. */ public function testHandle() { $filename = '/tmp/' . uniqid(); file_put_contents($filename, ''); $this->image->expects($this->atLeastOnce())->method('storageLocation')->willReturn($filename); $preProcessed = $this->makeMock(ImagickContract::class); $this->imagePreProcessor->expects($this->atLeastOnce())->method('preProcess')->with($this->image)->willReturn(new ImagickCollection([$preProcessed])); $this->config->expects($this->atLeastOnce())->method('get')->willReturn('foobar_endpoint'); $fileContent = 'foo bar'; $preProcessed->expects($this->atLeastOnce())->method('getImageBlob')->willReturn($fileContent); $this->filesystem->expects($this->atLeastOnce())->method('put')->with($this->isType('string'), $fileContent, $this->isType('array')); $this->newImageListener->handle($this->event); }
public function testDeleteDirectory() { $this->filesystem->expects($this->once())->method('deleteDir')->with('some/path'); $this->handler->deleteDirectory('some/path'); }
public function testGetMimeType() { $this->filesystem->expects($this->once())->method('getMimeType')->with('file.txt')->will($this->returnValue('text/plain')); self::assertEquals('text/plain', $this->handler->getMimeType('file.txt')); }
/** * @expectedException \eZ\Publish\Core\IO\Exception\BinaryFileNotFoundException */ public function testGetResourceNotFound() { $this->filesystem->expects($this->once())->method('readStream')->with('prefix/my/file.png')->will($this->throwException(new FileNotFoundException('prefix/my/file.png'))); $this->handler->getResource('prefix/my/file.png'); }