Пример #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);
 }
Пример #2
0
 /**
  * Helper function for the bound property
  *
  * @param $formObject
  */
 protected function stubVariableContainer($formObject)
 {
     $this->viewHelperVariableContainer->exists(Argument::cetera())->willReturn(true);
     $this->viewHelperVariableContainer->get(Argument::any(), 'formObjectName')->willReturn('objectName');
     $this->viewHelperVariableContainer->get(Argument::any(), 'fieldNamePrefix')->willReturn('fieldPrefix');
     $this->viewHelperVariableContainer->get(Argument::any(), 'formFieldNames')->willReturn([]);
     $this->viewHelperVariableContainer->get(Argument::any(), 'formObject')->willReturn($formObject);
     $this->viewHelperVariableContainer->get(Argument::any(), 'renderedHiddenFields')->willReturn([]);
     $this->viewHelperVariableContainer->addOrUpdate(Argument::cetera())->willReturn(null);
 }
Пример #3
0
 protected function setUp()
 {
     $typeName = Cache::TYPE_NAME;
     $this->type = $this->prophesize('\\Elastica\\Type');
     $this->type->request(Argument::any(), Argument::cetera())->willReturn(true);
     $this->type->getName()->willReturn($typeName);
     $this->index = $this->prophesize('\\Elastica\\Index');
     $this->index->getType($typeName)->willReturn($this->type->reveal());
     $this->index->exists()->willReturn(true);
     $nsDoc = new Document('DoctrineNamespaceCacheKey[]', [Cache::VALUE_FIELD => serialize($this->namespaceId)]);
     $this->type->getIndex()->willReturn($this->index->reveal());
     $this->type->getDocument("DoctrineNamespaceCacheKey[]")->willReturn($nsDoc);
     $this->client = $this->prophesize('\\Elastica\\Client');
     $this->client->getIndex($this->indexName)->willReturn($this->index->reveal());
     $this->cache = new Cache($this->client->reveal(), ['index' => $this->indexName]);
 }