Example #1
0
 /**
  * @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->filesystem->exists(sprintf('dir/preview_%s.png', urlencode($url)))->willReturn(false)->shouldBeCalledTimes(1);
     $this->image->saveAs($expectedPath)->shouldBeCalledTimes(1);
     $this->image->getError()->willReturn('Error!!')->shouldBeCalledTimes(1);
     $this->generator->generatePreview($url);
 }
 /**
  * @covers ::getError
  */
 public function testGetError()
 {
     $element = ['#foo' => 'bar'];
     $message = 'bar';
     $this->decoratedFormState->getError($element)->willReturn($message)->shouldBeCalled();
     $this->assertSame($message, $this->formStateDecoratorBase->getError($element));
 }