aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php86
-rw-r--r--tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php2
2 files changed, 86 insertions, 2 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
diff --git a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php
index 1f57939d..2a8e7c89 100644
--- a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php
@@ -121,7 +121,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
121 121
122 $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content); 122 $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content);
123 $this->assertEmpty($content->getMimetype(), 'Mimetype for http://www.framablog.org is empty'); 123 $this->assertEmpty($content->getMimetype(), 'Mimetype for http://www.framablog.org is empty');
124 $this->assertEmpty($content->getPreviewPicture(), 'Preview picture for http://www.framablog.org is empty'); 124 $this->assertSame($content->getPreviewPicture(), 'http://www.framablog.org/public/_img/framablog/wallaby_baby.jpg');
125 $this->assertEmpty($content->getLanguage(), 'Language for http://www.framablog.org is empty'); 125 $this->assertEmpty($content->getLanguage(), 'Language for http://www.framablog.org is empty');
126 126
127 $tags = $content->getTags(); 127 $tags = $content->getTags();