aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Wallabag')
-rw-r--r--tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php32
-rw-r--r--tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php8
2 files changed, 21 insertions, 19 deletions
diff --git a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
index 33b3ff2a..2ca13b91 100644
--- a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
+++ b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
@@ -10,6 +10,8 @@ use Wallabag\UserBundle\Entity\User;
10 10
11class ContentProxyTest extends \PHPUnit_Framework_TestCase 11class ContentProxyTest extends \PHPUnit_Framework_TestCase
12{ 12{
13 private $fetchingErrorMessage = 'wallabag can\'t retrieve contents for this article. Please <a href="http://doc.wallabag.org/en/master/user/errors_during_fetching.html#how-can-i-help-to-fix-that">troubleshoot this issue</a>.';
14
13 public function testWithBadUrl() 15 public function testWithBadUrl()
14 { 16 {
15 $tagger = $this->getTaggerMock(); 17 $tagger = $this->getTaggerMock();
@@ -31,12 +33,12 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
31 'language' => '', 33 'language' => '',
32 ]); 34 ]);
33 35
34 $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger()); 36 $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage);
35 $entry = $proxy->updateEntry(new Entry(new User()), 'http://user@:80'); 37 $entry = $proxy->updateEntry(new Entry(new User()), 'http://user@:80');
36 38
37 $this->assertEquals('http://user@:80', $entry->getUrl()); 39 $this->assertEquals('http://user@:80', $entry->getUrl());
38 $this->assertEmpty($entry->getTitle()); 40 $this->assertEmpty($entry->getTitle());
39 $this->assertEquals('<p>Unable to retrieve readable content.</p>', $entry->getContent()); 41 $this->assertEquals($this->fetchingErrorMessage, $entry->getContent());
40 $this->assertEmpty($entry->getPreviewPicture()); 42 $this->assertEmpty($entry->getPreviewPicture());
41 $this->assertEmpty($entry->getMimetype()); 43 $this->assertEmpty($entry->getMimetype());
42 $this->assertEmpty($entry->getLanguage()); 44 $this->assertEmpty($entry->getLanguage());
@@ -65,12 +67,12 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
65 'language' => '', 67 'language' => '',
66 ]); 68 ]);
67 69
68 $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger()); 70 $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage);
69 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); 71 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0');
70 72
71 $this->assertEquals('http://0.0.0.0', $entry->getUrl()); 73 $this->assertEquals('http://0.0.0.0', $entry->getUrl());
72 $this->assertEmpty($entry->getTitle()); 74 $this->assertEmpty($entry->getTitle());
73 $this->assertEquals('<p>Unable to retrieve readable content.</p>', $entry->getContent()); 75 $this->assertEquals($this->fetchingErrorMessage, $entry->getContent());
74 $this->assertEmpty($entry->getPreviewPicture()); 76 $this->assertEmpty($entry->getPreviewPicture());
75 $this->assertEmpty($entry->getMimetype()); 77 $this->assertEmpty($entry->getMimetype());
76 $this->assertEmpty($entry->getLanguage()); 78 $this->assertEmpty($entry->getLanguage());
@@ -104,12 +106,12 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
104 ], 106 ],
105 ]); 107 ]);
106 108
107 $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger()); 109 $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage);
108 $entry = $proxy->updateEntry(new Entry(new User()), 'http://domain.io'); 110 $entry = $proxy->updateEntry(new Entry(new User()), 'http://domain.io');
109 111
110 $this->assertEquals('http://domain.io', $entry->getUrl()); 112 $this->assertEquals('http://domain.io', $entry->getUrl());
111 $this->assertEquals('my title', $entry->getTitle()); 113 $this->assertEquals('my title', $entry->getTitle());
112 $this->assertEquals('<p>Unable to retrieve readable content.</p><p><i>But we found a short description: </i></p>desc', $entry->getContent()); 114 $this->assertEquals($this->fetchingErrorMessage . '<p><i>But we found a short description: </i></p>desc', $entry->getContent());
113 $this->assertEmpty($entry->getPreviewPicture()); 115 $this->assertEmpty($entry->getPreviewPicture());
114 $this->assertEmpty($entry->getLanguage()); 116 $this->assertEmpty($entry->getLanguage());
115 $this->assertEmpty($entry->getHttpStatus()); 117 $this->assertEmpty($entry->getHttpStatus());
@@ -145,7 +147,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
145 ], 147 ],
146 ]); 148 ]);
147 149
148 $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger()); 150 $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage);
149 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); 151 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0');
150 152
151 $this->assertEquals('http://1.1.1.1', $entry->getUrl()); 153 $this->assertEquals('http://1.1.1.1', $entry->getUrl());
@@ -167,7 +169,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
167 169
168 $graby = $this->getMockBuilder('Graby\Graby')->getMock(); 170 $graby = $this->getMockBuilder('Graby\Graby')->getMock();
169 171
170 $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger()); 172 $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage);
171 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0', [ 173 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0', [
172 'html' => str_repeat('this is my content', 325), 174 'html' => str_repeat('this is my content', 325),
173 'title' => 'this is my title', 175 'title' => 'this is my title',
@@ -197,7 +199,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
197 ->will($this->throwException(new \Exception())); 199 ->will($this->throwException(new \Exception()));
198 200
199 $tagRepo = $this->getTagRepositoryMock(); 201 $tagRepo = $this->getTagRepositoryMock();
200 $proxy = new ContentProxy($graby, $tagger, $tagRepo, $this->getLogger()); 202 $proxy = new ContentProxy($graby, $tagger, $tagRepo, $this->getLogger(), $this->fetchingErrorMessage);
201 203
202 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0', [ 204 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0', [
203 'html' => str_repeat('this is my content', 325), 205 'html' => str_repeat('this is my content', 325),
@@ -217,7 +219,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
217 ->getMock(); 219 ->getMock();
218 220
219 $tagRepo = $this->getTagRepositoryMock(); 221 $tagRepo = $this->getTagRepositoryMock();
220 $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger()); 222 $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage);
221 223
222 $entry = new Entry(new User()); 224 $entry = new Entry(new User());
223 225
@@ -235,7 +237,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
235 ->getMock(); 237 ->getMock();
236 238
237 $tagRepo = $this->getTagRepositoryMock(); 239 $tagRepo = $this->getTagRepositoryMock();
238 $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger()); 240 $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage);
239 241
240 $entry = new Entry(new User()); 242 $entry = new Entry(new User());
241 243
@@ -253,7 +255,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
253 ->getMock(); 255 ->getMock();
254 256
255 $tagRepo = $this->getTagRepositoryMock(); 257 $tagRepo = $this->getTagRepositoryMock();
256 $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger()); 258 $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage);
257 259
258 $entry = new Entry(new User()); 260 $entry = new Entry(new User());
259 261
@@ -269,7 +271,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
269 ->getMock(); 271 ->getMock();
270 272
271 $tagRepo = $this->getTagRepositoryMock(); 273 $tagRepo = $this->getTagRepositoryMock();
272 $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger()); 274 $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage);
273 275
274 $entry = new Entry(new User()); 276 $entry = new Entry(new User());
275 277
@@ -285,7 +287,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
285 ->getMock(); 287 ->getMock();
286 288
287 $tagRepo = $this->getTagRepositoryMock(); 289 $tagRepo = $this->getTagRepositoryMock();
288 $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger()); 290 $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage);
289 291
290 $tagEntity = new Tag(); 292 $tagEntity = new Tag();
291 $tagEntity->setLabel('tag1'); 293 $tagEntity->setLabel('tag1');
@@ -310,7 +312,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
310 $tagRepo->expects($this->never()) 312 $tagRepo->expects($this->never())
311 ->method('__call'); 313 ->method('__call');
312 314
313 $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger()); 315 $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage);
314 316
315 $tagEntity = new Tag(); 317 $tagEntity = new Tag();
316 $tagEntity->setLabel('tag1'); 318 $tagEntity->setLabel('tag1');
diff --git a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php
index 2c370ed9..acc39997 100644
--- a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php
@@ -112,7 +112,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
112 ->get('doctrine.orm.entity_manager') 112 ->get('doctrine.orm.entity_manager')
113 ->getRepository('WallabagCoreBundle:Entry') 113 ->getRepository('WallabagCoreBundle:Entry')
114 ->findByUrlAndUserId( 114 ->findByUrlAndUserId(
115 'http://www.framablog.org/index.php/post/2014/02/05/Framabag-service-libre-gratuit-interview-developpeur', 115 'https://framablog.org/2014/02/05/framabag-service-libre-gratuit-interview-developpeur/',
116 $this->getLoggedInUserId() 116 $this->getLoggedInUserId()
117 ); 117 );
118 118
@@ -126,9 +126,9 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
126 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); 126 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
127 $this->assertContains('flashes.import.notice.summary', $body[0]); 127 $this->assertContains('flashes.import.notice.summary', $body[0]);
128 128
129 $this->assertEmpty($content->getMimetype(), 'Mimetype for http://www.framablog.org is ok'); 129 $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.framablog.org is ok');
130 $this->assertEmpty($content->getPreviewPicture(), 'Preview picture for http://www.framablog.org is ok'); 130 $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.framablog.org is ok');
131 $this->assertEmpty($content->getLanguage(), 'Language for http://www.framablog.org is ok'); 131 $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.framablog.org is ok');
132 $this->assertEquals(1, count($content->getTags())); 132 $this->assertEquals(1, count($content->getTags()));
133 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); 133 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
134 } 134 }