aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/CoreBundle
diff options
context:
space:
mode:
authorKevin Decherf <kevin@kdecherf.com>2019-05-26 17:47:44 +0200
committerGitHub <noreply@github.com>2019-05-26 17:47:44 +0200
commit5c0701ba41fd64ba471addb4a84af062277ab559 (patch)
tree230c6bf7455bd5a8a7f3cf487bc08efdb9b7e16e /tests/Wallabag/CoreBundle
parentcc9731bf2bc59c4a3802ac546ac3f76afb4aa5d6 (diff)
parentd99e6423f4bd54595a8a805dd1efd0bd94e8bb09 (diff)
downloadwallabag-5c0701ba41fd64ba471addb4a84af062277ab559.tar.gz
wallabag-5c0701ba41fd64ba471addb4a84af062277ab559.tar.zst
wallabag-5c0701ba41fd64ba471addb4a84af062277ab559.zip
Merge pull request #3965 from nicofrand/previewPic
Preview picture: use the 1st pic retrieved if no og:image set
Diffstat (limited to 'tests/Wallabag/CoreBundle')
-rw-r--r--tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php86
1 files changed, 85 insertions, 1 deletions
diff --git a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
index 508adb1b..c7caac1d 100644
--- a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
+++ b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
@@ -214,6 +214,90 @@ class ContentProxyTest extends TestCase
214 $this->assertSame('1.1.1.1', $entry->getDomainName()); 214 $this->assertSame('1.1.1.1', $entry->getDomainName());
215 } 215 }
216 216
217 public function testWithContentAndContentImage()
218 {
219 $tagger = $this->getTaggerMock();
220 $tagger->expects($this->once())
221 ->method('tag');
222
223 $graby = $this->getMockBuilder('Graby\Graby')
224 ->setMethods(['fetchContent'])
225 ->disableOriginalConstructor()
226 ->getMock();
227
228 $graby->expects($this->any())
229 ->method('fetchContent')
230 ->willReturn([
231 'html' => "<h1>Test</h1><p><img src='http://3.3.3.3/cover.jpg'/></p>",
232 'title' => 'this is my title',
233 'url' => 'http://1.1.1.1',
234 'content_type' => 'text/html',
235 'language' => 'fr',
236 'status' => '200',
237 'open_graph' => [
238 'og_title' => 'my OG title',
239 'og_description' => 'OG desc',
240 'og_image' => null,
241 ],
242 ]);
243
244 $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
245 $entry = new Entry(new User());
246 $proxy->updateEntry($entry, 'http://0.0.0.0');
247
248 $this->assertSame('http://1.1.1.1', $entry->getUrl());
249 $this->assertSame('this is my title', $entry->getTitle());
250 $this->assertSame("<h1>Test</h1><p><img src='http://3.3.3.3/cover.jpg'/></p>", $entry->getContent());
251 $this->assertSame('http://3.3.3.3/cover.jpg', $entry->getPreviewPicture());
252 $this->assertSame('text/html', $entry->getMimetype());
253 $this->assertSame('fr', $entry->getLanguage());
254 $this->assertSame('200', $entry->getHttpStatus());
255 $this->assertSame(0.0, $entry->getReadingTime());
256 $this->assertSame('1.1.1.1', $entry->getDomainName());
257 }
258
259 public function testWithContentImageAndOgImage()
260 {
261 $tagger = $this->getTaggerMock();
262 $tagger->expects($this->once())
263 ->method('tag');
264
265 $graby = $this->getMockBuilder('Graby\Graby')
266 ->setMethods(['fetchContent'])
267 ->disableOriginalConstructor()
268 ->getMock();
269
270 $graby->expects($this->any())
271 ->method('fetchContent')
272 ->willReturn([
273 'html' => "<h1>Test</h1><p><img src='http://3.3.3.3/nevermind.jpg'/></p>",
274 'title' => 'this is my title',
275 'url' => 'http://1.1.1.1',
276 'content_type' => 'text/html',
277 'language' => 'fr',
278 'status' => '200',
279 'open_graph' => [
280 'og_title' => 'my OG title',
281 'og_description' => 'OG desc',
282 'og_image' => 'http://3.3.3.3/cover.jpg',
283 ],
284 ]);
285
286 $proxy = new ContentProxy($graby, $tagger, $this->getValidator(), $this->getLogger(), $this->fetchingErrorMessage);
287 $entry = new Entry(new User());
288 $proxy->updateEntry($entry, 'http://0.0.0.0');
289
290 $this->assertSame('http://1.1.1.1', $entry->getUrl());
291 $this->assertSame('this is my title', $entry->getTitle());
292 $this->assertSame("<h1>Test</h1><p><img src='http://3.3.3.3/nevermind.jpg'/></p>", $entry->getContent());
293 $this->assertSame('http://3.3.3.3/cover.jpg', $entry->getPreviewPicture());
294 $this->assertSame('text/html', $entry->getMimetype());
295 $this->assertSame('fr', $entry->getLanguage());
296 $this->assertSame('200', $entry->getHttpStatus());
297 $this->assertSame(0.0, $entry->getReadingTime());
298 $this->assertSame('1.1.1.1', $entry->getDomainName());
299 }
300
217 public function testWithContentAndBadLanguage() 301 public function testWithContentAndBadLanguage()
218 { 302 {
219 $tagger = $this->getTaggerMock(); 303 $tagger = $this->getTaggerMock();
@@ -415,7 +499,7 @@ class ContentProxyTest extends TestCase
415 499
416 $records = $handler->getRecords(); 500 $records = $handler->getRecords();
417 501
418 $this->assertCount(1, $records); 502 $this->assertCount(3, $records);
419 $this->assertContains('Error while defining date', $records[0]['message']); 503 $this->assertContains('Error while defining date', $records[0]['message']);
420 } 504 }
421 505