$this->assertEmpty($entry->getMimetype());
$this->assertEmpty($entry->getLanguage());
$this->assertSame(0.0, $entry->getReadingTime());
- $this->assertSame(false, $entry->getDomainName());
+ $this->assertSame(null, $entry->getDomainName());
}
public function testWithEmptyContent()
->method('tag');
$validator = $this->getValidator();
- $validator->expects($this->exactly(2))
+ $validator->expects($this->once())
->method('validate')
- ->will($this->onConsecutiveCalls(
- new ConstraintViolationList([new ConstraintViolation('oops', 'oops', [], 'oops', 'language', 'dontexist')]),
- new ConstraintViolationList()
- ));
+ ->willReturn(new ConstraintViolationList([new ConstraintViolation('oops', 'oops', [], 'oops', 'language', 'dontexist')]));
$graby = $this->getMockBuilder('Graby\Graby')
->setMethods(['fetchContent'])
$this->assertSame('1.1.1.1', $entry->getDomainName());
}
+ public function testWithImageAsContent()
+ {
+ $tagger = $this->getTaggerMock();
+ $tagger->expects($this->once())
+ ->method('tag');
+
+ $graby = $this->getMockBuilder('Graby\Graby')
+ ->setMethods(['fetchContent'])
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $graby->expects($this->any())
+ ->method('fetchContent')
+ ->willReturn([
+ 'html' => '<p><img src="http://1.1.1.1/image.jpg" /></p>',
+ 'title' => 'this is my title',
+ 'url' => 'http://1.1.1.1/image.jpg',
+ 'content_type' => 'image/jpeg',
+ 'status' => '200',
+ 'open_graph' => [],
+ ]);
+
+ $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
+ $entry = new Entry(new User());
+ $proxy->updateEntry($entry, 'http://0.0.0.0');
+
+ $this->assertSame('http://1.1.1.1/image.jpg', $entry->getUrl());
+ $this->assertSame('this is my title', $entry->getTitle());
+ $this->assertContains('http://1.1.1.1/image.jpg', $entry->getContent());
+ $this->assertSame('http://1.1.1.1/image.jpg', $entry->getPreviewPicture());
+ $this->assertSame('image/jpeg', $entry->getMimetype());
+ $this->assertSame('200', $entry->getHttpStatus());
+ $this->assertSame('1.1.1.1', $entry->getDomainName());
+ }
+
private function getTaggerMock()
{
return $this->getMockBuilder(RuleBasedTagger::class)