aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ImportBundle/Tests/Import/WallabagV1ImportTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/ImportBundle/Tests/Import/WallabagV1ImportTest.php')
-rw-r--r--src/Wallabag/ImportBundle/Tests/Import/WallabagV1ImportTest.php22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/Wallabag/ImportBundle/Tests/Import/WallabagV1ImportTest.php b/src/Wallabag/ImportBundle/Tests/Import/WallabagV1ImportTest.php
index 1cb5a233..9a563a11 100644
--- a/src/Wallabag/ImportBundle/Tests/Import/WallabagV1ImportTest.php
+++ b/src/Wallabag/ImportBundle/Tests/Import/WallabagV1ImportTest.php
@@ -12,6 +12,7 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
12 protected $user; 12 protected $user;
13 protected $em; 13 protected $em;
14 protected $logHandler; 14 protected $logHandler;
15 protected $contentProxy;
15 16
16 private function getWallabagV1Import($unsetUser = false) 17 private function getWallabagV1Import($unsetUser = false)
17 { 18 {
@@ -21,7 +22,11 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
21 ->disableOriginalConstructor() 22 ->disableOriginalConstructor()
22 ->getMock(); 23 ->getMock();
23 24
24 $wallabag = new WallabagV1Import($this->em); 25 $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy')
26 ->disableOriginalConstructor()
27 ->getMock();
28
29 $wallabag = new WallabagV1Import($this->em, $this->contentProxy);
25 30
26 $this->logHandler = new TestHandler(); 31 $this->logHandler = new TestHandler();
27 $logger = new Logger('test', array($this->logHandler)); 32 $logger = new Logger('test', array($this->logHandler));
@@ -52,19 +57,28 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
52 ->disableOriginalConstructor() 57 ->disableOriginalConstructor()
53 ->getMock(); 58 ->getMock();
54 59
55 $entryRepo->expects($this->exactly(3)) 60 $entryRepo->expects($this->exactly(4))
56 ->method('findByUrlAndUserId') 61 ->method('findByUrlAndUserId')
57 ->will($this->onConsecutiveCalls(false, true, false)); 62 ->will($this->onConsecutiveCalls(false, true, false, false));
58 63
59 $this->em 64 $this->em
60 ->expects($this->any()) 65 ->expects($this->any())
61 ->method('getRepository') 66 ->method('getRepository')
62 ->willReturn($entryRepo); 67 ->willReturn($entryRepo);
63 68
69 $entry = $this->getMockBuilder('Wallabag\CoreBundle\Entity\Entry')
70 ->disableOriginalConstructor()
71 ->getMock();
72
73 $this->contentProxy
74 ->expects($this->once())
75 ->method('updateEntry')
76 ->willReturn($entry);
77
64 $res = $wallabagV1Import->import(); 78 $res = $wallabagV1Import->import();
65 79
66 $this->assertTrue($res); 80 $this->assertTrue($res);
67 $this->assertEquals(['skipped' => 1, 'imported' => 2], $wallabagV1Import->getSummary()); 81 $this->assertEquals(['skipped' => 1, 'imported' => 3], $wallabagV1Import->getSummary());
68 } 82 }
69 83
70 public function testImportBadFile() 84 public function testImportBadFile()