diff options
author | Thomas Citharel <tcit@tcit.fr> | 2016-08-20 14:31:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-20 14:31:32 +0200 |
commit | 8642f14220a834a434225d812e2ea07680b04cb2 (patch) | |
tree | 325d2724ae5e5988b2ab77a33cf3f4cfe88c3647 /tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php | |
parent | e408d7e895e784271a55c3a200666034db0af80a (diff) | |
parent | 19d9efab32b5c6403e9ee95fb70a2ce56a27f14b (diff) | |
download | wallabag-8642f14220a834a434225d812e2ea07680b04cb2.tar.gz wallabag-8642f14220a834a434225d812e2ea07680b04cb2.tar.zst wallabag-8642f14220a834a434225d812e2ea07680b04cb2.zip |
Merge pull request #2224 from wallabag/avoid-exception-import
Avoid breaking import when fetching fail
Diffstat (limited to 'tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php')
-rw-r--r-- | tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php | 40 |
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 | } |