aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php')
-rw-r--r--tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php25
1 files changed, 17 insertions, 8 deletions
diff --git a/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php b/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php
index 9f0c5bac..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]);
@@ -82,14 +91,14 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
82 91
83 public function testImport() 92 public function testImport()
84 { 93 {
85 $wallabagV1Import = $this->getWallabagV1Import(false, 3); 94 $wallabagV1Import = $this->getWallabagV1Import(false, 1);
86 $wallabagV1Import->setFilepath(__DIR__.'/../fixtures/wallabag-v1.json'); 95 $wallabagV1Import->setFilepath(__DIR__.'/../fixtures/wallabag-v1.json');
87 96
88 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 97 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
89 ->disableOriginalConstructor() 98 ->disableOriginalConstructor()
90 ->getMock(); 99 ->getMock();
91 100
92 $entryRepo->expects($this->exactly(4)) 101 $entryRepo->expects($this->exactly(2))
93 ->method('findByUrlAndUserId') 102 ->method('findByUrlAndUserId')
94 ->will($this->onConsecutiveCalls(false, true, false, false)); 103 ->will($this->onConsecutiveCalls(false, true, false, false));
95 104
@@ -103,14 +112,14 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
103 ->getMock(); 112 ->getMock();
104 113
105 $this->contentProxy 114 $this->contentProxy
106 ->expects($this->exactly(3)) 115 ->expects($this->exactly(1))
107 ->method('updateEntry') 116 ->method('updateEntry')
108 ->willReturn($entry); 117 ->willReturn($entry);
109 118
110 $res = $wallabagV1Import->import(); 119 $res = $wallabagV1Import->import();
111 120
112 $this->assertTrue($res); 121 $this->assertTrue($res);
113 $this->assertEquals(['skipped' => 1, 'imported' => 3, 'queued' => 0], $wallabagV1Import->getSummary()); 122 $this->assertEquals(['skipped' => 1, 'imported' => 1, 'queued' => 0], $wallabagV1Import->getSummary());
114 } 123 }
115 124
116 public function testImportAndMarkAllAsRead() 125 public function testImportAndMarkAllAsRead()
@@ -180,7 +189,7 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
180 ->getMock(); 189 ->getMock();
181 190
182 $producer 191 $producer
183 ->expects($this->exactly(4)) 192 ->expects($this->exactly(2))
184 ->method('publish'); 193 ->method('publish');
185 194
186 $wallabagV1Import->setProducer($producer); 195 $wallabagV1Import->setProducer($producer);
@@ -188,7 +197,7 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
188 $res = $wallabagV1Import->setMarkAsRead(true)->import(); 197 $res = $wallabagV1Import->setMarkAsRead(true)->import();
189 198
190 $this->assertTrue($res); 199 $this->assertTrue($res);
191 $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 4], $wallabagV1Import->getSummary()); 200 $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 2], $wallabagV1Import->getSummary());
192 } 201 }
193 202
194 public function testImportWithRedis() 203 public function testImportWithRedis()
@@ -226,7 +235,7 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
226 $res = $wallabagV1Import->setMarkAsRead(true)->import(); 235 $res = $wallabagV1Import->setMarkAsRead(true)->import();
227 236
228 $this->assertTrue($res); 237 $this->assertTrue($res);
229 $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 4], $wallabagV1Import->getSummary()); 238 $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 2], $wallabagV1Import->getSummary());
230 239
231 $this->assertNotEmpty($redisMock->lpop('wallabag_v1')); 240 $this->assertNotEmpty($redisMock->lpop('wallabag_v1'));
232 } 241 }