aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php
diff options
context:
space:
mode:
authorThomas Citharel <tcit@tcit.fr>2016-09-21 19:24:19 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-09-25 12:29:19 +0200
commit64b1229b2d711e6b2f0e60de482802d9e86b912f (patch)
treeecf92f4cfd2eaecc9eb894f933222ccc0439e9f9 /tests/Wallabag/ImportBundle/Import/ChromeImportTest.php
parent2c61db30b737685ae9102ec10f2371778fb13f1a (diff)
downloadwallabag-64b1229b2d711e6b2f0e60de482802d9e86b912f.tar.gz
wallabag-64b1229b2d711e6b2f0e60de482802d9e86b912f.tar.zst
wallabag-64b1229b2d711e6b2f0e60de482802d9e86b912f.zip
fix tests
Diffstat (limited to 'tests/Wallabag/ImportBundle/Import/ChromeImportTest.php')
-rw-r--r--tests/Wallabag/ImportBundle/Import/ChromeImportTest.php30
1 files changed, 15 insertions, 15 deletions
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}