X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FWallabag%2FImportBundle%2FImport%2FWallabagV2ImportTest.php;h=4a45e0f0a6779ab750f710ce157e85b235aa8c9e;hb=4e4e8e9899c39b31f2c977c796f8b6e6b4f727f3;hp=8ec66b12e41672b4d7e223217d8231b550386a5f;hpb=e408d7e895e784271a55c3a200666034db0af80a;p=github%2Fwallabag%2Fwallabag.git 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 $this->assertContains('WallabagImport: user is not defined', $records[0]['message']); $this->assertEquals('ERROR', $records[0]['level_name']); } + + public function testImportEmptyFile() + { + $wallabagV2Import = $this->getWallabagV2Import(); + $wallabagV2Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2-empty.json'); + + $res = $wallabagV2Import->import(); + + $this->assertFalse($res); + $this->assertEquals(['skipped' => 0, 'imported' => 0], $wallabagV2Import->getSummary()); + } + + public function testImportWithExceptionFromGraby() + { + $wallabagV2Import = $this->getWallabagV2Import(); + $wallabagV2Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2.json'); + + $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') + ->disableOriginalConstructor() + ->getMock(); + + $entryRepo->expects($this->exactly(24)) + ->method('findByUrlAndUserId') + ->will($this->onConsecutiveCalls(false, true, false)); + + $this->em + ->expects($this->any()) + ->method('getRepository') + ->willReturn($entryRepo); + + $this->contentProxy + ->expects($this->exactly(2)) + ->method('updateEntry') + ->will($this->throwException(new \Exception())); + + $res = $wallabagV2Import->import(); + + $this->assertTrue($res); + $this->assertEquals(['skipped' => 24, 'imported' => 0], $wallabagV2Import->getSummary()); + } }