diff options
Diffstat (limited to 'tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php')
-rw-r--r-- | tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php b/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php index 0e50b8b2..5cc04aa5 100644 --- a/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php | |||
@@ -17,6 +17,8 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase | |||
17 | protected $em; | 17 | protected $em; |
18 | protected $logHandler; | 18 | protected $logHandler; |
19 | protected $contentProxy; | 19 | protected $contentProxy; |
20 | protected $tagsAssigner; | ||
21 | protected $uow; | ||
20 | 22 | ||
21 | private function getWallabagV2Import($unsetUser = false, $dispatched = 0) | 23 | private function getWallabagV2Import($unsetUser = false, $dispatched = 0) |
22 | { | 24 | { |
@@ -44,6 +46,10 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase | |||
44 | ->disableOriginalConstructor() | 46 | ->disableOriginalConstructor() |
45 | ->getMock(); | 47 | ->getMock(); |
46 | 48 | ||
49 | $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner') | ||
50 | ->disableOriginalConstructor() | ||
51 | ->getMock(); | ||
52 | |||
47 | $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher') | 53 | $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher') |
48 | ->disableOriginalConstructor() | 54 | ->disableOriginalConstructor() |
49 | ->getMock(); | 55 | ->getMock(); |
@@ -52,7 +58,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase | |||
52 | ->expects($this->exactly($dispatched)) | 58 | ->expects($this->exactly($dispatched)) |
53 | ->method('dispatch'); | 59 | ->method('dispatch'); |
54 | 60 | ||
55 | $wallabag = new WallabagV2Import($this->em, $this->contentProxy, $dispatcher); | 61 | $wallabag = new WallabagV2Import($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher); |
56 | 62 | ||
57 | $this->logHandler = new TestHandler(); | 63 | $this->logHandler = new TestHandler(); |
58 | $logger = new Logger('test', [$this->logHandler]); | 64 | $logger = new Logger('test', [$this->logHandler]); |
@@ -83,7 +89,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase | |||
83 | ->disableOriginalConstructor() | 89 | ->disableOriginalConstructor() |
84 | ->getMock(); | 90 | ->getMock(); |
85 | 91 | ||
86 | $entryRepo->expects($this->exactly(24)) | 92 | $entryRepo->expects($this->exactly(6)) |
87 | ->method('findByUrlAndUserId') | 93 | ->method('findByUrlAndUserId') |
88 | ->will($this->onConsecutiveCalls(false, true, false)); | 94 | ->will($this->onConsecutiveCalls(false, true, false)); |
89 | 95 | ||
@@ -100,7 +106,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase | |||
100 | $res = $wallabagV2Import->import(); | 106 | $res = $wallabagV2Import->import(); |
101 | 107 | ||
102 | $this->assertTrue($res); | 108 | $this->assertTrue($res); |
103 | $this->assertEquals(['skipped' => 22, 'imported' => 2, 'queued' => 0], $wallabagV2Import->getSummary()); | 109 | $this->assertEquals(['skipped' => 4, 'imported' => 2, 'queued' => 0], $wallabagV2Import->getSummary()); |
104 | } | 110 | } |
105 | 111 | ||
106 | public function testImportAndMarkAllAsRead() | 112 | public function testImportAndMarkAllAsRead() |
@@ -166,7 +172,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase | |||
166 | ->getMock(); | 172 | ->getMock(); |
167 | 173 | ||
168 | $producer | 174 | $producer |
169 | ->expects($this->exactly(24)) | 175 | ->expects($this->exactly(6)) |
170 | ->method('publish'); | 176 | ->method('publish'); |
171 | 177 | ||
172 | $wallabagV2Import->setProducer($producer); | 178 | $wallabagV2Import->setProducer($producer); |
@@ -174,7 +180,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase | |||
174 | $res = $wallabagV2Import->setMarkAsRead(true)->import(); | 180 | $res = $wallabagV2Import->setMarkAsRead(true)->import(); |
175 | 181 | ||
176 | $this->assertTrue($res); | 182 | $this->assertTrue($res); |
177 | $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 24], $wallabagV2Import->getSummary()); | 183 | $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 6], $wallabagV2Import->getSummary()); |
178 | } | 184 | } |
179 | 185 | ||
180 | public function testImportWithRedis() | 186 | public function testImportWithRedis() |
@@ -208,7 +214,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase | |||
208 | $res = $wallabagV2Import->setMarkAsRead(true)->import(); | 214 | $res = $wallabagV2Import->setMarkAsRead(true)->import(); |
209 | 215 | ||
210 | $this->assertTrue($res); | 216 | $this->assertTrue($res); |
211 | $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 24], $wallabagV2Import->getSummary()); | 217 | $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 6], $wallabagV2Import->getSummary()); |
212 | 218 | ||
213 | $this->assertNotEmpty($redisMock->lpop('wallabag_v2')); | 219 | $this->assertNotEmpty($redisMock->lpop('wallabag_v2')); |
214 | } | 220 | } |
@@ -261,7 +267,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase | |||
261 | ->disableOriginalConstructor() | 267 | ->disableOriginalConstructor() |
262 | ->getMock(); | 268 | ->getMock(); |
263 | 269 | ||
264 | $entryRepo->expects($this->exactly(24)) | 270 | $entryRepo->expects($this->exactly(6)) |
265 | ->method('findByUrlAndUserId') | 271 | ->method('findByUrlAndUserId') |
266 | ->will($this->onConsecutiveCalls(false, true, false)); | 272 | ->will($this->onConsecutiveCalls(false, true, false)); |
267 | 273 | ||
@@ -278,6 +284,6 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase | |||
278 | $res = $wallabagV2Import->import(); | 284 | $res = $wallabagV2Import->import(); |
279 | 285 | ||
280 | $this->assertTrue($res); | 286 | $this->assertTrue($res); |
281 | $this->assertEquals(['skipped' => 22, 'imported' => 2, 'queued' => 0], $wallabagV2Import->getSummary()); | 287 | $this->assertEquals(['skipped' => 4, 'imported' => 2, 'queued' => 0], $wallabagV2Import->getSummary()); |
282 | } | 288 | } |
283 | } | 289 | } |