aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/Wallabag/ImportBundle/Import/InstapaperImport.php17
-rw-r--r--tests/Wallabag/CoreBundle/Command/ExportCommandTest.php2
-rw-r--r--tests/Wallabag/CoreBundle/Command/TagAllCommandTest.php2
-rw-r--r--tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php1
-rw-r--r--tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php2
-rw-r--r--tests/Wallabag/ImportBundle/Command/RedisWorkerCommandTest.php4
-rw-r--r--tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php20
-rw-r--r--tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php8
-rw-r--r--tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php6
-rw-r--r--tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php14
-rw-r--r--tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php13
-rw-r--r--tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php35
-rw-r--r--tests/Wallabag/ImportBundle/fixtures/instapaper-export.csv1
13 files changed, 94 insertions, 31 deletions
diff --git a/src/Wallabag/ImportBundle/Import/InstapaperImport.php b/src/Wallabag/ImportBundle/Import/InstapaperImport.php
index 70a53f1a..c8e0cd5b 100644
--- a/src/Wallabag/ImportBundle/Import/InstapaperImport.php
+++ b/src/Wallabag/ImportBundle/Import/InstapaperImport.php
@@ -68,6 +68,14 @@ class InstapaperImport extends AbstractImport
68 continue; 68 continue;
69 } 69 }
70 70
71 // last element in the csv is the folder where the content belong
72 // BUT it can also be the status (since status = folder in Instapaper)
73 // and we don't want archive, unread & starred to become a tag
74 $tags = null;
75 if (false === in_array($data[3], ['Archive', 'Unread', 'Starred'])) {
76 $tags = [$data[3]];
77 }
78
71 $entries[] = [ 79 $entries[] = [
72 'url' => $data[0], 80 'url' => $data[0],
73 'title' => $data[1], 81 'title' => $data[1],
@@ -75,6 +83,7 @@ class InstapaperImport extends AbstractImport
75 'is_archived' => $data[3] === 'Archive' || $data[3] === 'Starred', 83 'is_archived' => $data[3] === 'Archive' || $data[3] === 'Starred',
76 'is_starred' => $data[3] === 'Starred', 84 'is_starred' => $data[3] === 'Starred',
77 'html' => false, 85 'html' => false,
86 'tags' => $tags,
78 ]; 87 ];
79 } 88 }
80 fclose($handle); 89 fclose($handle);
@@ -118,6 +127,14 @@ class InstapaperImport extends AbstractImport
118 // update entry with content (in case fetching failed, the given entry will be return) 127 // update entry with content (in case fetching failed, the given entry will be return)
119 $entry = $this->fetchContent($entry, $importedEntry['url'], $importedEntry); 128 $entry = $this->fetchContent($entry, $importedEntry['url'], $importedEntry);
120 129
130 if (!empty($importedEntry['tags'])) {
131 $this->tagsAssigner->assignTagsToEntry(
132 $entry,
133 $importedEntry['tags'],
134 $this->em->getUnitOfWork()->getScheduledEntityInsertions()
135 );
136 }
137
121 $entry->setArchived($importedEntry['is_archived']); 138 $entry->setArchived($importedEntry['is_archived']);
122 $entry->setStarred($importedEntry['is_starred']); 139 $entry->setStarred($importedEntry['is_starred']);
123 140
diff --git a/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php b/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php
index b21f3318..284efac4 100644
--- a/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php
+++ b/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php
@@ -10,7 +10,7 @@ use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
10class ExportCommandTest extends WallabagCoreTestCase 10class ExportCommandTest extends WallabagCoreTestCase
11{ 11{
12 /** 12 /**
13 * @expectedException Symfony\Component\Console\Exception\RuntimeException 13 * @expectedException \Symfony\Component\Console\Exception\RuntimeException
14 * @expectedExceptionMessage Not enough arguments (missing: "username") 14 * @expectedExceptionMessage Not enough arguments (missing: "username")
15 */ 15 */
16 public function testExportCommandWithoutUsername() 16 public function testExportCommandWithoutUsername()
diff --git a/tests/Wallabag/CoreBundle/Command/TagAllCommandTest.php b/tests/Wallabag/CoreBundle/Command/TagAllCommandTest.php
index ec31708f..4cde3679 100644
--- a/tests/Wallabag/CoreBundle/Command/TagAllCommandTest.php
+++ b/tests/Wallabag/CoreBundle/Command/TagAllCommandTest.php
@@ -10,7 +10,7 @@ use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
10class TagAllCommandTest extends WallabagCoreTestCase 10class TagAllCommandTest extends WallabagCoreTestCase
11{ 11{
12 /** 12 /**
13 * @expectedException Symfony\Component\Console\Exception\RuntimeException 13 * @expectedException \Symfony\Component\Console\Exception\RuntimeException
14 * @expectedExceptionMessage Not enough arguments (missing: "username") 14 * @expectedExceptionMessage Not enough arguments (missing: "username")
15 */ 15 */
16 public function testRunTagAllCommandWithoutUsername() 16 public function testRunTagAllCommandWithoutUsername()
diff --git a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
index 77dfd5bf..44fca073 100644
--- a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
+++ b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
@@ -7,7 +7,6 @@ use Wallabag\CoreBundle\Helper\ContentProxy;
7use Wallabag\CoreBundle\Entity\Entry; 7use Wallabag\CoreBundle\Entity\Entry;
8use Wallabag\CoreBundle\Entity\Tag; 8use Wallabag\CoreBundle\Entity\Tag;
9use Wallabag\UserBundle\Entity\User; 9use Wallabag\UserBundle\Entity\User;
10use Wallabag\CoreBundle\Repository\TagRepository;
11use Wallabag\CoreBundle\Helper\RuleBasedTagger; 10use Wallabag\CoreBundle\Helper\RuleBasedTagger;
12 11
13class ContentProxyTest extends \PHPUnit_Framework_TestCase 12class ContentProxyTest extends \PHPUnit_Framework_TestCase
diff --git a/tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php b/tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php
index 2e6fccfb..ca8e0d50 100644
--- a/tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php
+++ b/tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php
@@ -136,7 +136,7 @@ class UsernameRssTokenConverterTest extends \PHPUnit_Framework_TestCase
136 } 136 }
137 137
138 /** 138 /**
139 * @expectedException Symfony\Component\HttpKernel\Exception\NotFoundHttpException 139 * @expectedException \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
140 * @expectedExceptionMessage User not found 140 * @expectedExceptionMessage User not found
141 */ 141 */
142 public function testApplyUserNotFound() 142 public function testApplyUserNotFound()
diff --git a/tests/Wallabag/ImportBundle/Command/RedisWorkerCommandTest.php b/tests/Wallabag/ImportBundle/Command/RedisWorkerCommandTest.php
index 74952847..e5e251a0 100644
--- a/tests/Wallabag/ImportBundle/Command/RedisWorkerCommandTest.php
+++ b/tests/Wallabag/ImportBundle/Command/RedisWorkerCommandTest.php
@@ -11,7 +11,7 @@ use M6Web\Component\RedisMock\RedisMockFactory;
11class RedisWorkerCommandTest extends WallabagCoreTestCase 11class RedisWorkerCommandTest extends WallabagCoreTestCase
12{ 12{
13 /** 13 /**
14 * @expectedException Symfony\Component\Console\Exception\RuntimeException 14 * @expectedException \Symfony\Component\Console\Exception\RuntimeException
15 * @expectedExceptionMessage Not enough arguments (missing: "serviceName") 15 * @expectedExceptionMessage Not enough arguments (missing: "serviceName")
16 */ 16 */
17 public function testRunRedisWorkerCommandWithoutArguments() 17 public function testRunRedisWorkerCommandWithoutArguments()
@@ -28,7 +28,7 @@ class RedisWorkerCommandTest extends WallabagCoreTestCase
28 } 28 }
29 29
30 /** 30 /**
31 * @expectedException Symfony\Component\Config\Definition\Exception\Exception 31 * @expectedException \Symfony\Component\Config\Definition\Exception\Exception
32 * @expectedExceptionMessage No queue or consumer found for service name 32 * @expectedExceptionMessage No queue or consumer found for service name
33 */ 33 */
34 public function testRunRedisWorkerCommandWithBadService() 34 public function testRunRedisWorkerCommandWithBadService()
diff --git a/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php b/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php
index c2e5fdb7..84742e0a 100644
--- a/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php
@@ -107,6 +107,9 @@ class InstapaperControllerTest extends WallabagCoreTestCase
107 107
108 $crawler = $client->followRedirect(); 108 $crawler = $client->followRedirect();
109 109
110 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
111 $this->assertContains('flashes.import.notice.summary', $body[0]);
112
110 $content = $client->getContainer() 113 $content = $client->getContainer()
111 ->get('doctrine.orm.entity_manager') 114 ->get('doctrine.orm.entity_manager')
112 ->getRepository('WallabagCoreBundle:Entry') 115 ->getRepository('WallabagCoreBundle:Entry')
@@ -115,14 +118,25 @@ class InstapaperControllerTest extends WallabagCoreTestCase
115 $this->getLoggedInUserId() 118 $this->getLoggedInUserId()
116 ); 119 );
117 120
118 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
119 $this->assertContains('flashes.import.notice.summary', $body[0]);
120
121 $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.liberation.fr is ok'); 121 $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.liberation.fr is ok');
122 $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.liberation.fr is ok'); 122 $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.liberation.fr is ok');
123 $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.liberation.fr is ok'); 123 $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.liberation.fr is ok');
124 $this->assertContains('foot', $content->getTags(), 'It includes the "foot" tag');
124 $this->assertEquals(1, count($content->getTags())); 125 $this->assertEquals(1, count($content->getTags()));
125 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); 126 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
127
128 $content = $client->getContainer()
129 ->get('doctrine.orm.entity_manager')
130 ->getRepository('WallabagCoreBundle:Entry')
131 ->findByUrlAndUserId(
132 'http://www.20minutes.fr/high-tech/2077615-20170531-dis-donc-donald-trump-quoi-exactement-covfefe',
133 $this->getLoggedInUserId()
134 );
135
136 $this->assertContains('foot', $content->getTags());
137 $this->assertContains('test_tag', $content->getTags());
138
139 $this->assertEquals(2, count($content->getTags()));
126 } 140 }
127 141
128 public function testImportInstapaperWithFileAndMarkAllAsRead() 142 public function testImportInstapaperWithFileAndMarkAllAsRead()
diff --git a/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php b/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php
index 96b32484..e2b6e7b6 100644
--- a/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php
@@ -121,7 +121,13 @@ class PinboardControllerTest extends WallabagCoreTestCase
121 $this->assertNotEmpty($content->getMimetype(), 'Mimetype for https://ma.ttias.be is ok'); 121 $this->assertNotEmpty($content->getMimetype(), 'Mimetype for https://ma.ttias.be is ok');
122 $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://ma.ttias.be is ok'); 122 $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://ma.ttias.be is ok');
123 $this->assertNotEmpty($content->getLanguage(), 'Language for https://ma.ttias.be is ok'); 123 $this->assertNotEmpty($content->getLanguage(), 'Language for https://ma.ttias.be is ok');
124 $this->assertEquals(3, count($content->getTags())); 124
125 $tags = $content->getTags();
126 $this->assertContains('foot', $tags, 'It includes the "foot" tag');
127 $this->assertContains('varnish', $tags, 'It includes the "varnish" tag');
128 $this->assertContains('PHP', $tags, 'It includes the "PHP" tag');
129 $this->assertEquals(3, count($tags));
130
125 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); 131 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
126 $this->assertEquals('2016-10-26', $content->getCreatedAt()->format('Y-m-d')); 132 $this->assertEquals('2016-10-26', $content->getCreatedAt()->format('Y-m-d'));
127 } 133 }
diff --git a/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php b/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php
index e6d33fe9..bde0a600 100644
--- a/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php
@@ -121,7 +121,11 @@ class ReadabilityControllerTest extends WallabagCoreTestCase
121 $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.zataz.com is ok'); 121 $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.zataz.com is ok');
122 $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.zataz.com is ok'); 122 $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.zataz.com is ok');
123 $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.zataz.com is ok'); 123 $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.zataz.com is ok');
124 $this->assertEquals(1, count($content->getTags())); 124
125 $tags = $content->getTags();
126 $this->assertContains('foot', $tags, 'It includes the "foot" tag');
127 $this->assertEquals(1, count($tags));
128
125 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); 129 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
126 $this->assertEquals('2016-09-08', $content->getCreatedAt()->format('Y-m-d')); 130 $this->assertEquals('2016-09-08', $content->getCreatedAt()->format('Y-m-d'));
127 } 131 }
diff --git a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php
index 0c7f97ed..4ca6e623 100644
--- a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php
@@ -116,20 +116,18 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
116 $this->getLoggedInUserId() 116 $this->getLoggedInUserId()
117 ); 117 );
118 118
119 $tag = $client->getContainer()
120 ->get('doctrine.orm.entity_manager')
121 ->getRepository('WallabagCoreBundle:Tag')
122 ->findOneByLabel('Framabag');
123
124 $this->assertTrue($content->getTags()->contains($tag));
125
126 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); 119 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
127 $this->assertContains('flashes.import.notice.summary', $body[0]); 120 $this->assertContains('flashes.import.notice.summary', $body[0]);
128 121
129 $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.framablog.org is ok'); 122 $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.framablog.org is ok');
130 $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.framablog.org is ok'); 123 $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.framablog.org is ok');
131 $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.framablog.org is ok'); 124 $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.framablog.org is ok');
132 $this->assertEquals(2, count($content->getTags())); 125
126 $tags = $content->getTags();
127 $this->assertContains('foot', $tags, 'It includes the "foot" tag');
128 $this->assertContains('Framabag', $tags, 'It includes the "Framabag" tag');
129 $this->assertEquals(2, count($tags));
130
133 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); 131 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
134 } 132 }
135 133
diff --git a/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php b/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php
index 335115fe..18a02522 100644
--- a/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php
@@ -122,7 +122,10 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
122 $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.liberation.fr is ok'); 122 $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://www.liberation.fr is ok');
123 $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.liberation.fr is ok'); 123 $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.liberation.fr is ok');
124 $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.liberation.fr is ok'); 124 $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.liberation.fr is ok');
125 $this->assertEquals(1, count($content->getTags())); 125
126 $tags = $content->getTags();
127 $this->assertContains('foot', $tags, 'It includes the "foot" tag');
128 $this->assertEquals(1, count($tags));
126 129
127 $content = $client->getContainer() 130 $content = $client->getContainer()
128 ->get('doctrine.orm.entity_manager') 131 ->get('doctrine.orm.entity_manager')
@@ -135,7 +138,13 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
135 $this->assertNotEmpty($content->getMimetype(), 'Mimetype for https://www.mediapart.fr is ok'); 138 $this->assertNotEmpty($content->getMimetype(), 'Mimetype for https://www.mediapart.fr is ok');
136 $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://www.mediapart.fr is ok'); 139 $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for https://www.mediapart.fr is ok');
137 $this->assertNotEmpty($content->getLanguage(), 'Language for https://www.mediapart.fr is ok'); 140 $this->assertNotEmpty($content->getLanguage(), 'Language for https://www.mediapart.fr is ok');
138 $this->assertEquals(3, count($content->getTags())); 141
142 $tags = $content->getTags();
143 $this->assertContains('foot', $tags, 'It includes the "foot" tag');
144 $this->assertContains('mediapart', $tags, 'It includes the "mediapart" tag');
145 $this->assertContains('blog', $tags, 'It includes the "blog" tag');
146 $this->assertEquals(3, count($tags));
147
139 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); 148 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
140 $this->assertEquals('2016-09-08', $content->getCreatedAt()->format('Y-m-d')); 149 $this->assertEquals('2016-09-08', $content->getCreatedAt()->format('Y-m-d'));
141 $this->assertTrue($content->isStarred(), 'Entry is starred'); 150 $this->assertTrue($content->isStarred(), 'Entry is starred');
diff --git a/tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php b/tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php
index 6777a02e..9158c8a2 100644
--- a/tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php
+++ b/tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php
@@ -18,6 +18,7 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase
18 protected $logHandler; 18 protected $logHandler;
19 protected $contentProxy; 19 protected $contentProxy;
20 protected $tagsAssigner; 20 protected $tagsAssigner;
21 protected $uow;
21 22
22 private function getInstapaperImport($unsetUser = false, $dispatched = 0) 23 private function getInstapaperImport($unsetUser = false, $dispatched = 0)
23 { 24 {
@@ -27,6 +28,20 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase
27 ->disableOriginalConstructor() 28 ->disableOriginalConstructor()
28 ->getMock(); 29 ->getMock();
29 30
31 $this->uow = $this->getMockBuilder('Doctrine\ORM\UnitOfWork')
32 ->disableOriginalConstructor()
33 ->getMock();
34
35 $this->em
36 ->expects($this->any())
37 ->method('getUnitOfWork')
38 ->willReturn($this->uow);
39
40 $this->uow
41 ->expects($this->any())
42 ->method('getScheduledEntityInsertions')
43 ->willReturn([]);
44
30 $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy') 45 $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy')
31 ->disableOriginalConstructor() 46 ->disableOriginalConstructor()
32 ->getMock(); 47 ->getMock();
@@ -67,14 +82,14 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase
67 82
68 public function testImport() 83 public function testImport()
69 { 84 {
70 $instapaperImport = $this->getInstapaperImport(false, 3); 85 $instapaperImport = $this->getInstapaperImport(false, 4);
71 $instapaperImport->setFilepath(__DIR__.'/../fixtures/instapaper-export.csv'); 86 $instapaperImport->setFilepath(__DIR__.'/../fixtures/instapaper-export.csv');
72 87
73 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 88 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
74 ->disableOriginalConstructor() 89 ->disableOriginalConstructor()
75 ->getMock(); 90 ->getMock();
76 91
77 $entryRepo->expects($this->exactly(3)) 92 $entryRepo->expects($this->exactly(4))
78 ->method('findByUrlAndUserId') 93 ->method('findByUrlAndUserId')
79 ->willReturn(false); 94 ->willReturn(false);
80 95
@@ -88,14 +103,14 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase
88 ->getMock(); 103 ->getMock();
89 104
90 $this->contentProxy 105 $this->contentProxy
91 ->expects($this->exactly(3)) 106 ->expects($this->exactly(4))
92 ->method('updateEntry') 107 ->method('updateEntry')
93 ->willReturn($entry); 108 ->willReturn($entry);
94 109
95 $res = $instapaperImport->import(); 110 $res = $instapaperImport->import();
96 111
97 $this->assertTrue($res); 112 $this->assertTrue($res);
98 $this->assertEquals(['skipped' => 0, 'imported' => 3, 'queued' => 0], $instapaperImport->getSummary()); 113 $this->assertEquals(['skipped' => 0, 'imported' => 4, 'queued' => 0], $instapaperImport->getSummary());
99 } 114 }
100 115
101 public function testImportAndMarkAllAsRead() 116 public function testImportAndMarkAllAsRead()
@@ -107,9 +122,9 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase
107 ->disableOriginalConstructor() 122 ->disableOriginalConstructor()
108 ->getMock(); 123 ->getMock();
109 124
110 $entryRepo->expects($this->exactly(3)) 125 $entryRepo->expects($this->exactly(4))
111 ->method('findByUrlAndUserId') 126 ->method('findByUrlAndUserId')
112 ->will($this->onConsecutiveCalls(false, true, true)); 127 ->will($this->onConsecutiveCalls(false, true, true, true));
113 128
114 $this->em 129 $this->em
115 ->expects($this->any()) 130 ->expects($this->any())
@@ -133,7 +148,7 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase
133 148
134 $this->assertTrue($res); 149 $this->assertTrue($res);
135 150
136 $this->assertEquals(['skipped' => 2, 'imported' => 1, 'queued' => 0], $instapaperImport->getSummary()); 151 $this->assertEquals(['skipped' => 3, 'imported' => 1, 'queued' => 0], $instapaperImport->getSummary());
137 } 152 }
138 153
139 public function testImportWithRabbit() 154 public function testImportWithRabbit()
@@ -165,7 +180,7 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase
165 ->getMock(); 180 ->getMock();
166 181
167 $producer 182 $producer
168 ->expects($this->exactly(3)) 183 ->expects($this->exactly(4))
169 ->method('publish'); 184 ->method('publish');
170 185
171 $instapaperImport->setProducer($producer); 186 $instapaperImport->setProducer($producer);
@@ -173,7 +188,7 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase
173 $res = $instapaperImport->setMarkAsRead(true)->import(); 188 $res = $instapaperImport->setMarkAsRead(true)->import();
174 189
175 $this->assertTrue($res); 190 $this->assertTrue($res);
176 $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 3], $instapaperImport->getSummary()); 191 $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 4], $instapaperImport->getSummary());
177 } 192 }
178 193
179 public function testImportWithRedis() 194 public function testImportWithRedis()
@@ -211,7 +226,7 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase
211 $res = $instapaperImport->setMarkAsRead(true)->import(); 226 $res = $instapaperImport->setMarkAsRead(true)->import();
212 227
213 $this->assertTrue($res); 228 $this->assertTrue($res);
214 $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 3], $instapaperImport->getSummary()); 229 $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 4], $instapaperImport->getSummary());
215 230
216 $this->assertNotEmpty($redisMock->lpop('instapaper')); 231 $this->assertNotEmpty($redisMock->lpop('instapaper'));
217 } 232 }
diff --git a/tests/Wallabag/ImportBundle/fixtures/instapaper-export.csv b/tests/Wallabag/ImportBundle/fixtures/instapaper-export.csv
index 28a4c8e6..1a648f8a 100644
--- a/tests/Wallabag/ImportBundle/fixtures/instapaper-export.csv
+++ b/tests/Wallabag/ImportBundle/fixtures/instapaper-export.csv
@@ -2,3 +2,4 @@ URL,Title,Selection,Folder
2http://www.liberation.fr/societe/2012/12/06/baumettes-un-tour-en-cellule_865551,Baumettes : un tour en cellule,,Unread 2http://www.liberation.fr/societe/2012/12/06/baumettes-un-tour-en-cellule_865551,Baumettes : un tour en cellule,,Unread
3https://redditblog.com/2016/09/20/amp-and-reactredux/,AMP and React+Redux: Why Not?,,Archive 3https://redditblog.com/2016/09/20/amp-and-reactredux/,AMP and React+Redux: Why Not?,,Archive
4https://medium.com/@the_minh/why-foursquare-swarm-is-still-my-favourite-social-network-e38228493e6c,Why Foursquare / Swarm is still my favourite social network,,Starred 4https://medium.com/@the_minh/why-foursquare-swarm-is-still-my-favourite-social-network-e38228493e6c,Why Foursquare / Swarm is still my favourite social network,,Starred
5http://www.20minutes.fr/high-tech/2077615-20170531-dis-donc-donald-trump-quoi-exactement-covfefe,"Dis donc Donald Trump, c'est quoi exactement «covfefe»?",,test_tag