aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2017-01-10 17:42:34 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2017-01-10 17:42:36 +0100
commit3d71d40349897fe7293f7a0be86cecfe1141c61b (patch)
treebab62cb86914c10e4ff5cb2161603bc4539a9782 /tests/Wallabag
parente4ccd3effe8a5561d71d6c5f7c4bd1b23aa5a45b (diff)
downloadwallabag-3d71d40349897fe7293f7a0be86cecfe1141c61b.tar.gz
wallabag-3d71d40349897fe7293f7a0be86cecfe1141c61b.tar.zst
wallabag-3d71d40349897fe7293f7a0be86cecfe1141c61b.zip
Avoid false preview image
If the website doesn't provide an og_image, the value will be false and so it'll be saved like that in the database. We prefer to leave it as null instead of false.
Diffstat (limited to 'tests/Wallabag')
-rw-r--r--tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
index 2ca13b91..5956b502 100644
--- a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
+++ b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
@@ -161,6 +161,47 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
161 $this->assertEquals('1.1.1.1', $entry->getDomainName()); 161 $this->assertEquals('1.1.1.1', $entry->getDomainName());
162 } 162 }
163 163
164 public function testWithContentAndNoOgImage()
165 {
166 $tagger = $this->getTaggerMock();
167 $tagger->expects($this->once())
168 ->method('tag');
169
170 $graby = $this->getMockBuilder('Graby\Graby')
171 ->setMethods(['fetchContent'])
172 ->disableOriginalConstructor()
173 ->getMock();
174
175 $graby->expects($this->any())
176 ->method('fetchContent')
177 ->willReturn([
178 'html' => str_repeat('this is my content', 325),
179 'title' => 'this is my title',
180 'url' => 'http://1.1.1.1',
181 'content_type' => 'text/html',
182 'language' => 'fr',
183 'status' => '200',
184 'open_graph' => [
185 'og_title' => 'my OG title',
186 'og_description' => 'OG desc',
187 'og_image' => false,
188 ],
189 ]);
190
191 $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage);
192 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0');
193
194 $this->assertEquals('http://1.1.1.1', $entry->getUrl());
195 $this->assertEquals('this is my title', $entry->getTitle());
196 $this->assertContains('this is my content', $entry->getContent());
197 $this->assertNull($entry->getPreviewPicture());
198 $this->assertEquals('text/html', $entry->getMimetype());
199 $this->assertEquals('fr', $entry->getLanguage());
200 $this->assertEquals('200', $entry->getHttpStatus());
201 $this->assertEquals(4.0, $entry->getReadingTime());
202 $this->assertEquals('1.1.1.1', $entry->getDomainName());
203 }
204
164 public function testWithForcedContent() 205 public function testWithForcedContent()
165 { 206 {
166 $tagger = $this->getTaggerMock(); 207 $tagger = $this->getTaggerMock();