mirror of
https://github.com/shlinkio/shlink.git
synced 2025-02-25 18:45:27 -06:00
Managed error while generating URL previews by throwing an exception
This commit is contained in:
@@ -52,9 +52,27 @@ class PreviewGeneratorTest extends TestCase
|
||||
|
||||
$this->image->setPage($url)->shouldBeCalledTimes(1);
|
||||
$this->image->saveAs($expectedPath)->shouldBeCalledTimes(1);
|
||||
$this->image->getError()->willReturn('')->shouldBeCalledTimes(1);
|
||||
|
||||
$this->assertFalse($this->cache->contains($cacheId));
|
||||
$this->assertEquals($expectedPath, $this->generator->generatePreview($url));
|
||||
$this->assertTrue($this->cache->contains($cacheId));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @expectedException \Shlinkio\Shlink\Common\Exception\PreviewGenerationException
|
||||
*/
|
||||
public function errorWhileGeneratingPreviewThrowsException()
|
||||
{
|
||||
$url = 'http://foo.com';
|
||||
$cacheId = sprintf('preview_%s.png', urlencode($url));
|
||||
$expectedPath = 'dir/' . $cacheId;
|
||||
|
||||
$this->image->setPage($url)->shouldBeCalledTimes(1);
|
||||
$this->image->saveAs($expectedPath)->shouldBeCalledTimes(1);
|
||||
$this->image->getError()->willReturn('Error!!')->shouldBeCalledTimes(1);
|
||||
|
||||
$this->generator->generatePreview($url);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user