aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-08-22 23:03:16 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-08-22 23:03:16 +0200
commit79efca1e6ff28362d4bd2713f68205294cdd07de (patch)
treec20482071f97b5ba0f075d59a9a097b08b26b910 /tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php
parent9c545fe028013b30417c1a932cd6b9027bff752d (diff)
parent80bb0b73445092c4aa3e94f90cc5f8667fa123ba (diff)
downloadwallabag-79efca1e6ff28362d4bd2713f68205294cdd07de.tar.gz
wallabag-79efca1e6ff28362d4bd2713f68205294cdd07de.tar.zst
wallabag-79efca1e6ff28362d4bd2713f68205294cdd07de.zip
Merge remote-tracking branch 'origin/master' into 2.1
Diffstat (limited to 'tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php')
-rw-r--r--tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php b/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php
index 8ec66b12..4a45e0f0 100644
--- a/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php
+++ b/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php
@@ -143,4 +143,44 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
143 $this->assertContains('WallabagImport: user is not defined', $records[0]['message']); 143 $this->assertContains('WallabagImport: user is not defined', $records[0]['message']);
144 $this->assertEquals('ERROR', $records[0]['level_name']); 144 $this->assertEquals('ERROR', $records[0]['level_name']);
145 } 145 }
146
147 public function testImportEmptyFile()
148 {
149 $wallabagV2Import = $this->getWallabagV2Import();
150 $wallabagV2Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2-empty.json');
151
152 $res = $wallabagV2Import->import();
153
154 $this->assertFalse($res);
155 $this->assertEquals(['skipped' => 0, 'imported' => 0], $wallabagV2Import->getSummary());
156 }
157
158 public function testImportWithExceptionFromGraby()
159 {
160 $wallabagV2Import = $this->getWallabagV2Import();
161 $wallabagV2Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2.json');
162
163 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
164 ->disableOriginalConstructor()
165 ->getMock();
166
167 $entryRepo->expects($this->exactly(24))
168 ->method('findByUrlAndUserId')
169 ->will($this->onConsecutiveCalls(false, true, false));
170
171 $this->em
172 ->expects($this->any())
173 ->method('getRepository')
174 ->willReturn($entryRepo);
175
176 $this->contentProxy
177 ->expects($this->exactly(2))
178 ->method('updateEntry')
179 ->will($this->throwException(new \Exception()));
180
181 $res = $wallabagV2Import->import();
182
183 $this->assertTrue($res);
184 $this->assertEquals(['skipped' => 24, 'imported' => 0], $wallabagV2Import->getSummary());
185 }
146} 186}