diff options
Diffstat (limited to 'tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php')
-rw-r--r-- | tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php b/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php index d1bbe648..8f466d38 100644 --- a/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php | |||
@@ -17,6 +17,7 @@ class ReadabilityImportTest 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; | ||
20 | 21 | ||
21 | private function getReadabilityImport($unsetUser = false, $dispatched = 0) | 22 | private function getReadabilityImport($unsetUser = false, $dispatched = 0) |
22 | { | 23 | { |
@@ -30,6 +31,10 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase | |||
30 | ->disableOriginalConstructor() | 31 | ->disableOriginalConstructor() |
31 | ->getMock(); | 32 | ->getMock(); |
32 | 33 | ||
34 | $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner') | ||
35 | ->disableOriginalConstructor() | ||
36 | ->getMock(); | ||
37 | |||
33 | $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher') | 38 | $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher') |
34 | ->disableOriginalConstructor() | 39 | ->disableOriginalConstructor() |
35 | ->getMock(); | 40 | ->getMock(); |
@@ -38,7 +43,7 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase | |||
38 | ->expects($this->exactly($dispatched)) | 43 | ->expects($this->exactly($dispatched)) |
39 | ->method('dispatch'); | 44 | ->method('dispatch'); |
40 | 45 | ||
41 | $wallabag = new ReadabilityImport($this->em, $this->contentProxy, $dispatcher); | 46 | $wallabag = new ReadabilityImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher); |
42 | 47 | ||
43 | $this->logHandler = new TestHandler(); | 48 | $this->logHandler = new TestHandler(); |
44 | $logger = new Logger('test', [$this->logHandler]); | 49 | $logger = new Logger('test', [$this->logHandler]); |
@@ -62,14 +67,14 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase | |||
62 | 67 | ||
63 | public function testImport() | 68 | public function testImport() |
64 | { | 69 | { |
65 | $readabilityImport = $this->getReadabilityImport(false, 24); | 70 | $readabilityImport = $this->getReadabilityImport(false, 3); |
66 | $readabilityImport->setFilepath(__DIR__.'/../fixtures/readability.json'); | 71 | $readabilityImport->setFilepath(__DIR__.'/../fixtures/readability.json'); |
67 | 72 | ||
68 | $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') | 73 | $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') |
69 | ->disableOriginalConstructor() | 74 | ->disableOriginalConstructor() |
70 | ->getMock(); | 75 | ->getMock(); |
71 | 76 | ||
72 | $entryRepo->expects($this->exactly(24)) | 77 | $entryRepo->expects($this->exactly(3)) |
73 | ->method('findByUrlAndUserId') | 78 | ->method('findByUrlAndUserId') |
74 | ->willReturn(false); | 79 | ->willReturn(false); |
75 | 80 | ||
@@ -83,14 +88,14 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase | |||
83 | ->getMock(); | 88 | ->getMock(); |
84 | 89 | ||
85 | $this->contentProxy | 90 | $this->contentProxy |
86 | ->expects($this->exactly(24)) | 91 | ->expects($this->exactly(3)) |
87 | ->method('updateEntry') | 92 | ->method('updateEntry') |
88 | ->willReturn($entry); | 93 | ->willReturn($entry); |
89 | 94 | ||
90 | $res = $readabilityImport->import(); | 95 | $res = $readabilityImport->import(); |
91 | 96 | ||
92 | $this->assertTrue($res); | 97 | $this->assertTrue($res); |
93 | $this->assertEquals(['skipped' => 0, 'imported' => 24, 'queued' => 0], $readabilityImport->getSummary()); | 98 | $this->assertEquals(['skipped' => 0, 'imported' => 3, 'queued' => 0], $readabilityImport->getSummary()); |
94 | } | 99 | } |
95 | 100 | ||
96 | public function testImportAndMarkAllAsRead() | 101 | public function testImportAndMarkAllAsRead() |
@@ -160,7 +165,7 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase | |||
160 | ->getMock(); | 165 | ->getMock(); |
161 | 166 | ||
162 | $producer | 167 | $producer |
163 | ->expects($this->exactly(24)) | 168 | ->expects($this->exactly(3)) |
164 | ->method('publish'); | 169 | ->method('publish'); |
165 | 170 | ||
166 | $readabilityImport->setProducer($producer); | 171 | $readabilityImport->setProducer($producer); |
@@ -168,7 +173,7 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase | |||
168 | $res = $readabilityImport->setMarkAsRead(true)->import(); | 173 | $res = $readabilityImport->setMarkAsRead(true)->import(); |
169 | 174 | ||
170 | $this->assertTrue($res); | 175 | $this->assertTrue($res); |
171 | $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 24], $readabilityImport->getSummary()); | 176 | $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 3], $readabilityImport->getSummary()); |
172 | } | 177 | } |
173 | 178 | ||
174 | public function testImportWithRedis() | 179 | public function testImportWithRedis() |
@@ -206,7 +211,7 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase | |||
206 | $res = $readabilityImport->setMarkAsRead(true)->import(); | 211 | $res = $readabilityImport->setMarkAsRead(true)->import(); |
207 | 212 | ||
208 | $this->assertTrue($res); | 213 | $this->assertTrue($res); |
209 | $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 24], $readabilityImport->getSummary()); | 214 | $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 3], $readabilityImport->getSummary()); |
210 | 215 | ||
211 | $this->assertNotEmpty($redisMock->lpop('readability')); | 216 | $this->assertNotEmpty($redisMock->lpop('readability')); |
212 | } | 217 | } |