From 0783c99a196d1626d91119f715285150662fbe6e Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 11 Feb 2016 13:27:17 +0100 Subject: reimport v1 entries if they were not fetched --- src/Wallabag/ImportBundle/Tests/Import/WallabagV1ImportTest.php | 8 +++++++- src/Wallabag/ImportBundle/Tests/Import/WallabagV2ImportTest.php | 7 ++++++- 2 files changed, 13 insertions(+), 2 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 1cb5a233..78cc19b6 100644 --- a/src/Wallabag/ImportBundle/Tests/Import/WallabagV1ImportTest.php +++ b/src/Wallabag/ImportBundle/Tests/Import/WallabagV1ImportTest.php @@ -12,6 +12,8 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase protected $user; protected $em; protected $logHandler; + protected $contentProxy; + private function getWallabagV1Import($unsetUser = false) { @@ -21,7 +23,11 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $wallabag = new WallabagV1Import($this->em); + $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy') + ->disableOriginalConstructor() + ->getMock(); + + $wallabag = new WallabagV1Import($this->em,$this->contentProxy); $this->logHandler = new TestHandler(); $logger = new Logger('test', array($this->logHandler)); diff --git a/src/Wallabag/ImportBundle/Tests/Import/WallabagV2ImportTest.php b/src/Wallabag/ImportBundle/Tests/Import/WallabagV2ImportTest.php index 4ebe93bf..0b33afb6 100644 --- a/src/Wallabag/ImportBundle/Tests/Import/WallabagV2ImportTest.php +++ b/src/Wallabag/ImportBundle/Tests/Import/WallabagV2ImportTest.php @@ -12,6 +12,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase protected $user; protected $em; protected $logHandler; + protected $contentProxy; private function getWallabagV2Import($unsetUser = false) { @@ -21,7 +22,11 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $wallabag = new WallabagV2Import($this->em); + $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy') + ->disableOriginalConstructor() + ->getMock(); + + $wallabag = new WallabagV2Import($this->em,$this->contentProxy); $this->logHandler = new TestHandler(); $logger = new Logger('test', array($this->logHandler)); -- cgit v1.2.3 From da0a9e01e9b6ef52656aa47367bfc30b1905fe40 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Thu, 11 Feb 2016 13:39:21 +0100 Subject: CS --- src/Wallabag/ImportBundle/Tests/Import/WallabagV1ImportTest.php | 3 +-- src/Wallabag/ImportBundle/Tests/Import/WallabagV2ImportTest.php | 2 +- 2 files changed, 2 insertions(+), 3 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 78cc19b6..093420f9 100644 --- a/src/Wallabag/ImportBundle/Tests/Import/WallabagV1ImportTest.php +++ b/src/Wallabag/ImportBundle/Tests/Import/WallabagV1ImportTest.php @@ -14,7 +14,6 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase protected $logHandler; protected $contentProxy; - private function getWallabagV1Import($unsetUser = false) { $this->user = new User(); @@ -27,7 +26,7 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $wallabag = new WallabagV1Import($this->em,$this->contentProxy); + $wallabag = new WallabagV1Import($this->em, $this->contentProxy); $this->logHandler = new TestHandler(); $logger = new Logger('test', array($this->logHandler)); diff --git a/src/Wallabag/ImportBundle/Tests/Import/WallabagV2ImportTest.php b/src/Wallabag/ImportBundle/Tests/Import/WallabagV2ImportTest.php index 0b33afb6..ebabb8f7 100644 --- a/src/Wallabag/ImportBundle/Tests/Import/WallabagV2ImportTest.php +++ b/src/Wallabag/ImportBundle/Tests/Import/WallabagV2ImportTest.php @@ -26,7 +26,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor() ->getMock(); - $wallabag = new WallabagV2Import($this->em,$this->contentProxy); + $wallabag = new WallabagV2Import($this->em, $this->contentProxy); $this->logHandler = new TestHandler(); $logger = new Logger('test', array($this->logHandler)); -- cgit v1.2.3 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