aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag
diff options
context:
space:
mode:
authorJérémy Benoist <j0k3r@users.noreply.github.com>2017-06-02 11:26:37 +0200
committerGitHub <noreply@github.com>2017-06-02 11:26:37 +0200
commita687c8d915276eee0c0494156700f7d0c0606735 (patch)
tree23178dc2407aa1b926b79281c34d8e05b6318d3b /tests/Wallabag
parent14b8a7c950147d32d7c9782832b87bf2b18b4fd7 (diff)
parentf5924e954730efdb7b9fadf23c0b73b3f5a0a434 (diff)
downloadwallabag-a687c8d915276eee0c0494156700f7d0c0606735.tar.gz
wallabag-a687c8d915276eee0c0494156700f7d0c0606735.tar.zst
wallabag-a687c8d915276eee0c0494156700f7d0c0606735.zip
Merge pull request #2708 from jcharaoui/import-disablecontentupdate
Import disableContentUpdate
Diffstat (limited to 'tests/Wallabag')
-rw-r--r--tests/Wallabag/CoreBundle/Controller/TagControllerTest.php2
-rw-r--r--tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php74
-rw-r--r--tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php11
3 files changed, 54 insertions, 33 deletions
diff --git a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
index f9bf7b87..af1ad7af 100644
--- a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
@@ -123,7 +123,7 @@ class TagControllerTest extends WallabagCoreTestCase
123 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 123 $this->assertEquals(302, $client->getResponse()->getStatusCode());
124 $this->assertEquals($entryUri, $client->getResponse()->getTargetUrl()); 124 $this->assertEquals($entryUri, $client->getResponse()->getTargetUrl());
125 125
126 // re-retrieve the entry to be sure to get fresh data from database (mostly for tags) 126 // re-retrieve the entry to be sure to get fresh data from database (mostly for tags)
127 $entry = $this->getEntityManager()->getRepository(Entry::class)->find($entry->getId()); 127 $entry = $this->getEntityManager()->getRepository(Entry::class)->find($entry->getId());
128 $this->assertNotContains($this->tagName, $entry->getTags()); 128 $this->assertNotContains($this->tagName, $entry->getTags());
129 129
diff --git a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
index 0c715d90..a3570125 100644
--- a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
+++ b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
@@ -3,14 +3,14 @@
3namespace Tests\Wallabag\CoreBundle\Helper; 3namespace Tests\Wallabag\CoreBundle\Helper;
4 4
5use Psr\Log\NullLogger; 5use Psr\Log\NullLogger;
6use Monolog\Logger;
7use Monolog\Handler\TestHandler;
6use Wallabag\CoreBundle\Helper\ContentProxy; 8use Wallabag\CoreBundle\Helper\ContentProxy;
7use Wallabag\CoreBundle\Entity\Entry; 9use Wallabag\CoreBundle\Entity\Entry;
8use Wallabag\CoreBundle\Entity\Tag; 10use Wallabag\CoreBundle\Entity\Tag;
9use Wallabag\UserBundle\Entity\User; 11use Wallabag\UserBundle\Entity\User;
10use Wallabag\CoreBundle\Helper\RuleBasedTagger; 12use Wallabag\CoreBundle\Helper\RuleBasedTagger;
11use Graby\Graby; 13use Graby\Graby;
12use Monolog\Handler\TestHandler;
13use Monolog\Logger;
14 14
15class ContentProxyTest extends \PHPUnit_Framework_TestCase 15class ContentProxyTest extends \PHPUnit_Framework_TestCase
16{ 16{
@@ -38,7 +38,8 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
38 ]); 38 ]);
39 39
40 $proxy = new ContentProxy($graby, $tagger, $this->getLogger(), $this->fetchingErrorMessage); 40 $proxy = new ContentProxy($graby, $tagger, $this->getLogger(), $this->fetchingErrorMessage);
41 $entry = $proxy->updateEntry(new Entry(new User()), 'http://user@:80'); 41 $entry = new Entry(new User());
42 $proxy->updateEntry($entry, 'http://user@:80');
42 43
43 $this->assertEquals('http://user@:80', $entry->getUrl()); 44 $this->assertEquals('http://user@:80', $entry->getUrl());
44 $this->assertEmpty($entry->getTitle()); 45 $this->assertEmpty($entry->getTitle());
@@ -72,7 +73,8 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
72 ]); 73 ]);
73 74
74 $proxy = new ContentProxy($graby, $tagger, $this->getLogger(), $this->fetchingErrorMessage); 75 $proxy = new ContentProxy($graby, $tagger, $this->getLogger(), $this->fetchingErrorMessage);
75 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); 76 $entry = new Entry(new User());
77 $proxy->updateEntry($entry, 'http://0.0.0.0');
76 78
77 $this->assertEquals('http://0.0.0.0', $entry->getUrl()); 79 $this->assertEquals('http://0.0.0.0', $entry->getUrl());
78 $this->assertEmpty($entry->getTitle()); 80 $this->assertEmpty($entry->getTitle());
@@ -111,7 +113,8 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
111 ]); 113 ]);
112 114
113 $proxy = new ContentProxy($graby, $tagger, $this->getLogger(), $this->fetchingErrorMessage); 115 $proxy = new ContentProxy($graby, $tagger, $this->getLogger(), $this->fetchingErrorMessage);
114 $entry = $proxy->updateEntry(new Entry(new User()), 'http://domain.io'); 116 $entry = new Entry(new User());
117 $proxy->updateEntry($entry, 'http://domain.io');
115 118
116 $this->assertEquals('http://domain.io', $entry->getUrl()); 119 $this->assertEquals('http://domain.io', $entry->getUrl());
117 $this->assertEquals('my title', $entry->getTitle()); 120 $this->assertEquals('my title', $entry->getTitle());
@@ -152,7 +155,8 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
152 ]); 155 ]);
153 156
154 $proxy = new ContentProxy($graby, $tagger, $this->getLogger(), $this->fetchingErrorMessage); 157 $proxy = new ContentProxy($graby, $tagger, $this->getLogger(), $this->fetchingErrorMessage);
155 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); 158 $entry = new Entry(new User());
159 $proxy->updateEntry($entry, 'http://0.0.0.0');
156 160
157 $this->assertEquals('http://1.1.1.1', $entry->getUrl()); 161 $this->assertEquals('http://1.1.1.1', $entry->getUrl());
158 $this->assertEquals('this is my title', $entry->getTitle()); 162 $this->assertEquals('this is my title', $entry->getTitle());
@@ -193,7 +197,8 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
193 ]); 197 ]);
194 198
195 $proxy = new ContentProxy($graby, $tagger, $this->getLogger(), $this->fetchingErrorMessage); 199 $proxy = new ContentProxy($graby, $tagger, $this->getLogger(), $this->fetchingErrorMessage);
196 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0'); 200 $entry = new Entry(new User());
201 $proxy->updateEntry($entry, 'http://0.0.0.0');
197 202
198 $this->assertEquals('http://1.1.1.1', $entry->getUrl()); 203 $this->assertEquals('http://1.1.1.1', $entry->getUrl());
199 $this->assertEquals('this is my title', $entry->getTitle()); 204 $this->assertEquals('this is my title', $entry->getTitle());
@@ -213,8 +218,9 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
213 ->method('tag'); 218 ->method('tag');
214 219
215 $proxy = new ContentProxy((new Graby()), $tagger, $this->getLogger(), $this->fetchingErrorMessage); 220 $proxy = new ContentProxy((new Graby()), $tagger, $this->getLogger(), $this->fetchingErrorMessage);
216 $entry = $proxy->updateEntry( 221 $entry = new Entry(new User());
217 new Entry(new User()), 222 $proxy->updateEntry(
223 $entry,
218 'http://0.0.0.0', 224 'http://0.0.0.0',
219 [ 225 [
220 'html' => str_repeat('this is my content', 325), 226 'html' => str_repeat('this is my content', 325),
@@ -250,10 +256,14 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
250 $tagger->expects($this->once()) 256 $tagger->expects($this->once())
251 ->method('tag'); 257 ->method('tag');
252 258
253 $proxy = new ContentProxy((new Graby()), $tagger, $this->getLogger(), $this->fetchingErrorMessage); 259 $logHandler = new TestHandler();
254 $entry = $proxy->updateEntry( 260 $logger = new Logger('test', [$logHandler]);
255 new Entry(new User()), 261
256 'http://0.0.0.0', 262 $proxy = new ContentProxy((new Graby()), $tagger, $logger, $this->fetchingErrorMessage);
263 $entry = new Entry(new User());
264 $proxy->updateEntry(
265 $entry,
266 'http://1.1.1.1',
257 [ 267 [
258 'html' => str_repeat('this is my content', 325), 268 'html' => str_repeat('this is my content', 325),
259 'title' => 'this is my title', 269 'title' => 'this is my title',
@@ -285,9 +295,10 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
285 $logger->pushHandler($handler); 295 $logger->pushHandler($handler);
286 296
287 $proxy = new ContentProxy((new Graby()), $tagger, $logger, $this->fetchingErrorMessage); 297 $proxy = new ContentProxy((new Graby()), $tagger, $logger, $this->fetchingErrorMessage);
288 $entry = $proxy->updateEntry( 298 $entry = new Entry(new User());
289 new Entry(new User()), 299 $proxy->updateEntry(
290 'http://0.0.0.0', 300 $entry,
301 'http://1.1.1.1',
291 [ 302 [
292 'html' => str_repeat('this is my content', 325), 303 'html' => str_repeat('this is my content', 325),
293 'title' => 'this is my title', 304 'title' => 'this is my title',
@@ -315,24 +326,24 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
315 326
316 public function testTaggerThrowException() 327 public function testTaggerThrowException()
317 { 328 {
318 $graby = $this->getMockBuilder('Graby\Graby')
319 ->disableOriginalConstructor()
320 ->getMock();
321
322 $tagger = $this->getTaggerMock(); 329 $tagger = $this->getTaggerMock();
323 $tagger->expects($this->once()) 330 $tagger->expects($this->once())
324 ->method('tag') 331 ->method('tag')
325 ->will($this->throwException(new \Exception())); 332 ->will($this->throwException(new \Exception()));
326 333
327 $proxy = new ContentProxy($graby, $tagger, $this->getLogger(), $this->fetchingErrorMessage); 334 $proxy = new ContentProxy((new Graby()), $tagger, $this->getLogger(), $this->fetchingErrorMessage);
328 335 $entry = new Entry(new User());
329 $entry = $proxy->updateEntry(new Entry(new User()), 'http://0.0.0.0', [ 336 $proxy->updateEntry(
330 'html' => str_repeat('this is my content', 325), 337 $entry,
331 'title' => 'this is my title', 338 'http://1.1.1.1',
332 'url' => 'http://1.1.1.1', 339 [
333 'content_type' => 'text/html', 340 'html' => str_repeat('this is my content', 325),
334 'language' => 'fr', 341 'title' => 'this is my title',
335 ]); 342 'url' => 'http://1.1.1.1',
343 'content_type' => 'text/html',
344 'language' => 'fr',
345 ]
346 );
336 347
337 $this->assertCount(0, $entry->getTags()); 348 $this->assertCount(0, $entry->getTags());
338 } 349 }
@@ -361,8 +372,9 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
361 ->method('tag'); 372 ->method('tag');
362 373
363 $proxy = new ContentProxy((new Graby()), $tagger, $this->getLogger(), $this->fetchingErrorMessage); 374 $proxy = new ContentProxy((new Graby()), $tagger, $this->getLogger(), $this->fetchingErrorMessage);
364 $entry = $proxy->updateEntry( 375 $entry = new Entry(new User());
365 new Entry(new User()), 376 $proxy->updateEntry(
377 $entry,
366 'http://1.1.1.1', 378 'http://1.1.1.1',
367 [ 379 [
368 'html' => $html, 380 'html' => $html,
diff --git a/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php b/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php
index 7cbef637..834b7ef5 100644
--- a/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php
+++ b/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php
@@ -19,6 +19,8 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
19 protected $contentProxy; 19 protected $contentProxy;
20 protected $tagsAssigner; 20 protected $tagsAssigner;
21 protected $uow; 21 protected $uow;
22 protected $fetchingErrorMessageTitle = 'No title found';
23 protected $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>.';
22 24
23 private function getWallabagV1Import($unsetUser = false, $dispatched = 0) 25 private function getWallabagV1Import($unsetUser = false, $dispatched = 0)
24 { 26 {
@@ -58,7 +60,14 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
58 ->expects($this->exactly($dispatched)) 60 ->expects($this->exactly($dispatched))
59 ->method('dispatch'); 61 ->method('dispatch');
60 62
61 $wallabag = new WallabagV1Import($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher); 63 $wallabag = new WallabagV1Import(
64 $this->em,
65 $this->contentProxy,
66 $this->tagsAssigner,
67 $dispatcher,
68 $this->fetchingErrorMessageTitle,
69 $this->fetchingErrorMessage
70 );
62 71
63 $this->logHandler = new TestHandler(); 72 $this->logHandler = new TestHandler();
64 $logger = new Logger('test', [$this->logHandler]); 73 $logger = new Logger('test', [$this->logHandler]);