aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2017-06-30 17:04:40 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2017-07-03 13:45:04 +0200
commitd0ec2ddd2354e39badd947c2214f47193784b1c7 (patch)
tree1684fbea993e7aa0b9343f399e30ed09e927b5bd /tests/Wallabag
parenta05b61159e147776f63baee731b5026796e5f7ae (diff)
downloadwallabag-d0ec2ddd2354e39badd947c2214f47193784b1c7.tar.gz
wallabag-d0ec2ddd2354e39badd947c2214f47193784b1c7.tar.zst
wallabag-d0ec2ddd2354e39badd947c2214f47193784b1c7.zip
Fix validateAndSetPreviewPicture
Which wasn't covered by a test!
Diffstat (limited to 'tests/Wallabag')
-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)