From eaf9dad777e84d50e8b3e5877b05605ad9138fee Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 11 Feb 2016 15:48:20 +0100 Subject: add tests --- .../ImportBundle/Tests/Import/WallabagV1ImportTest.php | 15 ++++++++++++--- .../ImportBundle/Tests/Import/WallabagV2ImportTest.php | 4 ++-- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'src/Wallabag/ImportBundle/Tests/Import') diff --git a/src/Wallabag/ImportBundle/Tests/Import/WallabagV1ImportTest.php b/src/Wallabag/ImportBundle/Tests/Import/WallabagV1ImportTest.php index 093420f9..9a563a11 100644 --- a/src/Wallabag/ImportBundle/Tests/Import/WallabagV1ImportTest.php +++ b/src/Wallabag/ImportBundle/Tests/Import/WallabagV1ImportTest.php @@ -57,19 +57,28 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $entryRepo->expects($this->exactly(3)) + $entryRepo->expects($this->exactly(4)) ->method('findByUrlAndUserId') - ->will($this->onConsecutiveCalls(false, true, false)); + ->will($this->onConsecutiveCalls(false, true, false, false)); $this->em ->expects($this->any()) ->method('getRepository') ->willReturn($entryRepo); + $entry = $this->getMockBuilder('Wallabag\CoreBundle\Entity\Entry') + ->disableOriginalConstructor() + ->getMock(); + + $this->contentProxy + ->expects($this->once()) + ->method('updateEntry') + ->willReturn($entry); + $res = $wallabagV1Import->import(); $this->assertTrue($res); - $this->assertEquals(['skipped' => 1, 'imported' => 2], $wallabagV1Import->getSummary()); + $this->assertEquals(['skipped' => 1, 'imported' => 3], $wallabagV1Import->getSummary()); } public function testImportBadFile() diff --git a/src/Wallabag/ImportBundle/Tests/Import/WallabagV2ImportTest.php b/src/Wallabag/ImportBundle/Tests/Import/WallabagV2ImportTest.php index ebabb8f7..3268cd3e 100644 --- a/src/Wallabag/ImportBundle/Tests/Import/WallabagV2ImportTest.php +++ b/src/Wallabag/ImportBundle/Tests/Import/WallabagV2ImportTest.php @@ -57,7 +57,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $entryRepo->expects($this->exactly(2)) + $entryRepo->expects($this->exactly(3)) ->method('findByUrlAndUserId') ->will($this->onConsecutiveCalls(false, true, false)); @@ -69,7 +69,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase $res = $wallabagV2Import->import(); $this->assertTrue($res); - $this->assertEquals(['skipped' => 1, 'imported' => 1], $wallabagV2Import->getSummary()); + $this->assertEquals(['skipped' => 1, 'imported' => 2], $wallabagV2Import->getSummary()); } public function testImportBadFile() -- cgit v1.2.3