aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
index f394b947..c0b68d53 100644
--- a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
+++ b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
@@ -495,6 +495,41 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
495 $this->assertSame('1.1.1.1', $entry->getDomainName()); 495 $this->assertSame('1.1.1.1', $entry->getDomainName());
496 } 496 }
497 497
498 public function testWithImageAsContent()
499 {
500 $tagger = $this->getTaggerMock();
501 $tagger->expects($this->once())
502 ->method('tag');
503
504 $graby = $this->getMockBuilder('Graby\Graby')
505 ->setMethods(['fetchContent'])
506 ->disableOriginalConstructor()
507 ->getMock();
508
509 $graby->expects($this->any())
510 ->method('fetchContent')
511 ->willReturn([
512 'html' => '<p><img src="http://1.1.1.1/image.jpg" /></p>',
513 'title' => 'this is my title',
514 'url' => 'http://1.1.1.1/image.jpg',
515 'content_type' => 'image/jpeg',
516 'status' => '200',
517 'open_graph' => [],
518 ]);
519
520 $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
521 $entry = new Entry(new User());
522 $proxy->updateEntry($entry, 'http://0.0.0.0');
523
524 $this->assertEquals('http://1.1.1.1/image.jpg', $entry->getUrl());
525 $this->assertEquals('this is my title', $entry->getTitle());
526 $this->assertContains('http://1.1.1.1/image.jpg', $entry->getContent());
527 $this->assertSame('http://1.1.1.1/image.jpg', $entry->getPreviewPicture());
528 $this->assertEquals('image/jpeg', $entry->getMimetype());
529 $this->assertEquals('200', $entry->getHttpStatus());
530 $this->assertEquals('1.1.1.1', $entry->getDomainName());
531 }
532
498 private function getTaggerMock() 533 private function getTaggerMock()
499 { 534 {
500 return $this->getMockBuilder(RuleBasedTagger::class) 535 return $this->getMockBuilder(RuleBasedTagger::class)