diff options
author | Jerome Charaoui <jerome@riseup.net> | 2016-12-02 23:59:18 -0500 |
---|---|---|
committer | Jerome Charaoui <jerome@riseup.net> | 2016-12-03 00:14:06 -0500 |
commit | fc2b7bda53f4dd66d193383983d48ca92016b5b3 (patch) | |
tree | ef4bfd9e3bbcc8d8518db9123e5eb37d781d9a67 /tests/Wallabag | |
parent | 3cd6da0b749bd136758add109ed30531be224f4a (diff) | |
download | wallabag-fc2b7bda53f4dd66d193383983d48ca92016b5b3.tar.gz wallabag-fc2b7bda53f4dd66d193383983d48ca92016b5b3.tar.zst wallabag-fc2b7bda53f4dd66d193383983d48ca92016b5b3.zip |
Fix ContentProxy tests
Diffstat (limited to 'tests/Wallabag')
-rw-r--r-- | tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php index 33b3ff2a..55e4d506 100644 --- a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php +++ b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php | |||
@@ -1,14 +1,15 @@ | |||
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | namespace Tests\Wallabag\CoreBundle\Helper; | 3 | namespace tests\Wallabag\CoreBundle\Helper; |
4 | 4 | ||
5 | use Psr\Log\NullLogger; | 5 | use Psr\Log\NullLogger; |
6 | use Wallabag\CoreBundle\Helper\ContentProxy; | 6 | use Wallabag\CoreBundle\Helper\ContentProxy; |
7 | use Wallabag\CoreBundle\Entity\Entry; | 7 | use Wallabag\CoreBundle\Entity\Entry; |
8 | use Wallabag\CoreBundle\Entity\Tag; | 8 | use Wallabag\CoreBundle\Entity\Tag; |
9 | use Wallabag\UserBundle\Entity\User; | 9 | use Wallabag\UserBundle\Entity\User; |
10 | use Tests\Wallabag\CoreBundle\CoreKernelTestCase; | ||
10 | 11 | ||
11 | class ContentProxyTest extends \PHPUnit_Framework_TestCase | 12 | class ContentProxyTest extends CoreKernelTestCase |
12 | { | 13 | { |
13 | public function testWithBadUrl() | 14 | public function testWithBadUrl() |
14 | { | 15 | { |
@@ -31,12 +32,12 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
31 | 'language' => '', | 32 | 'language' => '', |
32 | ]); | 33 | ]); |
33 | 34 | ||
34 | $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger()); | 35 | $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage); |
35 | $entry = $proxy->updateEntry(new Entry(new User()), 'http://user@:80'); | 36 | $entry = $proxy->updateEntry(new Entry(new User()), 'http://user@:80'); |
36 | 37 | ||
37 | $this->assertEquals('http://user@:80', $entry->getUrl()); | 38 | $this->assertEquals('http://user@:80', $entry->getUrl()); |
38 | $this->assertEmpty($entry->getTitle()); | 39 | $this->assertEmpty($entry->getTitle()); |
39 | $this->assertEquals('<p>Unable to retrieve readable content.</p>', $entry->getContent()); | 40 | $this->assertEquals($this->fetchingErrorMessage, $entry->getContent()); |
40 | $this->assertEmpty($entry->getPreviewPicture()); | 41 | $this->assertEmpty($entry->getPreviewPicture()); |
41 | $this->assertEmpty($entry->getMimetype()); | 42 | $this->assertEmpty($entry->getMimetype()); |
42 | $this->assertEmpty($entry->getLanguage()); | 43 | $this->assertEmpty($entry->getLanguage()); |
@@ -65,12 +66,12 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
65 | 'language' => '', | 66 | 'language' => '', |
66 | ]); | 67 | ]); |
67 | 68 | ||
68 | $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger()); | 69 | $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage); |
69 | $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); | 70 | $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); |
70 | 71 | ||
71 | $this->assertEquals('http://0.0.0.0', $entry->getUrl()); | 72 | $this->assertEquals('http://0.0.0.0', $entry->getUrl()); |
72 | $this->assertEmpty($entry->getTitle()); | 73 | $this->assertEmpty($entry->getTitle()); |
73 | $this->assertEquals('<p>Unable to retrieve readable content.</p>', $entry->getContent()); | 74 | $this->assertEquals($this->fetchingErrorMessage, $entry->getContent()); |
74 | $this->assertEmpty($entry->getPreviewPicture()); | 75 | $this->assertEmpty($entry->getPreviewPicture()); |
75 | $this->assertEmpty($entry->getMimetype()); | 76 | $this->assertEmpty($entry->getMimetype()); |
76 | $this->assertEmpty($entry->getLanguage()); | 77 | $this->assertEmpty($entry->getLanguage()); |
@@ -104,12 +105,12 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
104 | ], | 105 | ], |
105 | ]); | 106 | ]); |
106 | 107 | ||
107 | $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger()); | 108 | $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage); |
108 | $entry = $proxy->updateEntry(new Entry(new User()), 'http://domain.io'); | 109 | $entry = $proxy->updateEntry(new Entry(new User()), 'http://domain.io'); |
109 | 110 | ||
110 | $this->assertEquals('http://domain.io', $entry->getUrl()); | 111 | $this->assertEquals('http://domain.io', $entry->getUrl()); |
111 | $this->assertEquals('my title', $entry->getTitle()); | 112 | $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()); | 113 | $this->assertEquals($this->fetchingErrorMessage . '<p><i>But we found a short description: </i></p>desc', $entry->getContent()); |
113 | $this->assertEmpty($entry->getPreviewPicture()); | 114 | $this->assertEmpty($entry->getPreviewPicture()); |
114 | $this->assertEmpty($entry->getLanguage()); | 115 | $this->assertEmpty($entry->getLanguage()); |
115 | $this->assertEmpty($entry->getHttpStatus()); | 116 | $this->assertEmpty($entry->getHttpStatus()); |
@@ -145,7 +146,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
145 | ], | 146 | ], |
146 | ]); | 147 | ]); |
147 | 148 | ||
148 | $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger()); | 149 | $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage); |
149 | $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); | 150 | $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); |
150 | 151 | ||
151 | $this->assertEquals('http://1.1.1.1', $entry->getUrl()); | 152 | $this->assertEquals('http://1.1.1.1', $entry->getUrl()); |
@@ -167,7 +168,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
167 | 168 | ||
168 | $graby = $this->getMockBuilder('Graby\Graby')->getMock(); | 169 | $graby = $this->getMockBuilder('Graby\Graby')->getMock(); |
169 | 170 | ||
170 | $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger()); | 171 | $proxy = new ContentProxy($graby, $tagger, $this->getTagRepositoryMock(), $this->getLogger(), $this->fetchingErrorMessage); |
171 | $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0', [ | 172 | $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0', [ |
172 | 'html' => str_repeat('this is my content', 325), | 173 | 'html' => str_repeat('this is my content', 325), |
173 | 'title' => 'this is my title', | 174 | 'title' => 'this is my title', |
@@ -197,7 +198,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
197 | ->will($this->throwException(new \Exception())); | 198 | ->will($this->throwException(new \Exception())); |
198 | 199 | ||
199 | $tagRepo = $this->getTagRepositoryMock(); | 200 | $tagRepo = $this->getTagRepositoryMock(); |
200 | $proxy = new ContentProxy($graby, $tagger, $tagRepo, $this->getLogger()); | 201 | $proxy = new ContentProxy($graby, $tagger, $tagRepo, $this->getLogger(), $this->fetchingErrorMessage); |
201 | 202 | ||
202 | $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0', [ | 203 | $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0', [ |
203 | 'html' => str_repeat('this is my content', 325), | 204 | 'html' => str_repeat('this is my content', 325), |
@@ -217,7 +218,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
217 | ->getMock(); | 218 | ->getMock(); |
218 | 219 | ||
219 | $tagRepo = $this->getTagRepositoryMock(); | 220 | $tagRepo = $this->getTagRepositoryMock(); |
220 | $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger()); | 221 | $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage); |
221 | 222 | ||
222 | $entry = new Entry(new User()); | 223 | $entry = new Entry(new User()); |
223 | 224 | ||
@@ -235,7 +236,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
235 | ->getMock(); | 236 | ->getMock(); |
236 | 237 | ||
237 | $tagRepo = $this->getTagRepositoryMock(); | 238 | $tagRepo = $this->getTagRepositoryMock(); |
238 | $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger()); | 239 | $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage); |
239 | 240 | ||
240 | $entry = new Entry(new User()); | 241 | $entry = new Entry(new User()); |
241 | 242 | ||
@@ -253,7 +254,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
253 | ->getMock(); | 254 | ->getMock(); |
254 | 255 | ||
255 | $tagRepo = $this->getTagRepositoryMock(); | 256 | $tagRepo = $this->getTagRepositoryMock(); |
256 | $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger()); | 257 | $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage); |
257 | 258 | ||
258 | $entry = new Entry(new User()); | 259 | $entry = new Entry(new User()); |
259 | 260 | ||
@@ -269,7 +270,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
269 | ->getMock(); | 270 | ->getMock(); |
270 | 271 | ||
271 | $tagRepo = $this->getTagRepositoryMock(); | 272 | $tagRepo = $this->getTagRepositoryMock(); |
272 | $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger()); | 273 | $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage); |
273 | 274 | ||
274 | $entry = new Entry(new User()); | 275 | $entry = new Entry(new User()); |
275 | 276 | ||
@@ -285,7 +286,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
285 | ->getMock(); | 286 | ->getMock(); |
286 | 287 | ||
287 | $tagRepo = $this->getTagRepositoryMock(); | 288 | $tagRepo = $this->getTagRepositoryMock(); |
288 | $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger()); | 289 | $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage); |
289 | 290 | ||
290 | $tagEntity = new Tag(); | 291 | $tagEntity = new Tag(); |
291 | $tagEntity->setLabel('tag1'); | 292 | $tagEntity->setLabel('tag1'); |
@@ -310,7 +311,7 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase | |||
310 | $tagRepo->expects($this->never()) | 311 | $tagRepo->expects($this->never()) |
311 | ->method('__call'); | 312 | ->method('__call'); |
312 | 313 | ||
313 | $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger()); | 314 | $proxy = new ContentProxy($graby, $this->getTaggerMock(), $tagRepo, $this->getLogger(), $this->fetchingErrorMessage); |
314 | 315 | ||
315 | $tagEntity = new Tag(); | 316 | $tagEntity = new Tag(); |
316 | $tagEntity->setLabel('tag1'); | 317 | $tagEntity->setLabel('tag1'); |