]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - tests/Wallabag/ImportBundle/Import/ChromeImportTest.php
Add disableContentUpdate import option
[github/wallabag/wallabag.git] / tests / Wallabag / ImportBundle / Import / ChromeImportTest.php
index 1e52615c0545d1f0739afb4660dce4cd164b323f..7a15e91879cac28f01d841e49ddd7c211fee75b4 100644 (file)
@@ -17,8 +17,9 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase
     protected $em;
     protected $logHandler;
     protected $contentProxy;
+    protected $tagsAssigner;
 
-    private function getChromeImport($unsetUser = false)
+    private function getChromeImport($unsetUser = false, $dispatched = 0)
     {
         $this->user = new User();
 
@@ -30,7 +31,19 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase
             ->disableOriginalConstructor()
             ->getMock();
 
-        $wallabag = new ChromeImport($this->em, $this->contentProxy);
+        $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
+            ->disableOriginalConstructor()
+            ->getMock();
+
+        $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
+            ->disableOriginalConstructor()
+            ->getMock();
+
+        $dispatcher
+            ->expects($this->exactly($dispatched))
+            ->method('dispatch');
+
+        $wallabag = new ChromeImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher);
 
         $this->logHandler = new TestHandler();
         $logger = new Logger('test', [$this->logHandler]);
@@ -54,7 +67,7 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase
 
     public function testImport()
     {
-        $chromeImport = $this->getChromeImport();
+        $chromeImport = $this->getChromeImport(false, 1);
         $chromeImport->setFilepath(__DIR__.'/../fixtures/chrome-bookmarks');
 
         $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
@@ -76,7 +89,7 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase
 
         $this->contentProxy
             ->expects($this->exactly(1))
-            ->method('updateEntry')
+            ->method('importEntry')
             ->willReturn($entry);
 
         $res = $chromeImport->import();
@@ -87,7 +100,7 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase
 
     public function testImportAndMarkAllAsRead()
     {
-        $chromeImport = $this->getChromeImport();
+        $chromeImport = $this->getChromeImport(false, 1);
         $chromeImport->setFilepath(__DIR__.'/../fixtures/chrome-bookmarks');
 
         $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
@@ -105,7 +118,7 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase
 
         $this->contentProxy
             ->expects($this->exactly(1))
-            ->method('updateEntry')
+            ->method('importEntry')
             ->willReturn(new Entry($this->user));
 
         // check that every entry persisted are archived
@@ -145,7 +158,7 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase
 
         $this->contentProxy
             ->expects($this->never())
-            ->method('updateEntry');
+            ->method('importEntry');
 
         $producer = $this->getMockBuilder('OldSound\RabbitMqBundle\RabbitMq\Producer')
             ->disableOriginalConstructor()
@@ -185,7 +198,7 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase
 
         $this->contentProxy
             ->expects($this->never())
-            ->method('updateEntry');
+            ->method('importEntry');
 
         $factory = new RedisMockFactory();
         $redisMock = $factory->getAdapter('Predis\Client', true);