diff options
author | Thomas Citharel <tcit@tcit.fr> | 2016-09-21 19:24:19 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-09-25 12:29:19 +0200 |
commit | 64b1229b2d711e6b2f0e60de482802d9e86b912f (patch) | |
tree | ecf92f4cfd2eaecc9eb894f933222ccc0439e9f9 /tests/Wallabag/ImportBundle | |
parent | 2c61db30b737685ae9102ec10f2371778fb13f1a (diff) | |
download | wallabag-64b1229b2d711e6b2f0e60de482802d9e86b912f.tar.gz wallabag-64b1229b2d711e6b2f0e60de482802d9e86b912f.tar.zst wallabag-64b1229b2d711e6b2f0e60de482802d9e86b912f.zip |
fix tests
Diffstat (limited to 'tests/Wallabag/ImportBundle')
3 files changed, 27 insertions, 28 deletions
diff --git a/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php b/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php index 448e559f..8890c5b1 100644 --- a/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php +++ b/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php | |||
@@ -117,7 +117,6 @@ class ChromeControllerTest extends WallabagCoreTestCase | |||
117 | $this->getLoggedInUserId() | 117 | $this->getLoggedInUserId() |
118 | ); | 118 | ); |
119 | 119 | ||
120 | $this->assertEmpty($content->getMimetype()); | ||
121 | $this->assertNotEmpty($content->getPreviewPicture()); | 120 | $this->assertNotEmpty($content->getPreviewPicture()); |
122 | $this->assertNotEmpty($content->getLanguage()); | 121 | $this->assertNotEmpty($content->getLanguage()); |
123 | $this->assertEquals(0, count($content->getTags())); | 122 | $this->assertEquals(0, count($content->getTags())); |
diff --git a/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php b/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php index f781a4d2..1e52615c 100644 --- a/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php | |||
@@ -61,7 +61,7 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase | |||
61 | ->disableOriginalConstructor() | 61 | ->disableOriginalConstructor() |
62 | ->getMock(); | 62 | ->getMock(); |
63 | 63 | ||
64 | $entryRepo->expects($this->exactly(4)) | 64 | $entryRepo->expects($this->exactly(1)) |
65 | ->method('findByUrlAndUserId') | 65 | ->method('findByUrlAndUserId') |
66 | ->willReturn(false); | 66 | ->willReturn(false); |
67 | 67 | ||
@@ -75,26 +75,26 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase | |||
75 | ->getMock(); | 75 | ->getMock(); |
76 | 76 | ||
77 | $this->contentProxy | 77 | $this->contentProxy |
78 | ->expects($this->exactly(4)) | 78 | ->expects($this->exactly(1)) |
79 | ->method('updateEntry') | 79 | ->method('updateEntry') |
80 | ->willReturn($entry); | 80 | ->willReturn($entry); |
81 | 81 | ||
82 | $res = $chromeImport->import(); | 82 | $res = $chromeImport->import(); |
83 | 83 | ||
84 | $this->assertTrue($res); | 84 | $this->assertTrue($res); |
85 | $this->assertEquals(['skipped' => 0, 'imported' => 4, 'queued' => 0], $chromeImport->getSummary()); | 85 | $this->assertEquals(['skipped' => 0, 'imported' => 1, 'queued' => 0], $chromeImport->getSummary()); |
86 | } | 86 | } |
87 | 87 | ||
88 | public function testImportAndMarkAllAsRead() | 88 | public function testImportAndMarkAllAsRead() |
89 | { | 89 | { |
90 | $chromeImport = $this->getChromeImport(); | 90 | $chromeImport = $this->getChromeImport(); |
91 | $chromeImport->setFilepath(__DIR__.'/../fixtures/readability-read.json'); | 91 | $chromeImport->setFilepath(__DIR__.'/../fixtures/chrome-bookmarks'); |
92 | 92 | ||
93 | $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') | 93 | $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') |
94 | ->disableOriginalConstructor() | 94 | ->disableOriginalConstructor() |
95 | ->getMock(); | 95 | ->getMock(); |
96 | 96 | ||
97 | $entryRepo->expects($this->exactly(2)) | 97 | $entryRepo->expects($this->exactly(1)) |
98 | ->method('findByUrlAndUserId') | 98 | ->method('findByUrlAndUserId') |
99 | ->will($this->onConsecutiveCalls(false, true)); | 99 | ->will($this->onConsecutiveCalls(false, true)); |
100 | 100 | ||
@@ -120,13 +120,13 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase | |||
120 | 120 | ||
121 | $this->assertTrue($res); | 121 | $this->assertTrue($res); |
122 | 122 | ||
123 | $this->assertEquals(['skipped' => 1, 'imported' => 1, 'queued' => 0], $chromeImport->getSummary()); | 123 | $this->assertEquals(['skipped' => 0, 'imported' => 1, 'queued' => 0], $chromeImport->getSummary()); |
124 | } | 124 | } |
125 | 125 | ||
126 | public function testImportWithRabbit() | 126 | public function testImportWithRabbit() |
127 | { | 127 | { |
128 | $chromeImport = $this->getChromeImport(); | 128 | $chromeImport = $this->getChromeImport(); |
129 | $chromeImport->setFilepath(__DIR__.'/../fixtures/readability.json'); | 129 | $chromeImport->setFilepath(__DIR__.'/../fixtures/chrome-bookmarks'); |
130 | 130 | ||
131 | $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') | 131 | $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') |
132 | ->disableOriginalConstructor() | 132 | ->disableOriginalConstructor() |
@@ -152,20 +152,20 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase | |||
152 | ->getMock(); | 152 | ->getMock(); |
153 | 153 | ||
154 | $producer | 154 | $producer |
155 | ->expects($this->exactly(4)) | 155 | ->expects($this->exactly(1)) |
156 | ->method('publish'); | 156 | ->method('publish'); |
157 | 157 | ||
158 | $chromeImport->setProducer($producer); | 158 | $chromeImport->setProducer($producer); |
159 | 159 | ||
160 | $res = $readabilityImport->setMarkAsRead(true)->import(); | 160 | $res = $chromeImport->setMarkAsRead(true)->import(); |
161 | 161 | ||
162 | $this->assertTrue($res); | 162 | $this->assertTrue($res); |
163 | $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 4], $chromeImport->getSummary()); | 163 | $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 1], $chromeImport->getSummary()); |
164 | } | 164 | } |
165 | 165 | ||
166 | public function testImportWithRedis() | 166 | public function testImportWithRedis() |
167 | { | 167 | { |
168 | $chromeImport = $this->getReadabilityImport(); | 168 | $chromeImport = $this->getChromeImport(); |
169 | $chromeImport->setFilepath(__DIR__.'/../fixtures/chrome-bookmarks'); | 169 | $chromeImport->setFilepath(__DIR__.'/../fixtures/chrome-bookmarks'); |
170 | 170 | ||
171 | $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') | 171 | $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') |
@@ -198,7 +198,7 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase | |||
198 | $res = $chromeImport->setMarkAsRead(true)->import(); | 198 | $res = $chromeImport->setMarkAsRead(true)->import(); |
199 | 199 | ||
200 | $this->assertTrue($res); | 200 | $this->assertTrue($res); |
201 | $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 4], $chromeImport->getSummary()); | 201 | $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 1], $chromeImport->getSummary()); |
202 | 202 | ||
203 | $this->assertNotEmpty($redisMock->lpop('chrome')); | 203 | $this->assertNotEmpty($redisMock->lpop('chrome')); |
204 | } | 204 | } |
@@ -213,21 +213,21 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase | |||
213 | $this->assertFalse($res); | 213 | $this->assertFalse($res); |
214 | 214 | ||
215 | $records = $this->logHandler->getRecords(); | 215 | $records = $this->logHandler->getRecords(); |
216 | $this->assertContains('ChromeImport: unable to read file', $records[0]['message']); | 216 | $this->assertContains('Wallabag Browser Import: unable to read file', $records[0]['message']); |
217 | $this->assertEquals('ERROR', $records[0]['level_name']); | 217 | $this->assertEquals('ERROR', $records[0]['level_name']); |
218 | } | 218 | } |
219 | 219 | ||
220 | public function testImportUserNotDefined() | 220 | public function testImportUserNotDefined() |
221 | { | 221 | { |
222 | $chromeImport = $this->getChromeImport(true); | 222 | $chromeImport = $this->getChromeImport(true); |
223 | $chromeImport->setFilepath(__DIR__.'/../fixtures/readability.json'); | 223 | $chromeImport->setFilepath(__DIR__.'/../fixtures/chrome-bookmarks'); |
224 | 224 | ||
225 | $res = $chromeImport->import(); | 225 | $res = $chromeImport->import(); |
226 | 226 | ||
227 | $this->assertFalse($res); | 227 | $this->assertFalse($res); |
228 | 228 | ||
229 | $records = $this->logHandler->getRecords(); | 229 | $records = $this->logHandler->getRecords(); |
230 | $this->assertContains('ChromeImport: user is not defined', $records[0]['message']); | 230 | $this->assertContains('Wallabag Browser Import: user is not defined', $records[0]['message']); |
231 | $this->assertEquals('ERROR', $records[0]['level_name']); | 231 | $this->assertEquals('ERROR', $records[0]['level_name']); |
232 | } | 232 | } |
233 | } | 233 | } |
diff --git a/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php b/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php index 0b4a28b4..e8f0f3c7 100644 --- a/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php | |||
@@ -88,13 +88,13 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase | |||
88 | public function testImportAndMarkAllAsRead() | 88 | public function testImportAndMarkAllAsRead() |
89 | { | 89 | { |
90 | $firefoxImport = $this->getFirefoxImport(); | 90 | $firefoxImport = $this->getFirefoxImport(); |
91 | $firefoxImport->setFilepath(__DIR__.'/../fixtures/readability-read.json'); | 91 | $firefoxImport->setFilepath(__DIR__.'/../fixtures/firefox-bookmarks.json'); |
92 | 92 | ||
93 | $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') | 93 | $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') |
94 | ->disableOriginalConstructor() | 94 | ->disableOriginalConstructor() |
95 | ->getMock(); | 95 | ->getMock(); |
96 | 96 | ||
97 | $entryRepo->expects($this->exactly(2)) | 97 | $entryRepo->expects($this->exactly(4)) |
98 | ->method('findByUrlAndUserId') | 98 | ->method('findByUrlAndUserId') |
99 | ->will($this->onConsecutiveCalls(false, true)); | 99 | ->will($this->onConsecutiveCalls(false, true)); |
100 | 100 | ||
@@ -120,13 +120,13 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase | |||
120 | 120 | ||
121 | $this->assertTrue($res); | 121 | $this->assertTrue($res); |
122 | 122 | ||
123 | $this->assertEquals(['skipped' => 1, 'imported' => 1, 'queued' => 0], $firefoxImport->getSummary()); | 123 | $this->assertEquals(['skipped' => 3, 'imported' => 1, 'queued' => 0], $firefoxImport->getSummary()); |
124 | } | 124 | } |
125 | 125 | ||
126 | public function testImportWithRabbit() | 126 | public function testImportWithRabbit() |
127 | { | 127 | { |
128 | $firefoxImport = $this->getFirefoxImport(); | 128 | $firefoxImport = $this->getFirefoxImport(); |
129 | $firefoxImport->setFilepath(__DIR__.'/../fixtures/readability.json'); | 129 | $firefoxImport->setFilepath(__DIR__.'/../fixtures/firefox-bookmarks.json'); |
130 | 130 | ||
131 | $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') | 131 | $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') |
132 | ->disableOriginalConstructor() | 132 | ->disableOriginalConstructor() |
@@ -152,20 +152,20 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase | |||
152 | ->getMock(); | 152 | ->getMock(); |
153 | 153 | ||
154 | $producer | 154 | $producer |
155 | ->expects($this->exactly(4)) | 155 | ->expects($this->exactly(1)) |
156 | ->method('publish'); | 156 | ->method('publish'); |
157 | 157 | ||
158 | $firefoxImport->setProducer($producer); | 158 | $firefoxImport->setProducer($producer); |
159 | 159 | ||
160 | $res = $readabilityImport->setMarkAsRead(true)->import(); | 160 | $res = $firefoxImport->setMarkAsRead(true)->import(); |
161 | 161 | ||
162 | $this->assertTrue($res); | 162 | $this->assertTrue($res); |
163 | $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 4], $firefoxImport->getSummary()); | 163 | $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 1], $firefoxImport->getSummary()); |
164 | } | 164 | } |
165 | 165 | ||
166 | public function testImportWithRedis() | 166 | public function testImportWithRedis() |
167 | { | 167 | { |
168 | $firefoxImport = $this->getReadabilityImport(); | 168 | $firefoxImport = $this->getFirefoxImport(); |
169 | $firefoxImport->setFilepath(__DIR__.'/../fixtures/firefox-bookmarks.json'); | 169 | $firefoxImport->setFilepath(__DIR__.'/../fixtures/firefox-bookmarks.json'); |
170 | 170 | ||
171 | $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') | 171 | $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') |
@@ -198,7 +198,7 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase | |||
198 | $res = $firefoxImport->setMarkAsRead(true)->import(); | 198 | $res = $firefoxImport->setMarkAsRead(true)->import(); |
199 | 199 | ||
200 | $this->assertTrue($res); | 200 | $this->assertTrue($res); |
201 | $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 4], $firefoxImport->getSummary()); | 201 | $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 1], $firefoxImport->getSummary()); |
202 | 202 | ||
203 | $this->assertNotEmpty($redisMock->lpop('firefox')); | 203 | $this->assertNotEmpty($redisMock->lpop('firefox')); |
204 | } | 204 | } |
@@ -213,21 +213,21 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase | |||
213 | $this->assertFalse($res); | 213 | $this->assertFalse($res); |
214 | 214 | ||
215 | $records = $this->logHandler->getRecords(); | 215 | $records = $this->logHandler->getRecords(); |
216 | $this->assertContains('FirefoxImport: unable to read file', $records[0]['message']); | 216 | $this->assertContains('Wallabag Browser Import: unable to read file', $records[0]['message']); |
217 | $this->assertEquals('ERROR', $records[0]['level_name']); | 217 | $this->assertEquals('ERROR', $records[0]['level_name']); |
218 | } | 218 | } |
219 | 219 | ||
220 | public function testImportUserNotDefined() | 220 | public function testImportUserNotDefined() |
221 | { | 221 | { |
222 | $firefoxImport = $this->getFirefoxImport(true); | 222 | $firefoxImport = $this->getFirefoxImport(true); |
223 | $firefoxImport->setFilepath(__DIR__.'/../fixtures/readability.json'); | 223 | $firefoxImport->setFilepath(__DIR__.'/../fixtures/firefox-bookmarks.json'); |
224 | 224 | ||
225 | $res = $firefoxImport->import(); | 225 | $res = $firefoxImport->import(); |
226 | 226 | ||
227 | $this->assertFalse($res); | 227 | $this->assertFalse($res); |
228 | 228 | ||
229 | $records = $this->logHandler->getRecords(); | 229 | $records = $this->logHandler->getRecords(); |
230 | $this->assertContains('FirefoxImport: user is not defined', $records[0]['message']); | 230 | $this->assertContains('Wallabag Browser Import: user is not defined', $records[0]['message']); |
231 | $this->assertEquals('ERROR', $records[0]['level_name']); | 231 | $this->assertEquals('ERROR', $records[0]['level_name']); |
232 | } | 232 | } |
233 | } | 233 | } |