aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/ImportBundle
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2017-07-01 09:52:38 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2017-07-01 09:52:38 +0200
commitf808b01692a835673f328d7221ba8c212caa9b61 (patch)
tree0c3b1fc5b1ddbd7af72227303503177689e1d403 /tests/Wallabag/ImportBundle
parent822c877949aff8ae57677671115f8f4fc69588d5 (diff)
downloadwallabag-f808b01692a835673f328d7221ba8c212caa9b61.tar.gz
wallabag-f808b01692a835673f328d7221ba8c212caa9b61.tar.zst
wallabag-f808b01692a835673f328d7221ba8c212caa9b61.zip
Add a real configuration for CS-Fixer
Diffstat (limited to 'tests/Wallabag/ImportBundle')
-rw-r--r--tests/Wallabag/ImportBundle/Command/ImportCommandTest.php6
-rw-r--r--tests/Wallabag/ImportBundle/Command/RedisWorkerCommandTest.php4
-rw-r--r--tests/Wallabag/ImportBundle/Consumer/AMQPEntryConsumerTest.php4
-rw-r--r--tests/Wallabag/ImportBundle/Consumer/RedisEntryConsumerTest.php2
-rw-r--r--tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php40
-rw-r--r--tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php40
-rw-r--r--tests/Wallabag/ImportBundle/Controller/ImportControllerTest.php6
-rw-r--r--tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php42
-rw-r--r--tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php42
-rw-r--r--tests/Wallabag/ImportBundle/Controller/PocketControllerTest.php24
-rw-r--r--tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php42
-rw-r--r--tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php40
-rw-r--r--tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php40
-rw-r--r--tests/Wallabag/ImportBundle/Import/ChromeImportTest.php114
-rw-r--r--tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php114
-rw-r--r--tests/Wallabag/ImportBundle/Import/ImportChainTest.php2
-rw-r--r--tests/Wallabag/ImportBundle/Import/ImportCompilerPassTest.php2
-rw-r--r--tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php142
-rw-r--r--tests/Wallabag/ImportBundle/Import/PocketImportTest.php150
-rw-r--r--tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php114
-rw-r--r--tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php156
-rw-r--r--tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php150
22 files changed, 638 insertions, 638 deletions
diff --git a/tests/Wallabag/ImportBundle/Command/ImportCommandTest.php b/tests/Wallabag/ImportBundle/Command/ImportCommandTest.php
index f507563c..8bed180a 100644
--- a/tests/Wallabag/ImportBundle/Command/ImportCommandTest.php
+++ b/tests/Wallabag/ImportBundle/Command/ImportCommandTest.php
@@ -4,8 +4,8 @@ namespace Tests\Wallabag\ImportBundle\Command;
4 4
5use Symfony\Bundle\FrameworkBundle\Console\Application; 5use Symfony\Bundle\FrameworkBundle\Console\Application;
6use Symfony\Component\Console\Tester\CommandTester; 6use Symfony\Component\Console\Tester\CommandTester;
7use Wallabag\ImportBundle\Command\ImportCommand;
8use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; 7use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
8use Wallabag\ImportBundle\Command\ImportCommand;
9 9
10class ImportCommandTest extends WallabagCoreTestCase 10class ImportCommandTest extends WallabagCoreTestCase
11{ 11{
@@ -74,7 +74,7 @@ class ImportCommandTest extends WallabagCoreTestCase
74 $tester->execute([ 74 $tester->execute([
75 'command' => $command->getName(), 75 'command' => $command->getName(),
76 'username' => 'admin', 76 'username' => 'admin',
77 'filepath' => $application->getKernel()->getContainer()->getParameter('kernel.root_dir').'/../tests/Wallabag/ImportBundle/fixtures/wallabag-v2-read.json', 77 'filepath' => $application->getKernel()->getContainer()->getParameter('kernel.root_dir') . '/../tests/Wallabag/ImportBundle/fixtures/wallabag-v2-read.json',
78 '--importer' => 'v2', 78 '--importer' => 'v2',
79 ]); 79 ]);
80 80
@@ -93,7 +93,7 @@ class ImportCommandTest extends WallabagCoreTestCase
93 $tester->execute([ 93 $tester->execute([
94 'command' => $command->getName(), 94 'command' => $command->getName(),
95 'username' => 1, 95 'username' => 1,
96 'filepath' => $application->getKernel()->getContainer()->getParameter('kernel.root_dir').'/../tests/Wallabag/ImportBundle/fixtures/wallabag-v2-read.json', 96 'filepath' => $application->getKernel()->getContainer()->getParameter('kernel.root_dir') . '/../tests/Wallabag/ImportBundle/fixtures/wallabag-v2-read.json',
97 '--useUserId' => true, 97 '--useUserId' => true,
98 '--importer' => 'v2', 98 '--importer' => 'v2',
99 ]); 99 ]);
diff --git a/tests/Wallabag/ImportBundle/Command/RedisWorkerCommandTest.php b/tests/Wallabag/ImportBundle/Command/RedisWorkerCommandTest.php
index e5e251a0..af62550c 100644
--- a/tests/Wallabag/ImportBundle/Command/RedisWorkerCommandTest.php
+++ b/tests/Wallabag/ImportBundle/Command/RedisWorkerCommandTest.php
@@ -2,11 +2,11 @@
2 2
3namespace Tests\Wallabag\ImportBundle\Command; 3namespace Tests\Wallabag\ImportBundle\Command;
4 4
5use M6Web\Component\RedisMock\RedisMockFactory;
5use Symfony\Bundle\FrameworkBundle\Console\Application; 6use Symfony\Bundle\FrameworkBundle\Console\Application;
6use Symfony\Component\Console\Tester\CommandTester; 7use Symfony\Component\Console\Tester\CommandTester;
7use Wallabag\ImportBundle\Command\RedisWorkerCommand;
8use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; 8use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
9use M6Web\Component\RedisMock\RedisMockFactory; 9use Wallabag\ImportBundle\Command\RedisWorkerCommand;
10 10
11class RedisWorkerCommandTest extends WallabagCoreTestCase 11class RedisWorkerCommandTest extends WallabagCoreTestCase
12{ 12{
diff --git a/tests/Wallabag/ImportBundle/Consumer/AMQPEntryConsumerTest.php b/tests/Wallabag/ImportBundle/Consumer/AMQPEntryConsumerTest.php
index a989ec7f..52b98a0b 100644
--- a/tests/Wallabag/ImportBundle/Consumer/AMQPEntryConsumerTest.php
+++ b/tests/Wallabag/ImportBundle/Consumer/AMQPEntryConsumerTest.php
@@ -2,10 +2,10 @@
2 2
3namespace Tests\Wallabag\ImportBundle\Consumer\AMQP; 3namespace Tests\Wallabag\ImportBundle\Consumer\AMQP;
4 4
5use Wallabag\ImportBundle\Consumer\AMQPEntryConsumer;
6use PhpAmqpLib\Message\AMQPMessage; 5use PhpAmqpLib\Message\AMQPMessage;
7use Wallabag\UserBundle\Entity\User;
8use Wallabag\CoreBundle\Entity\Entry; 6use Wallabag\CoreBundle\Entity\Entry;
7use Wallabag\ImportBundle\Consumer\AMQPEntryConsumer;
8use Wallabag\UserBundle\Entity\User;
9 9
10class AMQPEntryConsumerTest extends \PHPUnit_Framework_TestCase 10class AMQPEntryConsumerTest extends \PHPUnit_Framework_TestCase
11{ 11{
diff --git a/tests/Wallabag/ImportBundle/Consumer/RedisEntryConsumerTest.php b/tests/Wallabag/ImportBundle/Consumer/RedisEntryConsumerTest.php
index 78bd83ba..9506ff63 100644
--- a/tests/Wallabag/ImportBundle/Consumer/RedisEntryConsumerTest.php
+++ b/tests/Wallabag/ImportBundle/Consumer/RedisEntryConsumerTest.php
@@ -2,9 +2,9 @@
2 2
3namespace Tests\Wallabag\ImportBundle\Consumer\AMQP; 3namespace Tests\Wallabag\ImportBundle\Consumer\AMQP;
4 4
5use Wallabag\CoreBundle\Entity\Entry;
5use Wallabag\ImportBundle\Consumer\RedisEntryConsumer; 6use Wallabag\ImportBundle\Consumer\RedisEntryConsumer;
6use Wallabag\UserBundle\Entity\User; 7use Wallabag\UserBundle\Entity\User;
7use Wallabag\CoreBundle\Entity\Entry;
8 8
9class RedisEntryConsumerTest extends \PHPUnit_Framework_TestCase 9class RedisEntryConsumerTest extends \PHPUnit_Framework_TestCase
10{ 10{
diff --git a/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php b/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php
index 8e9f65e3..3873ccf4 100644
--- a/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/ChromeControllerTest.php
@@ -2,8 +2,8 @@
2 2
3namespace Tests\Wallabag\ImportBundle\Controller; 3namespace Tests\Wallabag\ImportBundle\Controller;
4 4
5use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
6use Symfony\Component\HttpFoundation\File\UploadedFile; 5use Symfony\Component\HttpFoundation\File\UploadedFile;
6use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
7 7
8class ChromeControllerTest extends WallabagCoreTestCase 8class ChromeControllerTest extends WallabagCoreTestCase
9{ 9{
@@ -14,9 +14,9 @@ class ChromeControllerTest extends WallabagCoreTestCase
14 14
15 $crawler = $client->request('GET', '/import/chrome'); 15 $crawler = $client->request('GET', '/import/chrome');
16 16
17 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 17 $this->assertSame(200, $client->getResponse()->getStatusCode());
18 $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); 18 $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
19 $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); 19 $this->assertSame(1, $crawler->filter('input[type=file]')->count());
20 } 20 }
21 21
22 public function testImportChromeWithRabbitEnabled() 22 public function testImportChromeWithRabbitEnabled()
@@ -28,9 +28,9 @@ class ChromeControllerTest extends WallabagCoreTestCase
28 28
29 $crawler = $client->request('GET', '/import/chrome'); 29 $crawler = $client->request('GET', '/import/chrome');
30 30
31 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 31 $this->assertSame(200, $client->getResponse()->getStatusCode());
32 $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); 32 $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
33 $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); 33 $this->assertSame(1, $crawler->filter('input[type=file]')->count());
34 34
35 $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0); 35 $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0);
36 } 36 }
@@ -49,7 +49,7 @@ class ChromeControllerTest extends WallabagCoreTestCase
49 49
50 $client->submit($form, $data); 50 $client->submit($form, $data);
51 51
52 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 52 $this->assertSame(200, $client->getResponse()->getStatusCode());
53 } 53 }
54 54
55 public function testImportChromeWithRedisEnabled() 55 public function testImportChromeWithRedisEnabled()
@@ -61,13 +61,13 @@ class ChromeControllerTest extends WallabagCoreTestCase
61 61
62 $crawler = $client->request('GET', '/import/chrome'); 62 $crawler = $client->request('GET', '/import/chrome');
63 63
64 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 64 $this->assertSame(200, $client->getResponse()->getStatusCode());
65 $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); 65 $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
66 $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); 66 $this->assertSame(1, $crawler->filter('input[type=file]')->count());
67 67
68 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 68 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
69 69
70 $file = new UploadedFile(__DIR__.'/../fixtures/chrome-bookmarks', 'Bookmarks'); 70 $file = new UploadedFile(__DIR__ . '/../fixtures/chrome-bookmarks', 'Bookmarks');
71 71
72 $data = [ 72 $data = [
73 'upload_import_file[file]' => $file, 73 'upload_import_file[file]' => $file,
@@ -75,7 +75,7 @@ class ChromeControllerTest extends WallabagCoreTestCase
75 75
76 $client->submit($form, $data); 76 $client->submit($form, $data);
77 77
78 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 78 $this->assertSame(302, $client->getResponse()->getStatusCode());
79 79
80 $crawler = $client->followRedirect(); 80 $crawler = $client->followRedirect();
81 81
@@ -95,7 +95,7 @@ class ChromeControllerTest extends WallabagCoreTestCase
95 $crawler = $client->request('GET', '/import/chrome'); 95 $crawler = $client->request('GET', '/import/chrome');
96 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 96 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
97 97
98 $file = new UploadedFile(__DIR__.'/../fixtures/chrome-bookmarks', 'Bookmarks'); 98 $file = new UploadedFile(__DIR__ . '/../fixtures/chrome-bookmarks', 'Bookmarks');
99 99
100 $data = [ 100 $data = [
101 'upload_import_file[file]' => $file, 101 'upload_import_file[file]' => $file,
@@ -103,7 +103,7 @@ class ChromeControllerTest extends WallabagCoreTestCase
103 103
104 $client->submit($form, $data); 104 $client->submit($form, $data);
105 105
106 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 106 $this->assertSame(302, $client->getResponse()->getStatusCode());
107 107
108 $crawler = $client->followRedirect(); 108 $crawler = $client->followRedirect();
109 109
@@ -120,11 +120,11 @@ class ChromeControllerTest extends WallabagCoreTestCase
120 120
121 $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.usinenouvelle.com is ok'); 121 $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://www.usinenouvelle.com is ok');
122 $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.usinenouvelle.com is ok'); 122 $this->assertNotEmpty($content->getLanguage(), 'Language for http://www.usinenouvelle.com is ok');
123 $this->assertEquals(1, count($content->getTags())); 123 $this->assertSame(1, count($content->getTags()));
124 124
125 $createdAt = $content->getCreatedAt(); 125 $createdAt = $content->getCreatedAt();
126 $this->assertEquals('2011', $createdAt->format('Y')); 126 $this->assertSame('2011', $createdAt->format('Y'));
127 $this->assertEquals('07', $createdAt->format('m')); 127 $this->assertSame('07', $createdAt->format('m'));
128 } 128 }
129 129
130 public function testImportWallabagWithEmptyFile() 130 public function testImportWallabagWithEmptyFile()
@@ -135,7 +135,7 @@ class ChromeControllerTest extends WallabagCoreTestCase
135 $crawler = $client->request('GET', '/import/chrome'); 135 $crawler = $client->request('GET', '/import/chrome');
136 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 136 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
137 137
138 $file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt'); 138 $file = new UploadedFile(__DIR__ . '/../fixtures/test.txt', 'test.txt');
139 139
140 $data = [ 140 $data = [
141 'upload_import_file[file]' => $file, 141 'upload_import_file[file]' => $file,
@@ -143,7 +143,7 @@ class ChromeControllerTest extends WallabagCoreTestCase
143 143
144 $client->submit($form, $data); 144 $client->submit($form, $data);
145 145
146 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 146 $this->assertSame(302, $client->getResponse()->getStatusCode());
147 147
148 $crawler = $client->followRedirect(); 148 $crawler = $client->followRedirect();
149 149
diff --git a/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php b/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php
index 5354439c..5e1260b1 100644
--- a/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/FirefoxControllerTest.php
@@ -2,8 +2,8 @@
2 2
3namespace Tests\Wallabag\ImportBundle\Controller; 3namespace Tests\Wallabag\ImportBundle\Controller;
4 4
5use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
6use Symfony\Component\HttpFoundation\File\UploadedFile; 5use Symfony\Component\HttpFoundation\File\UploadedFile;
6use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
7 7
8class FirefoxControllerTest extends WallabagCoreTestCase 8class FirefoxControllerTest extends WallabagCoreTestCase
9{ 9{
@@ -14,9 +14,9 @@ class FirefoxControllerTest extends WallabagCoreTestCase
14 14
15 $crawler = $client->request('GET', '/import/firefox'); 15 $crawler = $client->request('GET', '/import/firefox');
16 16
17 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 17 $this->assertSame(200, $client->getResponse()->getStatusCode());
18 $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); 18 $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
19 $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); 19 $this->assertSame(1, $crawler->filter('input[type=file]')->count());
20 } 20 }
21 21
22 public function testImportFirefoxWithRabbitEnabled() 22 public function testImportFirefoxWithRabbitEnabled()
@@ -28,9 +28,9 @@ class FirefoxControllerTest extends WallabagCoreTestCase
28 28
29 $crawler = $client->request('GET', '/import/firefox'); 29 $crawler = $client->request('GET', '/import/firefox');
30 30
31 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 31 $this->assertSame(200, $client->getResponse()->getStatusCode());
32 $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); 32 $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
33 $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); 33 $this->assertSame(1, $crawler->filter('input[type=file]')->count());
34 34
35 $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0); 35 $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0);
36 } 36 }
@@ -49,7 +49,7 @@ class FirefoxControllerTest extends WallabagCoreTestCase
49 49
50 $client->submit($form, $data); 50 $client->submit($form, $data);
51 51
52 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 52 $this->assertSame(200, $client->getResponse()->getStatusCode());
53 } 53 }
54 54
55 public function testImportFirefoxWithRedisEnabled() 55 public function testImportFirefoxWithRedisEnabled()
@@ -61,13 +61,13 @@ class FirefoxControllerTest extends WallabagCoreTestCase
61 61
62 $crawler = $client->request('GET', '/import/firefox'); 62 $crawler = $client->request('GET', '/import/firefox');
63 63
64 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 64 $this->assertSame(200, $client->getResponse()->getStatusCode());
65 $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); 65 $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
66 $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); 66 $this->assertSame(1, $crawler->filter('input[type=file]')->count());
67 67
68 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 68 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
69 69
70 $file = new UploadedFile(__DIR__.'/../fixtures/firefox-bookmarks.json', 'Bookmarks'); 70 $file = new UploadedFile(__DIR__ . '/../fixtures/firefox-bookmarks.json', 'Bookmarks');
71 71
72 $data = [ 72 $data = [
73 'upload_import_file[file]' => $file, 73 'upload_import_file[file]' => $file,
@@ -75,7 +75,7 @@ class FirefoxControllerTest extends WallabagCoreTestCase
75 75
76 $client->submit($form, $data); 76 $client->submit($form, $data);
77 77
78 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 78 $this->assertSame(302, $client->getResponse()->getStatusCode());
79 79
80 $crawler = $client->followRedirect(); 80 $crawler = $client->followRedirect();
81 81
@@ -95,7 +95,7 @@ class FirefoxControllerTest extends WallabagCoreTestCase
95 $crawler = $client->request('GET', '/import/firefox'); 95 $crawler = $client->request('GET', '/import/firefox');
96 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 96 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
97 97
98 $file = new UploadedFile(__DIR__.'/../fixtures/firefox-bookmarks.json', 'Bookmarks'); 98 $file = new UploadedFile(__DIR__ . '/../fixtures/firefox-bookmarks.json', 'Bookmarks');
99 99
100 $data = [ 100 $data = [
101 'upload_import_file[file]' => $file, 101 'upload_import_file[file]' => $file,
@@ -103,7 +103,7 @@ class FirefoxControllerTest extends WallabagCoreTestCase
103 103
104 $client->submit($form, $data); 104 $client->submit($form, $data);
105 105
106 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 106 $this->assertSame(302, $client->getResponse()->getStatusCode());
107 107
108 $crawler = $client->followRedirect(); 108 $crawler = $client->followRedirect();
109 109
@@ -121,7 +121,7 @@ class FirefoxControllerTest extends WallabagCoreTestCase
121 $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://lexpansion.lexpress.fr is ok'); 121 $this->assertNotEmpty($content->getMimetype(), 'Mimetype for http://lexpansion.lexpress.fr is ok');
122 $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://lexpansion.lexpress.fr is ok'); 122 $this->assertNotEmpty($content->getPreviewPicture(), 'Preview picture for http://lexpansion.lexpress.fr is ok');
123 $this->assertNotEmpty($content->getLanguage(), 'Language for http://lexpansion.lexpress.fr is ok'); 123 $this->assertNotEmpty($content->getLanguage(), 'Language for http://lexpansion.lexpress.fr is ok');
124 $this->assertEquals(3, count($content->getTags())); 124 $this->assertSame(3, count($content->getTags()));
125 125
126 $content = $client->getContainer() 126 $content = $client->getContainer()
127 ->get('doctrine.orm.entity_manager') 127 ->get('doctrine.orm.entity_manager')
@@ -136,8 +136,8 @@ class FirefoxControllerTest extends WallabagCoreTestCase
136 $this->assertEmpty($content->getLanguage(), 'Language for https://stackoverflow.com is ok'); 136 $this->assertEmpty($content->getLanguage(), 'Language for https://stackoverflow.com is ok');
137 137
138 $createdAt = $content->getCreatedAt(); 138 $createdAt = $content->getCreatedAt();
139 $this->assertEquals('2013', $createdAt->format('Y')); 139 $this->assertSame('2013', $createdAt->format('Y'));
140 $this->assertEquals('12', $createdAt->format('m')); 140 $this->assertSame('12', $createdAt->format('m'));
141 } 141 }
142 142
143 public function testImportWallabagWithEmptyFile() 143 public function testImportWallabagWithEmptyFile()
@@ -148,7 +148,7 @@ class FirefoxControllerTest extends WallabagCoreTestCase
148 $crawler = $client->request('GET', '/import/firefox'); 148 $crawler = $client->request('GET', '/import/firefox');
149 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 149 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
150 150
151 $file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt'); 151 $file = new UploadedFile(__DIR__ . '/../fixtures/test.txt', 'test.txt');
152 152
153 $data = [ 153 $data = [
154 'upload_import_file[file]' => $file, 154 'upload_import_file[file]' => $file,
@@ -156,7 +156,7 @@ class FirefoxControllerTest extends WallabagCoreTestCase
156 156
157 $client->submit($form, $data); 157 $client->submit($form, $data);
158 158
159 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 159 $this->assertSame(302, $client->getResponse()->getStatusCode());
160 160
161 $crawler = $client->followRedirect(); 161 $crawler = $client->followRedirect();
162 162
diff --git a/tests/Wallabag/ImportBundle/Controller/ImportControllerTest.php b/tests/Wallabag/ImportBundle/Controller/ImportControllerTest.php
index 5e57dcef..e1ec7c65 100644
--- a/tests/Wallabag/ImportBundle/Controller/ImportControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/ImportControllerTest.php
@@ -12,7 +12,7 @@ class ImportControllerTest extends WallabagCoreTestCase
12 12
13 $client->request('GET', '/import/'); 13 $client->request('GET', '/import/');
14 14
15 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 15 $this->assertSame(302, $client->getResponse()->getStatusCode());
16 $this->assertContains('login', $client->getResponse()->headers->get('location')); 16 $this->assertContains('login', $client->getResponse()->headers->get('location'));
17 } 17 }
18 18
@@ -23,7 +23,7 @@ class ImportControllerTest extends WallabagCoreTestCase
23 23
24 $crawler = $client->request('GET', '/import/'); 24 $crawler = $client->request('GET', '/import/');
25 25
26 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 26 $this->assertSame(200, $client->getResponse()->getStatusCode());
27 $this->assertEquals(8, $crawler->filter('blockquote')->count()); 27 $this->assertSame(8, $crawler->filter('blockquote')->count());
28 } 28 }
29} 29}
diff --git a/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php b/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php
index 84742e0a..067cf3dc 100644
--- a/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/InstapaperControllerTest.php
@@ -2,8 +2,8 @@
2 2
3namespace Tests\Wallabag\ImportBundle\Controller; 3namespace Tests\Wallabag\ImportBundle\Controller;
4 4
5use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
6use Symfony\Component\HttpFoundation\File\UploadedFile; 5use Symfony\Component\HttpFoundation\File\UploadedFile;
6use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
7 7
8class InstapaperControllerTest extends WallabagCoreTestCase 8class InstapaperControllerTest extends WallabagCoreTestCase
9{ 9{
@@ -14,9 +14,9 @@ class InstapaperControllerTest extends WallabagCoreTestCase
14 14
15 $crawler = $client->request('GET', '/import/instapaper'); 15 $crawler = $client->request('GET', '/import/instapaper');
16 16
17 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 17 $this->assertSame(200, $client->getResponse()->getStatusCode());
18 $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); 18 $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
19 $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); 19 $this->assertSame(1, $crawler->filter('input[type=file]')->count());
20 } 20 }
21 21
22 public function testImportInstapaperWithRabbitEnabled() 22 public function testImportInstapaperWithRabbitEnabled()
@@ -28,9 +28,9 @@ class InstapaperControllerTest extends WallabagCoreTestCase
28 28
29 $crawler = $client->request('GET', '/import/instapaper'); 29 $crawler = $client->request('GET', '/import/instapaper');
30 30
31 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 31 $this->assertSame(200, $client->getResponse()->getStatusCode());
32 $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); 32 $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
33 $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); 33 $this->assertSame(1, $crawler->filter('input[type=file]')->count());
34 34
35 $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0); 35 $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0);
36 } 36 }
@@ -49,7 +49,7 @@ class InstapaperControllerTest extends WallabagCoreTestCase
49 49
50 $client->submit($form, $data); 50 $client->submit($form, $data);
51 51
52 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 52 $this->assertSame(200, $client->getResponse()->getStatusCode());
53 } 53 }
54 54
55 public function testImportInstapaperWithRedisEnabled() 55 public function testImportInstapaperWithRedisEnabled()
@@ -61,13 +61,13 @@ class InstapaperControllerTest extends WallabagCoreTestCase
61 61
62 $crawler = $client->request('GET', '/import/instapaper'); 62 $crawler = $client->request('GET', '/import/instapaper');
63 63
64 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 64 $this->assertSame(200, $client->getResponse()->getStatusCode());
65 $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); 65 $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
66 $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); 66 $this->assertSame(1, $crawler->filter('input[type=file]')->count());
67 67
68 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 68 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
69 69
70 $file = new UploadedFile(__DIR__.'/../fixtures/instapaper-export.csv', 'instapaper.csv'); 70 $file = new UploadedFile(__DIR__ . '/../fixtures/instapaper-export.csv', 'instapaper.csv');
71 71
72 $data = [ 72 $data = [
73 'upload_import_file[file]' => $file, 73 'upload_import_file[file]' => $file,
@@ -75,7 +75,7 @@ class InstapaperControllerTest extends WallabagCoreTestCase
75 75
76 $client->submit($form, $data); 76 $client->submit($form, $data);
77 77
78 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 78 $this->assertSame(302, $client->getResponse()->getStatusCode());
79 79
80 $crawler = $client->followRedirect(); 80 $crawler = $client->followRedirect();
81 81
@@ -95,7 +95,7 @@ class InstapaperControllerTest extends WallabagCoreTestCase
95 $crawler = $client->request('GET', '/import/instapaper'); 95 $crawler = $client->request('GET', '/import/instapaper');
96 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 96 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
97 97
98 $file = new UploadedFile(__DIR__.'/../fixtures/instapaper-export.csv', 'instapaper.csv'); 98 $file = new UploadedFile(__DIR__ . '/../fixtures/instapaper-export.csv', 'instapaper.csv');
99 99
100 $data = [ 100 $data = [
101 'upload_import_file[file]' => $file, 101 'upload_import_file[file]' => $file,
@@ -103,7 +103,7 @@ class InstapaperControllerTest extends WallabagCoreTestCase
103 103
104 $client->submit($form, $data); 104 $client->submit($form, $data);
105 105
106 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 106 $this->assertSame(302, $client->getResponse()->getStatusCode());
107 107
108 $crawler = $client->followRedirect(); 108 $crawler = $client->followRedirect();
109 109
@@ -122,7 +122,7 @@ class InstapaperControllerTest extends WallabagCoreTestCase
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->assertContains('foot', $content->getTags(), 'It includes the "foot" tag');
125 $this->assertEquals(1, count($content->getTags())); 125 $this->assertSame(1, count($content->getTags()));
126 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); 126 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
127 127
128 $content = $client->getContainer() 128 $content = $client->getContainer()
@@ -136,7 +136,7 @@ class InstapaperControllerTest extends WallabagCoreTestCase
136 $this->assertContains('foot', $content->getTags()); 136 $this->assertContains('foot', $content->getTags());
137 $this->assertContains('test_tag', $content->getTags()); 137 $this->assertContains('test_tag', $content->getTags());
138 138
139 $this->assertEquals(2, count($content->getTags())); 139 $this->assertSame(2, count($content->getTags()));
140 } 140 }
141 141
142 public function testImportInstapaperWithFileAndMarkAllAsRead() 142 public function testImportInstapaperWithFileAndMarkAllAsRead()
@@ -147,7 +147,7 @@ class InstapaperControllerTest extends WallabagCoreTestCase
147 $crawler = $client->request('GET', '/import/instapaper'); 147 $crawler = $client->request('GET', '/import/instapaper');
148 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 148 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
149 149
150 $file = new UploadedFile(__DIR__.'/../fixtures/instapaper-export.csv', 'instapaper-read.csv'); 150 $file = new UploadedFile(__DIR__ . '/../fixtures/instapaper-export.csv', 'instapaper-read.csv');
151 151
152 $data = [ 152 $data = [
153 'upload_import_file[file]' => $file, 153 'upload_import_file[file]' => $file,
@@ -156,7 +156,7 @@ class InstapaperControllerTest extends WallabagCoreTestCase
156 156
157 $client->submit($form, $data); 157 $client->submit($form, $data);
158 158
159 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 159 $this->assertSame(302, $client->getResponse()->getStatusCode());
160 160
161 $crawler = $client->followRedirect(); 161 $crawler = $client->followRedirect();
162 162
@@ -192,7 +192,7 @@ class InstapaperControllerTest extends WallabagCoreTestCase
192 $crawler = $client->request('GET', '/import/instapaper'); 192 $crawler = $client->request('GET', '/import/instapaper');
193 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 193 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
194 194
195 $file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt'); 195 $file = new UploadedFile(__DIR__ . '/../fixtures/test.txt', 'test.txt');
196 196
197 $data = [ 197 $data = [
198 'upload_import_file[file]' => $file, 198 'upload_import_file[file]' => $file,
@@ -200,7 +200,7 @@ class InstapaperControllerTest extends WallabagCoreTestCase
200 200
201 $client->submit($form, $data); 201 $client->submit($form, $data);
202 202
203 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 203 $this->assertSame(302, $client->getResponse()->getStatusCode());
204 204
205 $crawler = $client->followRedirect(); 205 $crawler = $client->followRedirect();
206 206
diff --git a/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php b/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php
index e2b6e7b6..c307f96c 100644
--- a/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/PinboardControllerTest.php
@@ -2,8 +2,8 @@
2 2
3namespace Tests\Wallabag\ImportBundle\Controller; 3namespace Tests\Wallabag\ImportBundle\Controller;
4 4
5use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
6use Symfony\Component\HttpFoundation\File\UploadedFile; 5use Symfony\Component\HttpFoundation\File\UploadedFile;
6use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
7 7
8class PinboardControllerTest extends WallabagCoreTestCase 8class PinboardControllerTest extends WallabagCoreTestCase
9{ 9{
@@ -14,9 +14,9 @@ class PinboardControllerTest extends WallabagCoreTestCase
14 14
15 $crawler = $client->request('GET', '/import/pinboard'); 15 $crawler = $client->request('GET', '/import/pinboard');
16 16
17 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 17 $this->assertSame(200, $client->getResponse()->getStatusCode());
18 $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); 18 $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
19 $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); 19 $this->assertSame(1, $crawler->filter('input[type=file]')->count());
20 } 20 }
21 21
22 public function testImportPinboardWithRabbitEnabled() 22 public function testImportPinboardWithRabbitEnabled()
@@ -28,9 +28,9 @@ class PinboardControllerTest extends WallabagCoreTestCase
28 28
29 $crawler = $client->request('GET', '/import/pinboard'); 29 $crawler = $client->request('GET', '/import/pinboard');
30 30
31 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 31 $this->assertSame(200, $client->getResponse()->getStatusCode());
32 $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); 32 $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
33 $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); 33 $this->assertSame(1, $crawler->filter('input[type=file]')->count());
34 34
35 $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0); 35 $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0);
36 } 36 }
@@ -49,7 +49,7 @@ class PinboardControllerTest extends WallabagCoreTestCase
49 49
50 $client->submit($form, $data); 50 $client->submit($form, $data);
51 51
52 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 52 $this->assertSame(200, $client->getResponse()->getStatusCode());
53 } 53 }
54 54
55 public function testImportPinboardWithRedisEnabled() 55 public function testImportPinboardWithRedisEnabled()
@@ -61,13 +61,13 @@ class PinboardControllerTest extends WallabagCoreTestCase
61 61
62 $crawler = $client->request('GET', '/import/pinboard'); 62 $crawler = $client->request('GET', '/import/pinboard');
63 63
64 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 64 $this->assertSame(200, $client->getResponse()->getStatusCode());
65 $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); 65 $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
66 $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); 66 $this->assertSame(1, $crawler->filter('input[type=file]')->count());
67 67
68 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 68 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
69 69
70 $file = new UploadedFile(__DIR__.'/../fixtures/pinboard_export', 'pinboard.json'); 70 $file = new UploadedFile(__DIR__ . '/../fixtures/pinboard_export', 'pinboard.json');
71 71
72 $data = [ 72 $data = [
73 'upload_import_file[file]' => $file, 73 'upload_import_file[file]' => $file,
@@ -75,7 +75,7 @@ class PinboardControllerTest extends WallabagCoreTestCase
75 75
76 $client->submit($form, $data); 76 $client->submit($form, $data);
77 77
78 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 78 $this->assertSame(302, $client->getResponse()->getStatusCode());
79 79
80 $crawler = $client->followRedirect(); 80 $crawler = $client->followRedirect();
81 81
@@ -95,7 +95,7 @@ class PinboardControllerTest extends WallabagCoreTestCase
95 $crawler = $client->request('GET', '/import/pinboard'); 95 $crawler = $client->request('GET', '/import/pinboard');
96 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 96 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
97 97
98 $file = new UploadedFile(__DIR__.'/../fixtures/pinboard_export', 'pinboard.json'); 98 $file = new UploadedFile(__DIR__ . '/../fixtures/pinboard_export', 'pinboard.json');
99 99
100 $data = [ 100 $data = [
101 'upload_import_file[file]' => $file, 101 'upload_import_file[file]' => $file,
@@ -103,7 +103,7 @@ class PinboardControllerTest extends WallabagCoreTestCase
103 103
104 $client->submit($form, $data); 104 $client->submit($form, $data);
105 105
106 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 106 $this->assertSame(302, $client->getResponse()->getStatusCode());
107 107
108 $crawler = $client->followRedirect(); 108 $crawler = $client->followRedirect();
109 109
@@ -126,10 +126,10 @@ class PinboardControllerTest extends WallabagCoreTestCase
126 $this->assertContains('foot', $tags, 'It includes the "foot" tag'); 126 $this->assertContains('foot', $tags, 'It includes the "foot" tag');
127 $this->assertContains('varnish', $tags, 'It includes the "varnish" tag'); 127 $this->assertContains('varnish', $tags, 'It includes the "varnish" tag');
128 $this->assertContains('PHP', $tags, 'It includes the "PHP" tag'); 128 $this->assertContains('PHP', $tags, 'It includes the "PHP" tag');
129 $this->assertEquals(3, count($tags)); 129 $this->assertSame(3, count($tags));
130 130
131 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); 131 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
132 $this->assertEquals('2016-10-26', $content->getCreatedAt()->format('Y-m-d')); 132 $this->assertSame('2016-10-26', $content->getCreatedAt()->format('Y-m-d'));
133 } 133 }
134 134
135 public function testImportPinboardWithFileAndMarkAllAsRead() 135 public function testImportPinboardWithFileAndMarkAllAsRead()
@@ -140,7 +140,7 @@ class PinboardControllerTest extends WallabagCoreTestCase
140 $crawler = $client->request('GET', '/import/pinboard'); 140 $crawler = $client->request('GET', '/import/pinboard');
141 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 141 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
142 142
143 $file = new UploadedFile(__DIR__.'/../fixtures/pinboard_export', 'pinboard-read.json'); 143 $file = new UploadedFile(__DIR__ . '/../fixtures/pinboard_export', 'pinboard-read.json');
144 144
145 $data = [ 145 $data = [
146 'upload_import_file[file]' => $file, 146 'upload_import_file[file]' => $file,
@@ -149,7 +149,7 @@ class PinboardControllerTest extends WallabagCoreTestCase
149 149
150 $client->submit($form, $data); 150 $client->submit($form, $data);
151 151
152 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 152 $this->assertSame(302, $client->getResponse()->getStatusCode());
153 153
154 $crawler = $client->followRedirect(); 154 $crawler = $client->followRedirect();
155 155
@@ -185,7 +185,7 @@ class PinboardControllerTest extends WallabagCoreTestCase
185 $crawler = $client->request('GET', '/import/pinboard'); 185 $crawler = $client->request('GET', '/import/pinboard');
186 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 186 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
187 187
188 $file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt'); 188 $file = new UploadedFile(__DIR__ . '/../fixtures/test.txt', 'test.txt');
189 189
190 $data = [ 190 $data = [
191 'upload_import_file[file]' => $file, 191 'upload_import_file[file]' => $file,
@@ -193,7 +193,7 @@ class PinboardControllerTest extends WallabagCoreTestCase
193 193
194 $client->submit($form, $data); 194 $client->submit($form, $data);
195 195
196 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 196 $this->assertSame(302, $client->getResponse()->getStatusCode());
197 197
198 $crawler = $client->followRedirect(); 198 $crawler = $client->followRedirect();
199 199
diff --git a/tests/Wallabag/ImportBundle/Controller/PocketControllerTest.php b/tests/Wallabag/ImportBundle/Controller/PocketControllerTest.php
index 7d6a300f..17ce1a2a 100644
--- a/tests/Wallabag/ImportBundle/Controller/PocketControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/PocketControllerTest.php
@@ -13,8 +13,8 @@ class PocketControllerTest extends WallabagCoreTestCase
13 13
14 $crawler = $client->request('GET', '/import/pocket'); 14 $crawler = $client->request('GET', '/import/pocket');
15 15
16 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 16 $this->assertSame(200, $client->getResponse()->getStatusCode());
17 $this->assertEquals(1, $crawler->filter('button[type=submit]')->count()); 17 $this->assertSame(1, $crawler->filter('button[type=submit]')->count());
18 } 18 }
19 19
20 public function testImportPocketWithRabbitEnabled() 20 public function testImportPocketWithRabbitEnabled()
@@ -26,8 +26,8 @@ class PocketControllerTest extends WallabagCoreTestCase
26 26
27 $crawler = $client->request('GET', '/import/pocket'); 27 $crawler = $client->request('GET', '/import/pocket');
28 28
29 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 29 $this->assertSame(200, $client->getResponse()->getStatusCode());
30 $this->assertEquals(1, $crawler->filter('button[type=submit]')->count()); 30 $this->assertSame(1, $crawler->filter('button[type=submit]')->count());
31 31
32 $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0); 32 $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0);
33 } 33 }
@@ -42,8 +42,8 @@ class PocketControllerTest extends WallabagCoreTestCase
42 42
43 $crawler = $client->request('GET', '/import/pocket'); 43 $crawler = $client->request('GET', '/import/pocket');
44 44
45 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 45 $this->assertSame(200, $client->getResponse()->getStatusCode());
46 $this->assertEquals(1, $crawler->filter('button[type=submit]')->count()); 46 $this->assertSame(1, $crawler->filter('button[type=submit]')->count());
47 47
48 $client->getContainer()->get('craue_config')->set('import_with_redis', 0); 48 $client->getContainer()->get('craue_config')->set('import_with_redis', 0);
49 } 49 }
@@ -55,7 +55,7 @@ class PocketControllerTest extends WallabagCoreTestCase
55 55
56 $client->request('GET', '/import/pocket/auth'); 56 $client->request('GET', '/import/pocket/auth');
57 57
58 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 58 $this->assertSame(302, $client->getResponse()->getStatusCode());
59 } 59 }
60 60
61 public function testImportPocketAuth() 61 public function testImportPocketAuth()
@@ -76,7 +76,7 @@ class PocketControllerTest extends WallabagCoreTestCase
76 76
77 $client->request('GET', '/import/pocket/auth'); 77 $client->request('GET', '/import/pocket/auth');
78 78
79 $this->assertEquals(301, $client->getResponse()->getStatusCode()); 79 $this->assertSame(301, $client->getResponse()->getStatusCode());
80 $this->assertContains('getpocket.com/auth/authorize', $client->getResponse()->headers->get('location')); 80 $this->assertContains('getpocket.com/auth/authorize', $client->getResponse()->headers->get('location'));
81 } 81 }
82 82
@@ -98,9 +98,9 @@ class PocketControllerTest extends WallabagCoreTestCase
98 98
99 $client->request('GET', '/import/pocket/callback'); 99 $client->request('GET', '/import/pocket/callback');
100 100
101 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 101 $this->assertSame(302, $client->getResponse()->getStatusCode());
102 $this->assertContains('/', $client->getResponse()->headers->get('location'), 'Import is ok, redirect to homepage'); 102 $this->assertContains('/', $client->getResponse()->headers->get('location'), 'Import is ok, redirect to homepage');
103 $this->assertEquals('flashes.import.notice.failed', $client->getContainer()->get('session')->getFlashBag()->peek('notice')[0]); 103 $this->assertSame('flashes.import.notice.failed', $client->getContainer()->get('session')->getFlashBag()->peek('notice')[0]);
104 } 104 }
105 105
106 public function testImportPocketCallback() 106 public function testImportPocketCallback()
@@ -132,8 +132,8 @@ class PocketControllerTest extends WallabagCoreTestCase
132 132
133 $client->request('GET', '/import/pocket/callback'); 133 $client->request('GET', '/import/pocket/callback');
134 134
135 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 135 $this->assertSame(302, $client->getResponse()->getStatusCode());
136 $this->assertContains('/', $client->getResponse()->headers->get('location'), 'Import is ok, redirect to homepage'); 136 $this->assertContains('/', $client->getResponse()->headers->get('location'), 'Import is ok, redirect to homepage');
137 $this->assertEquals('flashes.import.notice.summary', $client->getContainer()->get('session')->getFlashBag()->peek('notice')[0]); 137 $this->assertSame('flashes.import.notice.summary', $client->getContainer()->get('session')->getFlashBag()->peek('notice')[0]);
138 } 138 }
139} 139}
diff --git a/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php b/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php
index bde0a600..e1915150 100644
--- a/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/ReadabilityControllerTest.php
@@ -2,8 +2,8 @@
2 2
3namespace Tests\Wallabag\ImportBundle\Controller; 3namespace Tests\Wallabag\ImportBundle\Controller;
4 4
5use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
6use Symfony\Component\HttpFoundation\File\UploadedFile; 5use Symfony\Component\HttpFoundation\File\UploadedFile;
6use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
7 7
8class ReadabilityControllerTest extends WallabagCoreTestCase 8class ReadabilityControllerTest extends WallabagCoreTestCase
9{ 9{
@@ -14,9 +14,9 @@ class ReadabilityControllerTest extends WallabagCoreTestCase
14 14
15 $crawler = $client->request('GET', '/import/readability'); 15 $crawler = $client->request('GET', '/import/readability');
16 16
17 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 17 $this->assertSame(200, $client->getResponse()->getStatusCode());
18 $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); 18 $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
19 $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); 19 $this->assertSame(1, $crawler->filter('input[type=file]')->count());
20 } 20 }
21 21
22 public function testImportReadabilityWithRabbitEnabled() 22 public function testImportReadabilityWithRabbitEnabled()
@@ -28,9 +28,9 @@ class ReadabilityControllerTest extends WallabagCoreTestCase
28 28
29 $crawler = $client->request('GET', '/import/readability'); 29 $crawler = $client->request('GET', '/import/readability');
30 30
31 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 31 $this->assertSame(200, $client->getResponse()->getStatusCode());
32 $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); 32 $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
33 $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); 33 $this->assertSame(1, $crawler->filter('input[type=file]')->count());
34 34
35 $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0); 35 $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0);
36 } 36 }
@@ -49,7 +49,7 @@ class ReadabilityControllerTest extends WallabagCoreTestCase
49 49
50 $client->submit($form, $data); 50 $client->submit($form, $data);
51 51
52 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 52 $this->assertSame(200, $client->getResponse()->getStatusCode());
53 } 53 }
54 54
55 public function testImportReadabilityWithRedisEnabled() 55 public function testImportReadabilityWithRedisEnabled()
@@ -61,13 +61,13 @@ class ReadabilityControllerTest extends WallabagCoreTestCase
61 61
62 $crawler = $client->request('GET', '/import/readability'); 62 $crawler = $client->request('GET', '/import/readability');
63 63
64 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 64 $this->assertSame(200, $client->getResponse()->getStatusCode());
65 $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); 65 $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
66 $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); 66 $this->assertSame(1, $crawler->filter('input[type=file]')->count());
67 67
68 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 68 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
69 69
70 $file = new UploadedFile(__DIR__.'/../fixtures/readability.json', 'readability.json'); 70 $file = new UploadedFile(__DIR__ . '/../fixtures/readability.json', 'readability.json');
71 71
72 $data = [ 72 $data = [
73 'upload_import_file[file]' => $file, 73 'upload_import_file[file]' => $file,
@@ -75,7 +75,7 @@ class ReadabilityControllerTest extends WallabagCoreTestCase
75 75
76 $client->submit($form, $data); 76 $client->submit($form, $data);
77 77
78 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 78 $this->assertSame(302, $client->getResponse()->getStatusCode());
79 79
80 $crawler = $client->followRedirect(); 80 $crawler = $client->followRedirect();
81 81
@@ -95,7 +95,7 @@ class ReadabilityControllerTest extends WallabagCoreTestCase
95 $crawler = $client->request('GET', '/import/readability'); 95 $crawler = $client->request('GET', '/import/readability');
96 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 96 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
97 97
98 $file = new UploadedFile(__DIR__.'/../fixtures/readability.json', 'readability.json'); 98 $file = new UploadedFile(__DIR__ . '/../fixtures/readability.json', 'readability.json');
99 99
100 $data = [ 100 $data = [
101 'upload_import_file[file]' => $file, 101 'upload_import_file[file]' => $file,
@@ -103,7 +103,7 @@ class ReadabilityControllerTest extends WallabagCoreTestCase
103 103
104 $client->submit($form, $data); 104 $client->submit($form, $data);
105 105
106 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 106 $this->assertSame(302, $client->getResponse()->getStatusCode());
107 107
108 $crawler = $client->followRedirect(); 108 $crawler = $client->followRedirect();
109 109
@@ -124,10 +124,10 @@ class ReadabilityControllerTest extends WallabagCoreTestCase
124 124
125 $tags = $content->getTags(); 125 $tags = $content->getTags();
126 $this->assertContains('foot', $tags, 'It includes the "foot" tag'); 126 $this->assertContains('foot', $tags, 'It includes the "foot" tag');
127 $this->assertEquals(1, count($tags)); 127 $this->assertSame(1, count($tags));
128 128
129 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); 129 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
130 $this->assertEquals('2016-09-08', $content->getCreatedAt()->format('Y-m-d')); 130 $this->assertSame('2016-09-08', $content->getCreatedAt()->format('Y-m-d'));
131 } 131 }
132 132
133 public function testImportReadabilityWithFileAndMarkAllAsRead() 133 public function testImportReadabilityWithFileAndMarkAllAsRead()
@@ -138,7 +138,7 @@ class ReadabilityControllerTest extends WallabagCoreTestCase
138 $crawler = $client->request('GET', '/import/readability'); 138 $crawler = $client->request('GET', '/import/readability');
139 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 139 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
140 140
141 $file = new UploadedFile(__DIR__.'/../fixtures/readability-read.json', 'readability-read.json'); 141 $file = new UploadedFile(__DIR__ . '/../fixtures/readability-read.json', 'readability-read.json');
142 142
143 $data = [ 143 $data = [
144 'upload_import_file[file]' => $file, 144 'upload_import_file[file]' => $file,
@@ -147,7 +147,7 @@ class ReadabilityControllerTest extends WallabagCoreTestCase
147 147
148 $client->submit($form, $data); 148 $client->submit($form, $data);
149 149
150 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 150 $this->assertSame(302, $client->getResponse()->getStatusCode());
151 151
152 $crawler = $client->followRedirect(); 152 $crawler = $client->followRedirect();
153 153
@@ -183,7 +183,7 @@ class ReadabilityControllerTest extends WallabagCoreTestCase
183 $crawler = $client->request('GET', '/import/readability'); 183 $crawler = $client->request('GET', '/import/readability');
184 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 184 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
185 185
186 $file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt'); 186 $file = new UploadedFile(__DIR__ . '/../fixtures/test.txt', 'test.txt');
187 187
188 $data = [ 188 $data = [
189 'upload_import_file[file]' => $file, 189 'upload_import_file[file]' => $file,
@@ -191,7 +191,7 @@ class ReadabilityControllerTest extends WallabagCoreTestCase
191 191
192 $client->submit($form, $data); 192 $client->submit($form, $data);
193 193
194 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 194 $this->assertSame(302, $client->getResponse()->getStatusCode());
195 195
196 $crawler = $client->followRedirect(); 196 $crawler = $client->followRedirect();
197 197
diff --git a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php
index 2c492c20..25625c35 100644
--- a/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/WallabagV1ControllerTest.php
@@ -2,8 +2,8 @@
2 2
3namespace Tests\Wallabag\ImportBundle\Controller; 3namespace Tests\Wallabag\ImportBundle\Controller;
4 4
5use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
6use Symfony\Component\HttpFoundation\File\UploadedFile; 5use Symfony\Component\HttpFoundation\File\UploadedFile;
6use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
7 7
8class WallabagV1ControllerTest extends WallabagCoreTestCase 8class WallabagV1ControllerTest extends WallabagCoreTestCase
9{ 9{
@@ -14,9 +14,9 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
14 14
15 $crawler = $client->request('GET', '/import/wallabag-v1'); 15 $crawler = $client->request('GET', '/import/wallabag-v1');
16 16
17 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 17 $this->assertSame(200, $client->getResponse()->getStatusCode());
18 $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); 18 $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
19 $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); 19 $this->assertSame(1, $crawler->filter('input[type=file]')->count());
20 } 20 }
21 21
22 public function testImportWallabagWithRabbitEnabled() 22 public function testImportWallabagWithRabbitEnabled()
@@ -28,9 +28,9 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
28 28
29 $crawler = $client->request('GET', '/import/wallabag-v1'); 29 $crawler = $client->request('GET', '/import/wallabag-v1');
30 30
31 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 31 $this->assertSame(200, $client->getResponse()->getStatusCode());
32 $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); 32 $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
33 $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); 33 $this->assertSame(1, $crawler->filter('input[type=file]')->count());
34 34
35 $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0); 35 $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0);
36 } 36 }
@@ -49,7 +49,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
49 49
50 $client->submit($form, $data); 50 $client->submit($form, $data);
51 51
52 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 52 $this->assertSame(200, $client->getResponse()->getStatusCode());
53 } 53 }
54 54
55 public function testImportWallabagWithRedisEnabled() 55 public function testImportWallabagWithRedisEnabled()
@@ -62,13 +62,13 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
62 62
63 $crawler = $client->request('GET', '/import/wallabag-v1'); 63 $crawler = $client->request('GET', '/import/wallabag-v1');
64 64
65 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 65 $this->assertSame(200, $client->getResponse()->getStatusCode());
66 $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); 66 $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
67 $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); 67 $this->assertSame(1, $crawler->filter('input[type=file]')->count());
68 68
69 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 69 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
70 70
71 $file = new UploadedFile(__DIR__.'/../fixtures/wallabag-v1.json', 'wallabag-v1.json'); 71 $file = new UploadedFile(__DIR__ . '/../fixtures/wallabag-v1.json', 'wallabag-v1.json');
72 72
73 $data = [ 73 $data = [
74 'upload_import_file[file]' => $file, 74 'upload_import_file[file]' => $file,
@@ -76,7 +76,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
76 76
77 $client->submit($form, $data); 77 $client->submit($form, $data);
78 78
79 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 79 $this->assertSame(302, $client->getResponse()->getStatusCode());
80 80
81 $crawler = $client->followRedirect(); 81 $crawler = $client->followRedirect();
82 82
@@ -96,7 +96,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
96 $crawler = $client->request('GET', '/import/wallabag-v1'); 96 $crawler = $client->request('GET', '/import/wallabag-v1');
97 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 97 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
98 98
99 $file = new UploadedFile(__DIR__.'/../fixtures/wallabag-v1.json', 'wallabag-v1.json'); 99 $file = new UploadedFile(__DIR__ . '/../fixtures/wallabag-v1.json', 'wallabag-v1.json');
100 100
101 $data = [ 101 $data = [
102 'upload_import_file[file]' => $file, 102 'upload_import_file[file]' => $file,
@@ -104,7 +104,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
104 104
105 $client->submit($form, $data); 105 $client->submit($form, $data);
106 106
107 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 107 $this->assertSame(302, $client->getResponse()->getStatusCode());
108 108
109 $crawler = $client->followRedirect(); 109 $crawler = $client->followRedirect();
110 110
@@ -126,7 +126,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
126 $tags = $content->getTags(); 126 $tags = $content->getTags();
127 $this->assertContains('foot', $tags, 'It includes the "foot" tag'); 127 $this->assertContains('foot', $tags, 'It includes the "foot" tag');
128 $this->assertContains('Framabag', $tags, 'It includes the "Framabag" tag'); 128 $this->assertContains('Framabag', $tags, 'It includes the "Framabag" tag');
129 $this->assertEquals(2, count($tags)); 129 $this->assertSame(2, count($tags));
130 130
131 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); 131 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
132 } 132 }
@@ -139,7 +139,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
139 $crawler = $client->request('GET', '/import/wallabag-v1'); 139 $crawler = $client->request('GET', '/import/wallabag-v1');
140 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 140 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
141 141
142 $file = new UploadedFile(__DIR__.'/../fixtures/wallabag-v1-read.json', 'wallabag-v1-read.json'); 142 $file = new UploadedFile(__DIR__ . '/../fixtures/wallabag-v1-read.json', 'wallabag-v1-read.json');
143 143
144 $data = [ 144 $data = [
145 'upload_import_file[file]' => $file, 145 'upload_import_file[file]' => $file,
@@ -148,7 +148,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
148 148
149 $client->submit($form, $data); 149 $client->submit($form, $data);
150 150
151 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 151 $this->assertSame(302, $client->getResponse()->getStatusCode());
152 152
153 $crawler = $client->followRedirect(); 153 $crawler = $client->followRedirect();
154 154
@@ -184,7 +184,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
184 $crawler = $client->request('GET', '/import/wallabag-v1'); 184 $crawler = $client->request('GET', '/import/wallabag-v1');
185 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 185 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
186 186
187 $file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt'); 187 $file = new UploadedFile(__DIR__ . '/../fixtures/test.txt', 'test.txt');
188 188
189 $data = [ 189 $data = [
190 'upload_import_file[file]' => $file, 190 'upload_import_file[file]' => $file,
@@ -192,7 +192,7 @@ class WallabagV1ControllerTest extends WallabagCoreTestCase
192 192
193 $client->submit($form, $data); 193 $client->submit($form, $data);
194 194
195 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 195 $this->assertSame(302, $client->getResponse()->getStatusCode());
196 196
197 $crawler = $client->followRedirect(); 197 $crawler = $client->followRedirect();
198 198
diff --git a/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php b/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php
index 24893259..a94adcaf 100644
--- a/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/WallabagV2ControllerTest.php
@@ -2,8 +2,8 @@
2 2
3namespace Tests\Wallabag\ImportBundle\Controller; 3namespace Tests\Wallabag\ImportBundle\Controller;
4 4
5use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
6use Symfony\Component\HttpFoundation\File\UploadedFile; 5use Symfony\Component\HttpFoundation\File\UploadedFile;
6use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
7 7
8class WallabagV2ControllerTest extends WallabagCoreTestCase 8class WallabagV2ControllerTest extends WallabagCoreTestCase
9{ 9{
@@ -14,9 +14,9 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
14 14
15 $crawler = $client->request('GET', '/import/wallabag-v2'); 15 $crawler = $client->request('GET', '/import/wallabag-v2');
16 16
17 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 17 $this->assertSame(200, $client->getResponse()->getStatusCode());
18 $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); 18 $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
19 $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); 19 $this->assertSame(1, $crawler->filter('input[type=file]')->count());
20 } 20 }
21 21
22 public function testImportWallabagWithRabbitEnabled() 22 public function testImportWallabagWithRabbitEnabled()
@@ -28,9 +28,9 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
28 28
29 $crawler = $client->request('GET', '/import/wallabag-v2'); 29 $crawler = $client->request('GET', '/import/wallabag-v2');
30 30
31 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 31 $this->assertSame(200, $client->getResponse()->getStatusCode());
32 $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); 32 $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
33 $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); 33 $this->assertSame(1, $crawler->filter('input[type=file]')->count());
34 34
35 $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0); 35 $client->getContainer()->get('craue_config')->set('import_with_rabbitmq', 0);
36 } 36 }
@@ -49,7 +49,7 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
49 49
50 $client->submit($form, $data); 50 $client->submit($form, $data);
51 51
52 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 52 $this->assertSame(200, $client->getResponse()->getStatusCode());
53 } 53 }
54 54
55 public function testImportWallabagWithRedisEnabled() 55 public function testImportWallabagWithRedisEnabled()
@@ -62,13 +62,13 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
62 62
63 $crawler = $client->request('GET', '/import/wallabag-v2'); 63 $crawler = $client->request('GET', '/import/wallabag-v2');
64 64
65 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 65 $this->assertSame(200, $client->getResponse()->getStatusCode());
66 $this->assertEquals(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count()); 66 $this->assertSame(1, $crawler->filter('form[name=upload_import_file] > button[type=submit]')->count());
67 $this->assertEquals(1, $crawler->filter('input[type=file]')->count()); 67 $this->assertSame(1, $crawler->filter('input[type=file]')->count());
68 68
69 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 69 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
70 70
71 $file = new UploadedFile(__DIR__.'/../fixtures/wallabag-v2.json', 'wallabag-v2.json'); 71 $file = new UploadedFile(__DIR__ . '/../fixtures/wallabag-v2.json', 'wallabag-v2.json');
72 72
73 $data = [ 73 $data = [
74 'upload_import_file[file]' => $file, 74 'upload_import_file[file]' => $file,
@@ -76,7 +76,7 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
76 76
77 $client->submit($form, $data); 77 $client->submit($form, $data);
78 78
79 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 79 $this->assertSame(302, $client->getResponse()->getStatusCode());
80 80
81 $crawler = $client->followRedirect(); 81 $crawler = $client->followRedirect();
82 82
@@ -96,7 +96,7 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
96 $crawler = $client->request('GET', '/import/wallabag-v2'); 96 $crawler = $client->request('GET', '/import/wallabag-v2');
97 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 97 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
98 98
99 $file = new UploadedFile(__DIR__.'/../fixtures/wallabag-v2.json', 'wallabag-v2.json'); 99 $file = new UploadedFile(__DIR__ . '/../fixtures/wallabag-v2.json', 'wallabag-v2.json');
100 100
101 $data = [ 101 $data = [
102 'upload_import_file[file]' => $file, 102 'upload_import_file[file]' => $file,
@@ -104,7 +104,7 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
104 104
105 $client->submit($form, $data); 105 $client->submit($form, $data);
106 106
107 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 107 $this->assertSame(302, $client->getResponse()->getStatusCode());
108 108
109 $crawler = $client->followRedirect(); 109 $crawler = $client->followRedirect();
110 110
@@ -126,7 +126,7 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
126 126
127 $tags = $content->getTags(); 127 $tags = $content->getTags();
128 $this->assertContains('foot', $tags, 'It includes the "foot" tag'); 128 $this->assertContains('foot', $tags, 'It includes the "foot" tag');
129 $this->assertEquals(1, count($tags)); 129 $this->assertSame(1, count($tags));
130 130
131 $content = $client->getContainer() 131 $content = $client->getContainer()
132 ->get('doctrine.orm.entity_manager') 132 ->get('doctrine.orm.entity_manager')
@@ -144,10 +144,10 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
144 $this->assertContains('foot', $tags, 'It includes the "foot" tag'); 144 $this->assertContains('foot', $tags, 'It includes the "foot" tag');
145 $this->assertContains('mediapart', $tags, 'It includes the "mediapart" tag'); 145 $this->assertContains('mediapart', $tags, 'It includes the "mediapart" tag');
146 $this->assertContains('blog', $tags, 'It includes the "blog" tag'); 146 $this->assertContains('blog', $tags, 'It includes the "blog" tag');
147 $this->assertEquals(3, count($tags)); 147 $this->assertSame(3, count($tags));
148 148
149 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt()); 149 $this->assertInstanceOf(\DateTime::class, $content->getCreatedAt());
150 $this->assertEquals('2016-09-08', $content->getCreatedAt()->format('Y-m-d')); 150 $this->assertSame('2016-09-08', $content->getCreatedAt()->format('Y-m-d'));
151 $this->assertTrue($content->isStarred(), 'Entry is starred'); 151 $this->assertTrue($content->isStarred(), 'Entry is starred');
152 } 152 }
153 153
@@ -159,7 +159,7 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
159 $crawler = $client->request('GET', '/import/wallabag-v2'); 159 $crawler = $client->request('GET', '/import/wallabag-v2');
160 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form(); 160 $form = $crawler->filter('form[name=upload_import_file] > button[type=submit]')->form();
161 161
162 $file = new UploadedFile(__DIR__.'/../fixtures/test.txt', 'test.txt'); 162 $file = new UploadedFile(__DIR__ . '/../fixtures/test.txt', 'test.txt');
163 163
164 $data = [ 164 $data = [
165 'upload_import_file[file]' => $file, 165 'upload_import_file[file]' => $file,
@@ -167,7 +167,7 @@ class WallabagV2ControllerTest extends WallabagCoreTestCase
167 167
168 $client->submit($form, $data); 168 $client->submit($form, $data);
169 169
170 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 170 $this->assertSame(302, $client->getResponse()->getStatusCode());
171 171
172 $crawler = $client->followRedirect(); 172 $crawler = $client->followRedirect();
173 173
diff --git a/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php b/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php
index cec19534..5559ac7e 100644
--- a/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php
+++ b/tests/Wallabag/ImportBundle/Import/ChromeImportTest.php
@@ -2,14 +2,14 @@
2 2
3namespace Tests\Wallabag\ImportBundle\Import; 3namespace Tests\Wallabag\ImportBundle\Import;
4 4
5use Wallabag\ImportBundle\Import\ChromeImport; 5use M6Web\Component\RedisMock\RedisMockFactory;
6use Wallabag\UserBundle\Entity\User;
7use Wallabag\CoreBundle\Entity\Entry;
8use Wallabag\ImportBundle\Redis\Producer;
9use Monolog\Logger;
10use Monolog\Handler\TestHandler; 6use Monolog\Handler\TestHandler;
7use Monolog\Logger;
11use Simpleue\Queue\RedisQueue; 8use Simpleue\Queue\RedisQueue;
12use M6Web\Component\RedisMock\RedisMockFactory; 9use Wallabag\CoreBundle\Entity\Entry;
10use Wallabag\ImportBundle\Import\ChromeImport;
11use Wallabag\ImportBundle\Redis\Producer;
12use Wallabag\UserBundle\Entity\User;
13 13
14class ChromeImportTest extends \PHPUnit_Framework_TestCase 14class ChromeImportTest extends \PHPUnit_Framework_TestCase
15{ 15{
@@ -19,56 +19,19 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase
19 protected $contentProxy; 19 protected $contentProxy;
20 protected $tagsAssigner; 20 protected $tagsAssigner;
21 21
22 private function getChromeImport($unsetUser = false, $dispatched = 0)
23 {
24 $this->user = new User();
25
26 $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
27 ->disableOriginalConstructor()
28 ->getMock();
29
30 $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy')
31 ->disableOriginalConstructor()
32 ->getMock();
33
34 $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
35 ->disableOriginalConstructor()
36 ->getMock();
37
38 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
39 ->disableOriginalConstructor()
40 ->getMock();
41
42 $dispatcher
43 ->expects($this->exactly($dispatched))
44 ->method('dispatch');
45
46 $wallabag = new ChromeImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher);
47
48 $this->logHandler = new TestHandler();
49 $logger = new Logger('test', [$this->logHandler]);
50 $wallabag->setLogger($logger);
51
52 if (false === $unsetUser) {
53 $wallabag->setUser($this->user);
54 }
55
56 return $wallabag;
57 }
58
59 public function testInit() 22 public function testInit()
60 { 23 {
61 $chromeImport = $this->getChromeImport(); 24 $chromeImport = $this->getChromeImport();
62 25
63 $this->assertEquals('Chrome', $chromeImport->getName()); 26 $this->assertSame('Chrome', $chromeImport->getName());
64 $this->assertNotEmpty($chromeImport->getUrl()); 27 $this->assertNotEmpty($chromeImport->getUrl());
65 $this->assertEquals('import.chrome.description', $chromeImport->getDescription()); 28 $this->assertSame('import.chrome.description', $chromeImport->getDescription());
66 } 29 }
67 30
68 public function testImport() 31 public function testImport()
69 { 32 {
70 $chromeImport = $this->getChromeImport(false, 1); 33 $chromeImport = $this->getChromeImport(false, 1);
71 $chromeImport->setFilepath(__DIR__.'/../fixtures/chrome-bookmarks'); 34 $chromeImport->setFilepath(__DIR__ . '/../fixtures/chrome-bookmarks');
72 35
73 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 36 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
74 ->disableOriginalConstructor() 37 ->disableOriginalConstructor()
@@ -95,13 +58,13 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase
95 $res = $chromeImport->import(); 58 $res = $chromeImport->import();
96 59
97 $this->assertTrue($res); 60 $this->assertTrue($res);
98 $this->assertEquals(['skipped' => 0, 'imported' => 1, 'queued' => 0], $chromeImport->getSummary()); 61 $this->assertSame(['skipped' => 0, 'imported' => 1, 'queued' => 0], $chromeImport->getSummary());
99 } 62 }
100 63
101 public function testImportAndMarkAllAsRead() 64 public function testImportAndMarkAllAsRead()
102 { 65 {
103 $chromeImport = $this->getChromeImport(false, 1); 66 $chromeImport = $this->getChromeImport(false, 1);
104 $chromeImport->setFilepath(__DIR__.'/../fixtures/chrome-bookmarks'); 67 $chromeImport->setFilepath(__DIR__ . '/../fixtures/chrome-bookmarks');
105 68
106 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 69 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
107 ->disableOriginalConstructor() 70 ->disableOriginalConstructor()
@@ -133,13 +96,13 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase
133 96
134 $this->assertTrue($res); 97 $this->assertTrue($res);
135 98
136 $this->assertEquals(['skipped' => 0, 'imported' => 1, 'queued' => 0], $chromeImport->getSummary()); 99 $this->assertSame(['skipped' => 0, 'imported' => 1, 'queued' => 0], $chromeImport->getSummary());
137 } 100 }
138 101
139 public function testImportWithRabbit() 102 public function testImportWithRabbit()
140 { 103 {
141 $chromeImport = $this->getChromeImport(); 104 $chromeImport = $this->getChromeImport();
142 $chromeImport->setFilepath(__DIR__.'/../fixtures/chrome-bookmarks'); 105 $chromeImport->setFilepath(__DIR__ . '/../fixtures/chrome-bookmarks');
143 106
144 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 107 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
145 ->disableOriginalConstructor() 108 ->disableOriginalConstructor()
@@ -173,13 +136,13 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase
173 $res = $chromeImport->setMarkAsRead(true)->import(); 136 $res = $chromeImport->setMarkAsRead(true)->import();
174 137
175 $this->assertTrue($res); 138 $this->assertTrue($res);
176 $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 1], $chromeImport->getSummary()); 139 $this->assertSame(['skipped' => 0, 'imported' => 0, 'queued' => 1], $chromeImport->getSummary());
177 } 140 }
178 141
179 public function testImportWithRedis() 142 public function testImportWithRedis()
180 { 143 {
181 $chromeImport = $this->getChromeImport(); 144 $chromeImport = $this->getChromeImport();
182 $chromeImport->setFilepath(__DIR__.'/../fixtures/chrome-bookmarks'); 145 $chromeImport->setFilepath(__DIR__ . '/../fixtures/chrome-bookmarks');
183 146
184 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 147 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
185 ->disableOriginalConstructor() 148 ->disableOriginalConstructor()
@@ -211,7 +174,7 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase
211 $res = $chromeImport->setMarkAsRead(true)->import(); 174 $res = $chromeImport->setMarkAsRead(true)->import();
212 175
213 $this->assertTrue($res); 176 $this->assertTrue($res);
214 $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 1], $chromeImport->getSummary()); 177 $this->assertSame(['skipped' => 0, 'imported' => 0, 'queued' => 1], $chromeImport->getSummary());
215 178
216 $this->assertNotEmpty($redisMock->lpop('chrome')); 179 $this->assertNotEmpty($redisMock->lpop('chrome'));
217 } 180 }
@@ -219,7 +182,7 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase
219 public function testImportBadFile() 182 public function testImportBadFile()
220 { 183 {
221 $chromeImport = $this->getChromeImport(); 184 $chromeImport = $this->getChromeImport();
222 $chromeImport->setFilepath(__DIR__.'/../fixtures/wallabag-v1.jsonx'); 185 $chromeImport->setFilepath(__DIR__ . '/../fixtures/wallabag-v1.jsonx');
223 186
224 $res = $chromeImport->import(); 187 $res = $chromeImport->import();
225 188
@@ -227,13 +190,13 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase
227 190
228 $records = $this->logHandler->getRecords(); 191 $records = $this->logHandler->getRecords();
229 $this->assertContains('Wallabag Browser Import: unable to read file', $records[0]['message']); 192 $this->assertContains('Wallabag Browser Import: unable to read file', $records[0]['message']);
230 $this->assertEquals('ERROR', $records[0]['level_name']); 193 $this->assertSame('ERROR', $records[0]['level_name']);
231 } 194 }
232 195
233 public function testImportUserNotDefined() 196 public function testImportUserNotDefined()
234 { 197 {
235 $chromeImport = $this->getChromeImport(true); 198 $chromeImport = $this->getChromeImport(true);
236 $chromeImport->setFilepath(__DIR__.'/../fixtures/chrome-bookmarks'); 199 $chromeImport->setFilepath(__DIR__ . '/../fixtures/chrome-bookmarks');
237 200
238 $res = $chromeImport->import(); 201 $res = $chromeImport->import();
239 202
@@ -241,6 +204,43 @@ class ChromeImportTest extends \PHPUnit_Framework_TestCase
241 204
242 $records = $this->logHandler->getRecords(); 205 $records = $this->logHandler->getRecords();
243 $this->assertContains('Wallabag Browser Import: user is not defined', $records[0]['message']); 206 $this->assertContains('Wallabag Browser Import: user is not defined', $records[0]['message']);
244 $this->assertEquals('ERROR', $records[0]['level_name']); 207 $this->assertSame('ERROR', $records[0]['level_name']);
208 }
209
210 private function getChromeImport($unsetUser = false, $dispatched = 0)
211 {
212 $this->user = new User();
213
214 $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
215 ->disableOriginalConstructor()
216 ->getMock();
217
218 $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy')
219 ->disableOriginalConstructor()
220 ->getMock();
221
222 $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
223 ->disableOriginalConstructor()
224 ->getMock();
225
226 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
227 ->disableOriginalConstructor()
228 ->getMock();
229
230 $dispatcher
231 ->expects($this->exactly($dispatched))
232 ->method('dispatch');
233
234 $wallabag = new ChromeImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher);
235
236 $this->logHandler = new TestHandler();
237 $logger = new Logger('test', [$this->logHandler]);
238 $wallabag->setLogger($logger);
239
240 if (false === $unsetUser) {
241 $wallabag->setUser($this->user);
242 }
243
244 return $wallabag;
245 } 245 }
246} 246}
diff --git a/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php b/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php
index c186c820..a1783bfc 100644
--- a/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php
+++ b/tests/Wallabag/ImportBundle/Import/FirefoxImportTest.php
@@ -2,14 +2,14 @@
2 2
3namespace Tests\Wallabag\ImportBundle\Import; 3namespace Tests\Wallabag\ImportBundle\Import;
4 4
5use Wallabag\ImportBundle\Import\FirefoxImport; 5use M6Web\Component\RedisMock\RedisMockFactory;
6use Wallabag\UserBundle\Entity\User;
7use Wallabag\CoreBundle\Entity\Entry;
8use Wallabag\ImportBundle\Redis\Producer;
9use Monolog\Logger;
10use Monolog\Handler\TestHandler; 6use Monolog\Handler\TestHandler;
7use Monolog\Logger;
11use Simpleue\Queue\RedisQueue; 8use Simpleue\Queue\RedisQueue;
12use M6Web\Component\RedisMock\RedisMockFactory; 9use Wallabag\CoreBundle\Entity\Entry;
10use Wallabag\ImportBundle\Import\FirefoxImport;
11use Wallabag\ImportBundle\Redis\Producer;
12use Wallabag\UserBundle\Entity\User;
13 13
14class FirefoxImportTest extends \PHPUnit_Framework_TestCase 14class FirefoxImportTest extends \PHPUnit_Framework_TestCase
15{ 15{
@@ -19,56 +19,19 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase
19 protected $contentProxy; 19 protected $contentProxy;
20 protected $tagsAssigner; 20 protected $tagsAssigner;
21 21
22 private function getFirefoxImport($unsetUser = false, $dispatched = 0)
23 {
24 $this->user = new User();
25
26 $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
27 ->disableOriginalConstructor()
28 ->getMock();
29
30 $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy')
31 ->disableOriginalConstructor()
32 ->getMock();
33
34 $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
35 ->disableOriginalConstructor()
36 ->getMock();
37
38 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
39 ->disableOriginalConstructor()
40 ->getMock();
41
42 $dispatcher
43 ->expects($this->exactly($dispatched))
44 ->method('dispatch');
45
46 $wallabag = new FirefoxImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher);
47
48 $this->logHandler = new TestHandler();
49 $logger = new Logger('test', [$this->logHandler]);
50 $wallabag->setLogger($logger);
51
52 if (false === $unsetUser) {
53 $wallabag->setUser($this->user);
54 }
55
56 return $wallabag;
57 }
58
59 public function testInit() 22 public function testInit()
60 { 23 {
61 $firefoxImport = $this->getFirefoxImport(); 24 $firefoxImport = $this->getFirefoxImport();
62 25
63 $this->assertEquals('Firefox', $firefoxImport->getName()); 26 $this->assertSame('Firefox', $firefoxImport->getName());
64 $this->assertNotEmpty($firefoxImport->getUrl()); 27 $this->assertNotEmpty($firefoxImport->getUrl());
65 $this->assertEquals('import.firefox.description', $firefoxImport->getDescription()); 28 $this->assertSame('import.firefox.description', $firefoxImport->getDescription());
66 } 29 }
67 30
68 public function testImport() 31 public function testImport()
69 { 32 {
70 $firefoxImport = $this->getFirefoxImport(false, 2); 33 $firefoxImport = $this->getFirefoxImport(false, 2);
71 $firefoxImport->setFilepath(__DIR__.'/../fixtures/firefox-bookmarks.json'); 34 $firefoxImport->setFilepath(__DIR__ . '/../fixtures/firefox-bookmarks.json');
72 35
73 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 36 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
74 ->disableOriginalConstructor() 37 ->disableOriginalConstructor()
@@ -95,13 +58,13 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase
95 $res = $firefoxImport->import(); 58 $res = $firefoxImport->import();
96 59
97 $this->assertTrue($res); 60 $this->assertTrue($res);
98 $this->assertEquals(['skipped' => 0, 'imported' => 2, 'queued' => 0], $firefoxImport->getSummary()); 61 $this->assertSame(['skipped' => 0, 'imported' => 2, 'queued' => 0], $firefoxImport->getSummary());
99 } 62 }
100 63
101 public function testImportAndMarkAllAsRead() 64 public function testImportAndMarkAllAsRead()
102 { 65 {
103 $firefoxImport = $this->getFirefoxImport(false, 1); 66 $firefoxImport = $this->getFirefoxImport(false, 1);
104 $firefoxImport->setFilepath(__DIR__.'/../fixtures/firefox-bookmarks.json'); 67 $firefoxImport->setFilepath(__DIR__ . '/../fixtures/firefox-bookmarks.json');
105 68
106 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 69 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
107 ->disableOriginalConstructor() 70 ->disableOriginalConstructor()
@@ -133,13 +96,13 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase
133 96
134 $this->assertTrue($res); 97 $this->assertTrue($res);
135 98
136 $this->assertEquals(['skipped' => 1, 'imported' => 1, 'queued' => 0], $firefoxImport->getSummary()); 99 $this->assertSame(['skipped' => 1, 'imported' => 1, 'queued' => 0], $firefoxImport->getSummary());
137 } 100 }
138 101
139 public function testImportWithRabbit() 102 public function testImportWithRabbit()
140 { 103 {
141 $firefoxImport = $this->getFirefoxImport(); 104 $firefoxImport = $this->getFirefoxImport();
142 $firefoxImport->setFilepath(__DIR__.'/../fixtures/firefox-bookmarks.json'); 105 $firefoxImport->setFilepath(__DIR__ . '/../fixtures/firefox-bookmarks.json');
143 106
144 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 107 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
145 ->disableOriginalConstructor() 108 ->disableOriginalConstructor()
@@ -173,13 +136,13 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase
173 $res = $firefoxImport->setMarkAsRead(true)->import(); 136 $res = $firefoxImport->setMarkAsRead(true)->import();
174 137
175 $this->assertTrue($res); 138 $this->assertTrue($res);
176 $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 1], $firefoxImport->getSummary()); 139 $this->assertSame(['skipped' => 0, 'imported' => 0, 'queued' => 1], $firefoxImport->getSummary());
177 } 140 }
178 141
179 public function testImportWithRedis() 142 public function testImportWithRedis()
180 { 143 {
181 $firefoxImport = $this->getFirefoxImport(); 144 $firefoxImport = $this->getFirefoxImport();
182 $firefoxImport->setFilepath(__DIR__.'/../fixtures/firefox-bookmarks.json'); 145 $firefoxImport->setFilepath(__DIR__ . '/../fixtures/firefox-bookmarks.json');
183 146
184 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 147 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
185 ->disableOriginalConstructor() 148 ->disableOriginalConstructor()
@@ -211,7 +174,7 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase
211 $res = $firefoxImport->setMarkAsRead(true)->import(); 174 $res = $firefoxImport->setMarkAsRead(true)->import();
212 175
213 $this->assertTrue($res); 176 $this->assertTrue($res);
214 $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 1], $firefoxImport->getSummary()); 177 $this->assertSame(['skipped' => 0, 'imported' => 0, 'queued' => 1], $firefoxImport->getSummary());
215 178
216 $this->assertNotEmpty($redisMock->lpop('firefox')); 179 $this->assertNotEmpty($redisMock->lpop('firefox'));
217 } 180 }
@@ -219,7 +182,7 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase
219 public function testImportBadFile() 182 public function testImportBadFile()
220 { 183 {
221 $firefoxImport = $this->getFirefoxImport(); 184 $firefoxImport = $this->getFirefoxImport();
222 $firefoxImport->setFilepath(__DIR__.'/../fixtures/wallabag-v1.jsonx'); 185 $firefoxImport->setFilepath(__DIR__ . '/../fixtures/wallabag-v1.jsonx');
223 186
224 $res = $firefoxImport->import(); 187 $res = $firefoxImport->import();
225 188
@@ -227,13 +190,13 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase
227 190
228 $records = $this->logHandler->getRecords(); 191 $records = $this->logHandler->getRecords();
229 $this->assertContains('Wallabag Browser Import: unable to read file', $records[0]['message']); 192 $this->assertContains('Wallabag Browser Import: unable to read file', $records[0]['message']);
230 $this->assertEquals('ERROR', $records[0]['level_name']); 193 $this->assertSame('ERROR', $records[0]['level_name']);
231 } 194 }
232 195
233 public function testImportUserNotDefined() 196 public function testImportUserNotDefined()
234 { 197 {
235 $firefoxImport = $this->getFirefoxImport(true); 198 $firefoxImport = $this->getFirefoxImport(true);
236 $firefoxImport->setFilepath(__DIR__.'/../fixtures/firefox-bookmarks.json'); 199 $firefoxImport->setFilepath(__DIR__ . '/../fixtures/firefox-bookmarks.json');
237 200
238 $res = $firefoxImport->import(); 201 $res = $firefoxImport->import();
239 202
@@ -241,6 +204,43 @@ class FirefoxImportTest extends \PHPUnit_Framework_TestCase
241 204
242 $records = $this->logHandler->getRecords(); 205 $records = $this->logHandler->getRecords();
243 $this->assertContains('Wallabag Browser Import: user is not defined', $records[0]['message']); 206 $this->assertContains('Wallabag Browser Import: user is not defined', $records[0]['message']);
244 $this->assertEquals('ERROR', $records[0]['level_name']); 207 $this->assertSame('ERROR', $records[0]['level_name']);
208 }
209
210 private function getFirefoxImport($unsetUser = false, $dispatched = 0)
211 {
212 $this->user = new User();
213
214 $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
215 ->disableOriginalConstructor()
216 ->getMock();
217
218 $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy')
219 ->disableOriginalConstructor()
220 ->getMock();
221
222 $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
223 ->disableOriginalConstructor()
224 ->getMock();
225
226 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
227 ->disableOriginalConstructor()
228 ->getMock();
229
230 $dispatcher
231 ->expects($this->exactly($dispatched))
232 ->method('dispatch');
233
234 $wallabag = new FirefoxImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher);
235
236 $this->logHandler = new TestHandler();
237 $logger = new Logger('test', [$this->logHandler]);
238 $wallabag->setLogger($logger);
239
240 if (false === $unsetUser) {
241 $wallabag->setUser($this->user);
242 }
243
244 return $wallabag;
245 } 245 }
246} 246}
diff --git a/tests/Wallabag/ImportBundle/Import/ImportChainTest.php b/tests/Wallabag/ImportBundle/Import/ImportChainTest.php
index 32568ce5..a9a9915e 100644
--- a/tests/Wallabag/ImportBundle/Import/ImportChainTest.php
+++ b/tests/Wallabag/ImportBundle/Import/ImportChainTest.php
@@ -16,6 +16,6 @@ class ImportChainTest extends \PHPUnit_Framework_TestCase
16 $importChain->addImport($import, 'alias'); 16 $importChain->addImport($import, 'alias');
17 17
18 $this->assertCount(1, $importChain->getAll()); 18 $this->assertCount(1, $importChain->getAll());
19 $this->assertEquals($import, $importChain->getAll()['alias']); 19 $this->assertSame($import, $importChain->getAll()['alias']);
20 } 20 }
21} 21}
diff --git a/tests/Wallabag/ImportBundle/Import/ImportCompilerPassTest.php b/tests/Wallabag/ImportBundle/Import/ImportCompilerPassTest.php
index 71a007a9..207054f4 100644
--- a/tests/Wallabag/ImportBundle/Import/ImportCompilerPassTest.php
+++ b/tests/Wallabag/ImportBundle/Import/ImportCompilerPassTest.php
@@ -36,7 +36,7 @@ class ImportCompilerPassTest extends \PHPUnit_Framework_TestCase
36 $this->assertTrue($definition->hasMethodCall('addImport')); 36 $this->assertTrue($definition->hasMethodCall('addImport'));
37 37
38 $calls = $definition->getMethodCalls(); 38 $calls = $definition->getMethodCalls();
39 $this->assertEquals('pocket', $calls[0][1][1]); 39 $this->assertSame('pocket', $calls[0][1][1]);
40 } 40 }
41 41
42 protected function process(ContainerBuilder $container) 42 protected function process(ContainerBuilder $container)
diff --git a/tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php b/tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php
index 9158c8a2..274dc326 100644
--- a/tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php
+++ b/tests/Wallabag/ImportBundle/Import/InstapaperImportTest.php
@@ -2,14 +2,14 @@
2 2
3namespace Tests\Wallabag\ImportBundle\Import; 3namespace Tests\Wallabag\ImportBundle\Import;
4 4
5use Wallabag\ImportBundle\Import\InstapaperImport; 5use M6Web\Component\RedisMock\RedisMockFactory;
6use Wallabag\UserBundle\Entity\User;
7use Wallabag\CoreBundle\Entity\Entry;
8use Wallabag\ImportBundle\Redis\Producer;
9use Monolog\Logger;
10use Monolog\Handler\TestHandler; 6use Monolog\Handler\TestHandler;
7use Monolog\Logger;
11use Simpleue\Queue\RedisQueue; 8use Simpleue\Queue\RedisQueue;
12use M6Web\Component\RedisMock\RedisMockFactory; 9use Wallabag\CoreBundle\Entity\Entry;
10use Wallabag\ImportBundle\Import\InstapaperImport;
11use Wallabag\ImportBundle\Redis\Producer;
12use Wallabag\UserBundle\Entity\User;
13 13
14class InstapaperImportTest extends \PHPUnit_Framework_TestCase 14class InstapaperImportTest extends \PHPUnit_Framework_TestCase
15{ 15{
@@ -20,70 +20,19 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase
20 protected $tagsAssigner; 20 protected $tagsAssigner;
21 protected $uow; 21 protected $uow;
22 22
23 private function getInstapaperImport($unsetUser = false, $dispatched = 0)
24 {
25 $this->user = new User();
26
27 $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
28 ->disableOriginalConstructor()
29 ->getMock();
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
45 $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy')
46 ->disableOriginalConstructor()
47 ->getMock();
48
49 $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
50 ->disableOriginalConstructor()
51 ->getMock();
52
53 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
54 ->disableOriginalConstructor()
55 ->getMock();
56
57 $dispatcher
58 ->expects($this->exactly($dispatched))
59 ->method('dispatch');
60
61 $import = new InstapaperImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher);
62
63 $this->logHandler = new TestHandler();
64 $logger = new Logger('test', [$this->logHandler]);
65 $import->setLogger($logger);
66
67 if (false === $unsetUser) {
68 $import->setUser($this->user);
69 }
70
71 return $import;
72 }
73
74 public function testInit() 23 public function testInit()
75 { 24 {
76 $instapaperImport = $this->getInstapaperImport(); 25 $instapaperImport = $this->getInstapaperImport();
77 26
78 $this->assertEquals('Instapaper', $instapaperImport->getName()); 27 $this->assertSame('Instapaper', $instapaperImport->getName());
79 $this->assertNotEmpty($instapaperImport->getUrl()); 28 $this->assertNotEmpty($instapaperImport->getUrl());
80 $this->assertEquals('import.instapaper.description', $instapaperImport->getDescription()); 29 $this->assertSame('import.instapaper.description', $instapaperImport->getDescription());
81 } 30 }
82 31
83 public function testImport() 32 public function testImport()
84 { 33 {
85 $instapaperImport = $this->getInstapaperImport(false, 4); 34 $instapaperImport = $this->getInstapaperImport(false, 4);
86 $instapaperImport->setFilepath(__DIR__.'/../fixtures/instapaper-export.csv'); 35 $instapaperImport->setFilepath(__DIR__ . '/../fixtures/instapaper-export.csv');
87 36
88 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 37 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
89 ->disableOriginalConstructor() 38 ->disableOriginalConstructor()
@@ -110,13 +59,13 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase
110 $res = $instapaperImport->import(); 59 $res = $instapaperImport->import();
111 60
112 $this->assertTrue($res); 61 $this->assertTrue($res);
113 $this->assertEquals(['skipped' => 0, 'imported' => 4, 'queued' => 0], $instapaperImport->getSummary()); 62 $this->assertSame(['skipped' => 0, 'imported' => 4, 'queued' => 0], $instapaperImport->getSummary());
114 } 63 }
115 64
116 public function testImportAndMarkAllAsRead() 65 public function testImportAndMarkAllAsRead()
117 { 66 {
118 $instapaperImport = $this->getInstapaperImport(false, 1); 67 $instapaperImport = $this->getInstapaperImport(false, 1);
119 $instapaperImport->setFilepath(__DIR__.'/../fixtures/instapaper-export.csv'); 68 $instapaperImport->setFilepath(__DIR__ . '/../fixtures/instapaper-export.csv');
120 69
121 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 70 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
122 ->disableOriginalConstructor() 71 ->disableOriginalConstructor()
@@ -148,13 +97,13 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase
148 97
149 $this->assertTrue($res); 98 $this->assertTrue($res);
150 99
151 $this->assertEquals(['skipped' => 3, 'imported' => 1, 'queued' => 0], $instapaperImport->getSummary()); 100 $this->assertSame(['skipped' => 3, 'imported' => 1, 'queued' => 0], $instapaperImport->getSummary());
152 } 101 }
153 102
154 public function testImportWithRabbit() 103 public function testImportWithRabbit()
155 { 104 {
156 $instapaperImport = $this->getInstapaperImport(); 105 $instapaperImport = $this->getInstapaperImport();
157 $instapaperImport->setFilepath(__DIR__.'/../fixtures/instapaper-export.csv'); 106 $instapaperImport->setFilepath(__DIR__ . '/../fixtures/instapaper-export.csv');
158 107
159 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 108 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
160 ->disableOriginalConstructor() 109 ->disableOriginalConstructor()
@@ -188,13 +137,13 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase
188 $res = $instapaperImport->setMarkAsRead(true)->import(); 137 $res = $instapaperImport->setMarkAsRead(true)->import();
189 138
190 $this->assertTrue($res); 139 $this->assertTrue($res);
191 $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 4], $instapaperImport->getSummary()); 140 $this->assertSame(['skipped' => 0, 'imported' => 0, 'queued' => 4], $instapaperImport->getSummary());
192 } 141 }
193 142
194 public function testImportWithRedis() 143 public function testImportWithRedis()
195 { 144 {
196 $instapaperImport = $this->getInstapaperImport(); 145 $instapaperImport = $this->getInstapaperImport();
197 $instapaperImport->setFilepath(__DIR__.'/../fixtures/instapaper-export.csv'); 146 $instapaperImport->setFilepath(__DIR__ . '/../fixtures/instapaper-export.csv');
198 147
199 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 148 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
200 ->disableOriginalConstructor() 149 ->disableOriginalConstructor()
@@ -226,7 +175,7 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase
226 $res = $instapaperImport->setMarkAsRead(true)->import(); 175 $res = $instapaperImport->setMarkAsRead(true)->import();
227 176
228 $this->assertTrue($res); 177 $this->assertTrue($res);
229 $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 4], $instapaperImport->getSummary()); 178 $this->assertSame(['skipped' => 0, 'imported' => 0, 'queued' => 4], $instapaperImport->getSummary());
230 179
231 $this->assertNotEmpty($redisMock->lpop('instapaper')); 180 $this->assertNotEmpty($redisMock->lpop('instapaper'));
232 } 181 }
@@ -234,7 +183,7 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase
234 public function testImportBadFile() 183 public function testImportBadFile()
235 { 184 {
236 $instapaperImport = $this->getInstapaperImport(); 185 $instapaperImport = $this->getInstapaperImport();
237 $instapaperImport->setFilepath(__DIR__.'/../fixtures/wallabag-v1.jsonx'); 186 $instapaperImport->setFilepath(__DIR__ . '/../fixtures/wallabag-v1.jsonx');
238 187
239 $res = $instapaperImport->import(); 188 $res = $instapaperImport->import();
240 189
@@ -242,13 +191,13 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase
242 191
243 $records = $this->logHandler->getRecords(); 192 $records = $this->logHandler->getRecords();
244 $this->assertContains('InstapaperImport: unable to read file', $records[0]['message']); 193 $this->assertContains('InstapaperImport: unable to read file', $records[0]['message']);
245 $this->assertEquals('ERROR', $records[0]['level_name']); 194 $this->assertSame('ERROR', $records[0]['level_name']);
246 } 195 }
247 196
248 public function testImportUserNotDefined() 197 public function testImportUserNotDefined()
249 { 198 {
250 $instapaperImport = $this->getInstapaperImport(true); 199 $instapaperImport = $this->getInstapaperImport(true);
251 $instapaperImport->setFilepath(__DIR__.'/../fixtures/instapaper-export.csv'); 200 $instapaperImport->setFilepath(__DIR__ . '/../fixtures/instapaper-export.csv');
252 201
253 $res = $instapaperImport->import(); 202 $res = $instapaperImport->import();
254 203
@@ -256,6 +205,57 @@ class InstapaperImportTest extends \PHPUnit_Framework_TestCase
256 205
257 $records = $this->logHandler->getRecords(); 206 $records = $this->logHandler->getRecords();
258 $this->assertContains('InstapaperImport: user is not defined', $records[0]['message']); 207 $this->assertContains('InstapaperImport: user is not defined', $records[0]['message']);
259 $this->assertEquals('ERROR', $records[0]['level_name']); 208 $this->assertSame('ERROR', $records[0]['level_name']);
209 }
210
211 private function getInstapaperImport($unsetUser = false, $dispatched = 0)
212 {
213 $this->user = new User();
214
215 $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
216 ->disableOriginalConstructor()
217 ->getMock();
218
219 $this->uow = $this->getMockBuilder('Doctrine\ORM\UnitOfWork')
220 ->disableOriginalConstructor()
221 ->getMock();
222
223 $this->em
224 ->expects($this->any())
225 ->method('getUnitOfWork')
226 ->willReturn($this->uow);
227
228 $this->uow
229 ->expects($this->any())
230 ->method('getScheduledEntityInsertions')
231 ->willReturn([]);
232
233 $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy')
234 ->disableOriginalConstructor()
235 ->getMock();
236
237 $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
238 ->disableOriginalConstructor()
239 ->getMock();
240
241 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
242 ->disableOriginalConstructor()
243 ->getMock();
244
245 $dispatcher
246 ->expects($this->exactly($dispatched))
247 ->method('dispatch');
248
249 $import = new InstapaperImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher);
250
251 $this->logHandler = new TestHandler();
252 $logger = new Logger('test', [$this->logHandler]);
253 $import->setLogger($logger);
254
255 if (false === $unsetUser) {
256 $import->setUser($this->user);
257 }
258
259 return $import;
260 } 260 }
261} 261}
diff --git a/tests/Wallabag/ImportBundle/Import/PocketImportTest.php b/tests/Wallabag/ImportBundle/Import/PocketImportTest.php
index b81ebe15..fe59f867 100644
--- a/tests/Wallabag/ImportBundle/Import/PocketImportTest.php
+++ b/tests/Wallabag/ImportBundle/Import/PocketImportTest.php
@@ -2,19 +2,19 @@
2 2
3namespace Tests\Wallabag\ImportBundle\Import; 3namespace Tests\Wallabag\ImportBundle\Import;
4 4
5use Wallabag\UserBundle\Entity\User;
6use Wallabag\CoreBundle\Entity\Entry;
7use Wallabag\CoreBundle\Entity\Config;
8use Wallabag\ImportBundle\Import\PocketImport;
9use GuzzleHttp\Client; 5use GuzzleHttp\Client;
10use GuzzleHttp\Subscriber\Mock;
11use GuzzleHttp\Message\Response; 6use GuzzleHttp\Message\Response;
12use GuzzleHttp\Stream\Stream; 7use GuzzleHttp\Stream\Stream;
13use Wallabag\ImportBundle\Redis\Producer; 8use GuzzleHttp\Subscriber\Mock;
14use Monolog\Logger; 9use M6Web\Component\RedisMock\RedisMockFactory;
15use Monolog\Handler\TestHandler; 10use Monolog\Handler\TestHandler;
11use Monolog\Logger;
16use Simpleue\Queue\RedisQueue; 12use Simpleue\Queue\RedisQueue;
17use M6Web\Component\RedisMock\RedisMockFactory; 13use Wallabag\CoreBundle\Entity\Config;
14use Wallabag\CoreBundle\Entity\Entry;
15use Wallabag\ImportBundle\Import\PocketImport;
16use Wallabag\ImportBundle\Redis\Producer;
17use Wallabag\UserBundle\Entity\User;
18 18
19class PocketImportTest extends \PHPUnit_Framework_TestCase 19class PocketImportTest extends \PHPUnit_Framework_TestCase
20{ 20{
@@ -26,66 +26,13 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase
26 protected $tagsAssigner; 26 protected $tagsAssigner;
27 protected $uow; 27 protected $uow;
28 28
29 private function getPocketImport($consumerKey = 'ConsumerKey', $dispatched = 0)
30 {
31 $this->user = new User();
32
33 $config = new Config($this->user);
34 $config->setPocketConsumerKey('xxx');
35
36 $this->user->setConfig($config);
37
38 $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy')
39 ->disableOriginalConstructor()
40 ->getMock();
41
42 $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
43 ->disableOriginalConstructor()
44 ->getMock();
45
46 $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
47 ->disableOriginalConstructor()
48 ->getMock();
49
50 $this->uow = $this->getMockBuilder('Doctrine\ORM\UnitOfWork')
51 ->disableOriginalConstructor()
52 ->getMock();
53
54 $this->em
55 ->expects($this->any())
56 ->method('getUnitOfWork')
57 ->willReturn($this->uow);
58
59 $this->uow
60 ->expects($this->any())
61 ->method('getScheduledEntityInsertions')
62 ->willReturn([]);
63
64 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
65 ->disableOriginalConstructor()
66 ->getMock();
67
68 $dispatcher
69 ->expects($this->exactly($dispatched))
70 ->method('dispatch');
71
72 $pocket = new PocketImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher);
73 $pocket->setUser($this->user);
74
75 $this->logHandler = new TestHandler();
76 $logger = new Logger('test', [$this->logHandler]);
77 $pocket->setLogger($logger);
78
79 return $pocket;
80 }
81
82 public function testInit() 29 public function testInit()
83 { 30 {
84 $pocketImport = $this->getPocketImport(); 31 $pocketImport = $this->getPocketImport();
85 32
86 $this->assertEquals('Pocket', $pocketImport->getName()); 33 $this->assertSame('Pocket', $pocketImport->getName());
87 $this->assertNotEmpty($pocketImport->getUrl()); 34 $this->assertNotEmpty($pocketImport->getUrl());
88 $this->assertEquals('import.pocket.description', $pocketImport->getDescription()); 35 $this->assertSame('import.pocket.description', $pocketImport->getDescription());
89 } 36 }
90 37
91 public function testOAuthRequest() 38 public function testOAuthRequest()
@@ -103,7 +50,7 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase
103 50
104 $code = $pocketImport->getRequestToken('http://0.0.0.0/redirect'); 51 $code = $pocketImport->getRequestToken('http://0.0.0.0/redirect');
105 52
106 $this->assertEquals('wunderbar_code', $code); 53 $this->assertSame('wunderbar_code', $code);
107 } 54 }
108 55
109 public function testOAuthRequestBadResponse() 56 public function testOAuthRequestBadResponse()
@@ -125,7 +72,7 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase
125 72
126 $records = $this->logHandler->getRecords(); 73 $records = $this->logHandler->getRecords();
127 $this->assertContains('PocketImport: Failed to request token', $records[0]['message']); 74 $this->assertContains('PocketImport: Failed to request token', $records[0]['message']);
128 $this->assertEquals('ERROR', $records[0]['level_name']); 75 $this->assertSame('ERROR', $records[0]['level_name']);
129 } 76 }
130 77
131 public function testOAuthAuthorize() 78 public function testOAuthAuthorize()
@@ -144,7 +91,7 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase
144 $res = $pocketImport->authorize('wunderbar_code'); 91 $res = $pocketImport->authorize('wunderbar_code');
145 92
146 $this->assertTrue($res); 93 $this->assertTrue($res);
147 $this->assertEquals('wunderbar_token', $pocketImport->getAccessToken()); 94 $this->assertSame('wunderbar_token', $pocketImport->getAccessToken());
148 } 95 }
149 96
150 public function testOAuthAuthorizeBadResponse() 97 public function testOAuthAuthorizeBadResponse()
@@ -166,7 +113,7 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase
166 113
167 $records = $this->logHandler->getRecords(); 114 $records = $this->logHandler->getRecords();
168 $this->assertContains('PocketImport: Failed to authorize client', $records[0]['message']); 115 $this->assertContains('PocketImport: Failed to authorize client', $records[0]['message']);
169 $this->assertEquals('ERROR', $records[0]['level_name']); 116 $this->assertSame('ERROR', $records[0]['level_name']);
170 } 117 }
171 118
172 /** 119 /**
@@ -291,7 +238,7 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase
291 $res = $pocketImport->import(); 238 $res = $pocketImport->import();
292 239
293 $this->assertTrue($res); 240 $this->assertTrue($res);
294 $this->assertEquals(['skipped' => 1, 'imported' => 1, 'queued' => 0], $pocketImport->getSummary()); 241 $this->assertSame(['skipped' => 1, 'imported' => 1, 'queued' => 0], $pocketImport->getSummary());
295 } 242 }
296 243
297 /** 244 /**
@@ -386,7 +333,7 @@ class PocketImportTest extends \PHPUnit_Framework_TestCase
386 $res = $pocketImport->setMarkAsRead(true)->import(); 333 $res = $pocketImport->setMarkAsRead(true)->import();
387 334
388 $this->assertTrue($res); 335 $this->assertTrue($res);
389 $this->assertEquals(['skipped' => 0, 'imported' => 2, 'queued' => 0], $pocketImport->getSummary()); 336 $this->assertSame(['skipped' => 0, 'imported' => 2, 'queued' => 0], $pocketImport->getSummary());
390 } 337 }
391 338
392 /** 339 /**
@@ -425,7 +372,7 @@ JSON;
425 { 372 {
426 "status": 1, 373 "status": 1,
427 "list": { 374 "list": {
428 "229279690": '.$body.' 375 "229279690": ' . $body . '
429 } 376 }
430 } 377 }
431 ')), 378 ')),
@@ -472,7 +419,7 @@ JSON;
472 $res = $pocketImport->setMarkAsRead(true)->import(); 419 $res = $pocketImport->setMarkAsRead(true)->import();
473 420
474 $this->assertTrue($res); 421 $this->assertTrue($res);
475 $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 1], $pocketImport->getSummary()); 422 $this->assertSame(['skipped' => 0, 'imported' => 0, 'queued' => 1], $pocketImport->getSummary());
476 } 423 }
477 424
478 /** 425 /**
@@ -511,7 +458,7 @@ JSON;
511 { 458 {
512 "status": 1, 459 "status": 1,
513 "list": { 460 "list": {
514 "229279690": '.$body.' 461 "229279690": ' . $body . '
515 } 462 }
516 } 463 }
517 ')), 464 ')),
@@ -551,7 +498,7 @@ JSON;
551 $res = $pocketImport->setMarkAsRead(true)->import(); 498 $res = $pocketImport->setMarkAsRead(true)->import();
552 499
553 $this->assertTrue($res); 500 $this->assertTrue($res);
554 $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 1], $pocketImport->getSummary()); 501 $this->assertSame(['skipped' => 0, 'imported' => 0, 'queued' => 1], $pocketImport->getSummary());
555 502
556 $this->assertNotEmpty($redisMock->lpop('pocket')); 503 $this->assertNotEmpty($redisMock->lpop('pocket'));
557 } 504 }
@@ -577,7 +524,7 @@ JSON;
577 524
578 $records = $this->logHandler->getRecords(); 525 $records = $this->logHandler->getRecords();
579 $this->assertContains('PocketImport: Failed to import', $records[0]['message']); 526 $this->assertContains('PocketImport: Failed to import', $records[0]['message']);
580 $this->assertEquals('ERROR', $records[0]['level_name']); 527 $this->assertSame('ERROR', $records[0]['level_name']);
581 } 528 }
582 529
583 public function testImportWithExceptionFromGraby() 530 public function testImportWithExceptionFromGraby()
@@ -630,6 +577,59 @@ JSON;
630 $res = $pocketImport->import(); 577 $res = $pocketImport->import();
631 578
632 $this->assertTrue($res); 579 $this->assertTrue($res);
633 $this->assertEquals(['skipped' => 0, 'imported' => 1, 'queued' => 0], $pocketImport->getSummary()); 580 $this->assertSame(['skipped' => 0, 'imported' => 1, 'queued' => 0], $pocketImport->getSummary());
581 }
582
583 private function getPocketImport($consumerKey = 'ConsumerKey', $dispatched = 0)
584 {
585 $this->user = new User();
586
587 $config = new Config($this->user);
588 $config->setPocketConsumerKey('xxx');
589
590 $this->user->setConfig($config);
591
592 $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy')
593 ->disableOriginalConstructor()
594 ->getMock();
595
596 $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
597 ->disableOriginalConstructor()
598 ->getMock();
599
600 $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
601 ->disableOriginalConstructor()
602 ->getMock();
603
604 $this->uow = $this->getMockBuilder('Doctrine\ORM\UnitOfWork')
605 ->disableOriginalConstructor()
606 ->getMock();
607
608 $this->em
609 ->expects($this->any())
610 ->method('getUnitOfWork')
611 ->willReturn($this->uow);
612
613 $this->uow
614 ->expects($this->any())
615 ->method('getScheduledEntityInsertions')
616 ->willReturn([]);
617
618 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
619 ->disableOriginalConstructor()
620 ->getMock();
621
622 $dispatcher
623 ->expects($this->exactly($dispatched))
624 ->method('dispatch');
625
626 $pocket = new PocketImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher);
627 $pocket->setUser($this->user);
628
629 $this->logHandler = new TestHandler();
630 $logger = new Logger('test', [$this->logHandler]);
631 $pocket->setLogger($logger);
632
633 return $pocket;
634 } 634 }
635} 635}
diff --git a/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php b/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php
index 8f466d38..1822cdaa 100644
--- a/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php
+++ b/tests/Wallabag/ImportBundle/Import/ReadabilityImportTest.php
@@ -2,14 +2,14 @@
2 2
3namespace Tests\Wallabag\ImportBundle\Import; 3namespace Tests\Wallabag\ImportBundle\Import;
4 4
5use Wallabag\ImportBundle\Import\ReadabilityImport; 5use M6Web\Component\RedisMock\RedisMockFactory;
6use Wallabag\UserBundle\Entity\User;
7use Wallabag\CoreBundle\Entity\Entry;
8use Wallabag\ImportBundle\Redis\Producer;
9use Monolog\Logger;
10use Monolog\Handler\TestHandler; 6use Monolog\Handler\TestHandler;
7use Monolog\Logger;
11use Simpleue\Queue\RedisQueue; 8use Simpleue\Queue\RedisQueue;
12use M6Web\Component\RedisMock\RedisMockFactory; 9use Wallabag\CoreBundle\Entity\Entry;
10use Wallabag\ImportBundle\Import\ReadabilityImport;
11use Wallabag\ImportBundle\Redis\Producer;
12use Wallabag\UserBundle\Entity\User;
13 13
14class ReadabilityImportTest extends \PHPUnit_Framework_TestCase 14class ReadabilityImportTest extends \PHPUnit_Framework_TestCase
15{ 15{
@@ -19,56 +19,19 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase
19 protected $contentProxy; 19 protected $contentProxy;
20 protected $tagsAssigner; 20 protected $tagsAssigner;
21 21
22 private function getReadabilityImport($unsetUser = false, $dispatched = 0)
23 {
24 $this->user = new User();
25
26 $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
27 ->disableOriginalConstructor()
28 ->getMock();
29
30 $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy')
31 ->disableOriginalConstructor()
32 ->getMock();
33
34 $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
35 ->disableOriginalConstructor()
36 ->getMock();
37
38 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
39 ->disableOriginalConstructor()
40 ->getMock();
41
42 $dispatcher
43 ->expects($this->exactly($dispatched))
44 ->method('dispatch');
45
46 $wallabag = new ReadabilityImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher);
47
48 $this->logHandler = new TestHandler();
49 $logger = new Logger('test', [$this->logHandler]);
50 $wallabag->setLogger($logger);
51
52 if (false === $unsetUser) {
53 $wallabag->setUser($this->user);
54 }
55
56 return $wallabag;
57 }
58
59 public function testInit() 22 public function testInit()
60 { 23 {
61 $readabilityImport = $this->getReadabilityImport(); 24 $readabilityImport = $this->getReadabilityImport();
62 25
63 $this->assertEquals('Readability', $readabilityImport->getName()); 26 $this->assertSame('Readability', $readabilityImport->getName());
64 $this->assertNotEmpty($readabilityImport->getUrl()); 27 $this->assertNotEmpty($readabilityImport->getUrl());
65 $this->assertEquals('import.readability.description', $readabilityImport->getDescription()); 28 $this->assertSame('import.readability.description', $readabilityImport->getDescription());
66 } 29 }
67 30
68 public function testImport() 31 public function testImport()
69 { 32 {
70 $readabilityImport = $this->getReadabilityImport(false, 3); 33 $readabilityImport = $this->getReadabilityImport(false, 3);
71 $readabilityImport->setFilepath(__DIR__.'/../fixtures/readability.json'); 34 $readabilityImport->setFilepath(__DIR__ . '/../fixtures/readability.json');
72 35
73 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 36 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
74 ->disableOriginalConstructor() 37 ->disableOriginalConstructor()
@@ -95,13 +58,13 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase
95 $res = $readabilityImport->import(); 58 $res = $readabilityImport->import();
96 59
97 $this->assertTrue($res); 60 $this->assertTrue($res);
98 $this->assertEquals(['skipped' => 0, 'imported' => 3, 'queued' => 0], $readabilityImport->getSummary()); 61 $this->assertSame(['skipped' => 0, 'imported' => 3, 'queued' => 0], $readabilityImport->getSummary());
99 } 62 }
100 63
101 public function testImportAndMarkAllAsRead() 64 public function testImportAndMarkAllAsRead()
102 { 65 {
103 $readabilityImport = $this->getReadabilityImport(false, 1); 66 $readabilityImport = $this->getReadabilityImport(false, 1);
104 $readabilityImport->setFilepath(__DIR__.'/../fixtures/readability-read.json'); 67 $readabilityImport->setFilepath(__DIR__ . '/../fixtures/readability-read.json');
105 68
106 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 69 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
107 ->disableOriginalConstructor() 70 ->disableOriginalConstructor()
@@ -133,13 +96,13 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase
133 96
134 $this->assertTrue($res); 97 $this->assertTrue($res);
135 98
136 $this->assertEquals(['skipped' => 1, 'imported' => 1, 'queued' => 0], $readabilityImport->getSummary()); 99 $this->assertSame(['skipped' => 1, 'imported' => 1, 'queued' => 0], $readabilityImport->getSummary());
137 } 100 }
138 101
139 public function testImportWithRabbit() 102 public function testImportWithRabbit()
140 { 103 {
141 $readabilityImport = $this->getReadabilityImport(); 104 $readabilityImport = $this->getReadabilityImport();
142 $readabilityImport->setFilepath(__DIR__.'/../fixtures/readability.json'); 105 $readabilityImport->setFilepath(__DIR__ . '/../fixtures/readability.json');
143 106
144 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 107 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
145 ->disableOriginalConstructor() 108 ->disableOriginalConstructor()
@@ -173,13 +136,13 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase
173 $res = $readabilityImport->setMarkAsRead(true)->import(); 136 $res = $readabilityImport->setMarkAsRead(true)->import();
174 137
175 $this->assertTrue($res); 138 $this->assertTrue($res);
176 $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 3], $readabilityImport->getSummary()); 139 $this->assertSame(['skipped' => 0, 'imported' => 0, 'queued' => 3], $readabilityImport->getSummary());
177 } 140 }
178 141
179 public function testImportWithRedis() 142 public function testImportWithRedis()
180 { 143 {
181 $readabilityImport = $this->getReadabilityImport(); 144 $readabilityImport = $this->getReadabilityImport();
182 $readabilityImport->setFilepath(__DIR__.'/../fixtures/readability.json'); 145 $readabilityImport->setFilepath(__DIR__ . '/../fixtures/readability.json');
183 146
184 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 147 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
185 ->disableOriginalConstructor() 148 ->disableOriginalConstructor()
@@ -211,7 +174,7 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase
211 $res = $readabilityImport->setMarkAsRead(true)->import(); 174 $res = $readabilityImport->setMarkAsRead(true)->import();
212 175
213 $this->assertTrue($res); 176 $this->assertTrue($res);
214 $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 3], $readabilityImport->getSummary()); 177 $this->assertSame(['skipped' => 0, 'imported' => 0, 'queued' => 3], $readabilityImport->getSummary());
215 178
216 $this->assertNotEmpty($redisMock->lpop('readability')); 179 $this->assertNotEmpty($redisMock->lpop('readability'));
217 } 180 }
@@ -219,7 +182,7 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase
219 public function testImportBadFile() 182 public function testImportBadFile()
220 { 183 {
221 $readabilityImport = $this->getReadabilityImport(); 184 $readabilityImport = $this->getReadabilityImport();
222 $readabilityImport->setFilepath(__DIR__.'/../fixtures/wallabag-v1.jsonx'); 185 $readabilityImport->setFilepath(__DIR__ . '/../fixtures/wallabag-v1.jsonx');
223 186
224 $res = $readabilityImport->import(); 187 $res = $readabilityImport->import();
225 188
@@ -227,13 +190,13 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase
227 190
228 $records = $this->logHandler->getRecords(); 191 $records = $this->logHandler->getRecords();
229 $this->assertContains('ReadabilityImport: unable to read file', $records[0]['message']); 192 $this->assertContains('ReadabilityImport: unable to read file', $records[0]['message']);
230 $this->assertEquals('ERROR', $records[0]['level_name']); 193 $this->assertSame('ERROR', $records[0]['level_name']);
231 } 194 }
232 195
233 public function testImportUserNotDefined() 196 public function testImportUserNotDefined()
234 { 197 {
235 $readabilityImport = $this->getReadabilityImport(true); 198 $readabilityImport = $this->getReadabilityImport(true);
236 $readabilityImport->setFilepath(__DIR__.'/../fixtures/readability.json'); 199 $readabilityImport->setFilepath(__DIR__ . '/../fixtures/readability.json');
237 200
238 $res = $readabilityImport->import(); 201 $res = $readabilityImport->import();
239 202
@@ -241,6 +204,43 @@ class ReadabilityImportTest extends \PHPUnit_Framework_TestCase
241 204
242 $records = $this->logHandler->getRecords(); 205 $records = $this->logHandler->getRecords();
243 $this->assertContains('ReadabilityImport: user is not defined', $records[0]['message']); 206 $this->assertContains('ReadabilityImport: user is not defined', $records[0]['message']);
244 $this->assertEquals('ERROR', $records[0]['level_name']); 207 $this->assertSame('ERROR', $records[0]['level_name']);
208 }
209
210 private function getReadabilityImport($unsetUser = false, $dispatched = 0)
211 {
212 $this->user = new User();
213
214 $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
215 ->disableOriginalConstructor()
216 ->getMock();
217
218 $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy')
219 ->disableOriginalConstructor()
220 ->getMock();
221
222 $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
223 ->disableOriginalConstructor()
224 ->getMock();
225
226 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
227 ->disableOriginalConstructor()
228 ->getMock();
229
230 $dispatcher
231 ->expects($this->exactly($dispatched))
232 ->method('dispatch');
233
234 $wallabag = new ReadabilityImport($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher);
235
236 $this->logHandler = new TestHandler();
237 $logger = new Logger('test', [$this->logHandler]);
238 $wallabag->setLogger($logger);
239
240 if (false === $unsetUser) {
241 $wallabag->setUser($this->user);
242 }
243
244 return $wallabag;
245 } 245 }
246} 246}
diff --git a/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php b/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php
index 834b7ef5..822ad694 100644
--- a/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php
+++ b/tests/Wallabag/ImportBundle/Import/WallabagV1ImportTest.php
@@ -2,14 +2,14 @@
2 2
3namespace Tests\Wallabag\ImportBundle\Import; 3namespace Tests\Wallabag\ImportBundle\Import;
4 4
5use Wallabag\ImportBundle\Import\WallabagV1Import; 5use M6Web\Component\RedisMock\RedisMockFactory;
6use Wallabag\UserBundle\Entity\User;
7use Wallabag\CoreBundle\Entity\Entry;
8use Wallabag\ImportBundle\Redis\Producer;
9use Monolog\Logger;
10use Monolog\Handler\TestHandler; 6use Monolog\Handler\TestHandler;
7use Monolog\Logger;
11use Simpleue\Queue\RedisQueue; 8use Simpleue\Queue\RedisQueue;
12use M6Web\Component\RedisMock\RedisMockFactory; 9use Wallabag\CoreBundle\Entity\Entry;
10use Wallabag\ImportBundle\Import\WallabagV1Import;
11use Wallabag\ImportBundle\Redis\Producer;
12use Wallabag\UserBundle\Entity\User;
13 13
14class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase 14class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
15{ 15{
@@ -22,77 +22,19 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
22 protected $fetchingErrorMessageTitle = 'No title found'; 22 protected $fetchingErrorMessageTitle = 'No title found';
23 protected $fetchingErrorMessage = 'wallabag can\'t retrieve contents for this article. Please <a href="http://doc.wallabag.org/en/master/user/errors_during_fetching.html#how-can-i-help-to-fix-that">troubleshoot this issue</a>.'; 23 protected $fetchingErrorMessage = 'wallabag can\'t retrieve contents for this article. Please <a href="http://doc.wallabag.org/en/master/user/errors_during_fetching.html#how-can-i-help-to-fix-that">troubleshoot this issue</a>.';
24 24
25 private function getWallabagV1Import($unsetUser = false, $dispatched = 0)
26 {
27 $this->user = new User();
28
29 $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
30 ->disableOriginalConstructor()
31 ->getMock();
32
33 $this->uow = $this->getMockBuilder('Doctrine\ORM\UnitOfWork')
34 ->disableOriginalConstructor()
35 ->getMock();
36
37 $this->em
38 ->expects($this->any())
39 ->method('getUnitOfWork')
40 ->willReturn($this->uow);
41
42 $this->uow
43 ->expects($this->any())
44 ->method('getScheduledEntityInsertions')
45 ->willReturn([]);
46
47 $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy')
48 ->disableOriginalConstructor()
49 ->getMock();
50
51 $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
52 ->disableOriginalConstructor()
53 ->getMock();
54
55 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
56 ->disableOriginalConstructor()
57 ->getMock();
58
59 $dispatcher
60 ->expects($this->exactly($dispatched))
61 ->method('dispatch');
62
63 $wallabag = new WallabagV1Import(
64 $this->em,
65 $this->contentProxy,
66 $this->tagsAssigner,
67 $dispatcher,
68 $this->fetchingErrorMessageTitle,
69 $this->fetchingErrorMessage
70 );
71
72 $this->logHandler = new TestHandler();
73 $logger = new Logger('test', [$this->logHandler]);
74 $wallabag->setLogger($logger);
75
76 if (false === $unsetUser) {
77 $wallabag->setUser($this->user);
78 }
79
80 return $wallabag;
81 }
82
83 public function testInit() 25 public function testInit()
84 { 26 {
85 $wallabagV1Import = $this->getWallabagV1Import(); 27 $wallabagV1Import = $this->getWallabagV1Import();
86 28
87 $this->assertEquals('wallabag v1', $wallabagV1Import->getName()); 29 $this->assertSame('wallabag v1', $wallabagV1Import->getName());
88 $this->assertNotEmpty($wallabagV1Import->getUrl()); 30 $this->assertNotEmpty($wallabagV1Import->getUrl());
89 $this->assertEquals('import.wallabag_v1.description', $wallabagV1Import->getDescription()); 31 $this->assertSame('import.wallabag_v1.description', $wallabagV1Import->getDescription());
90 } 32 }
91 33
92 public function testImport() 34 public function testImport()
93 { 35 {
94 $wallabagV1Import = $this->getWallabagV1Import(false, 1); 36 $wallabagV1Import = $this->getWallabagV1Import(false, 1);
95 $wallabagV1Import->setFilepath(__DIR__.'/../fixtures/wallabag-v1.json'); 37 $wallabagV1Import->setFilepath(__DIR__ . '/../fixtures/wallabag-v1.json');
96 38
97 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 39 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
98 ->disableOriginalConstructor() 40 ->disableOriginalConstructor()
@@ -119,13 +61,13 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
119 $res = $wallabagV1Import->import(); 61 $res = $wallabagV1Import->import();
120 62
121 $this->assertTrue($res); 63 $this->assertTrue($res);
122 $this->assertEquals(['skipped' => 1, 'imported' => 1, 'queued' => 0], $wallabagV1Import->getSummary()); 64 $this->assertSame(['skipped' => 1, 'imported' => 1, 'queued' => 0], $wallabagV1Import->getSummary());
123 } 65 }
124 66
125 public function testImportAndMarkAllAsRead() 67 public function testImportAndMarkAllAsRead()
126 { 68 {
127 $wallabagV1Import = $this->getWallabagV1Import(false, 3); 69 $wallabagV1Import = $this->getWallabagV1Import(false, 3);
128 $wallabagV1Import->setFilepath(__DIR__.'/../fixtures/wallabag-v1-read.json'); 70 $wallabagV1Import->setFilepath(__DIR__ . '/../fixtures/wallabag-v1-read.json');
129 71
130 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 72 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
131 ->disableOriginalConstructor() 73 ->disableOriginalConstructor()
@@ -157,13 +99,13 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
157 99
158 $this->assertTrue($res); 100 $this->assertTrue($res);
159 101
160 $this->assertEquals(['skipped' => 0, 'imported' => 3, 'queued' => 0], $wallabagV1Import->getSummary()); 102 $this->assertSame(['skipped' => 0, 'imported' => 3, 'queued' => 0], $wallabagV1Import->getSummary());
161 } 103 }
162 104
163 public function testImportWithRabbit() 105 public function testImportWithRabbit()
164 { 106 {
165 $wallabagV1Import = $this->getWallabagV1Import(); 107 $wallabagV1Import = $this->getWallabagV1Import();
166 $wallabagV1Import->setFilepath(__DIR__.'/../fixtures/wallabag-v1.json'); 108 $wallabagV1Import->setFilepath(__DIR__ . '/../fixtures/wallabag-v1.json');
167 109
168 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 110 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
169 ->disableOriginalConstructor() 111 ->disableOriginalConstructor()
@@ -197,13 +139,13 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
197 $res = $wallabagV1Import->setMarkAsRead(true)->import(); 139 $res = $wallabagV1Import->setMarkAsRead(true)->import();
198 140
199 $this->assertTrue($res); 141 $this->assertTrue($res);
200 $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 2], $wallabagV1Import->getSummary()); 142 $this->assertSame(['skipped' => 0, 'imported' => 0, 'queued' => 2], $wallabagV1Import->getSummary());
201 } 143 }
202 144
203 public function testImportWithRedis() 145 public function testImportWithRedis()
204 { 146 {
205 $wallabagV1Import = $this->getWallabagV1Import(); 147 $wallabagV1Import = $this->getWallabagV1Import();
206 $wallabagV1Import->setFilepath(__DIR__.'/../fixtures/wallabag-v1.json'); 148 $wallabagV1Import->setFilepath(__DIR__ . '/../fixtures/wallabag-v1.json');
207 149
208 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 150 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
209 ->disableOriginalConstructor() 151 ->disableOriginalConstructor()
@@ -235,7 +177,7 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
235 $res = $wallabagV1Import->setMarkAsRead(true)->import(); 177 $res = $wallabagV1Import->setMarkAsRead(true)->import();
236 178
237 $this->assertTrue($res); 179 $this->assertTrue($res);
238 $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 2], $wallabagV1Import->getSummary()); 180 $this->assertSame(['skipped' => 0, 'imported' => 0, 'queued' => 2], $wallabagV1Import->getSummary());
239 181
240 $this->assertNotEmpty($redisMock->lpop('wallabag_v1')); 182 $this->assertNotEmpty($redisMock->lpop('wallabag_v1'));
241 } 183 }
@@ -243,7 +185,7 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
243 public function testImportBadFile() 185 public function testImportBadFile()
244 { 186 {
245 $wallabagV1Import = $this->getWallabagV1Import(); 187 $wallabagV1Import = $this->getWallabagV1Import();
246 $wallabagV1Import->setFilepath(__DIR__.'/../fixtures/wallabag-v1.jsonx'); 188 $wallabagV1Import->setFilepath(__DIR__ . '/../fixtures/wallabag-v1.jsonx');
247 189
248 $res = $wallabagV1Import->import(); 190 $res = $wallabagV1Import->import();
249 191
@@ -251,13 +193,13 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
251 193
252 $records = $this->logHandler->getRecords(); 194 $records = $this->logHandler->getRecords();
253 $this->assertContains('WallabagImport: unable to read file', $records[0]['message']); 195 $this->assertContains('WallabagImport: unable to read file', $records[0]['message']);
254 $this->assertEquals('ERROR', $records[0]['level_name']); 196 $this->assertSame('ERROR', $records[0]['level_name']);
255 } 197 }
256 198
257 public function testImportUserNotDefined() 199 public function testImportUserNotDefined()
258 { 200 {
259 $wallabagV1Import = $this->getWallabagV1Import(true); 201 $wallabagV1Import = $this->getWallabagV1Import(true);
260 $wallabagV1Import->setFilepath(__DIR__.'/../fixtures/wallabag-v1.json'); 202 $wallabagV1Import->setFilepath(__DIR__ . '/../fixtures/wallabag-v1.json');
261 203
262 $res = $wallabagV1Import->import(); 204 $res = $wallabagV1Import->import();
263 205
@@ -265,6 +207,64 @@ class WallabagV1ImportTest extends \PHPUnit_Framework_TestCase
265 207
266 $records = $this->logHandler->getRecords(); 208 $records = $this->logHandler->getRecords();
267 $this->assertContains('WallabagImport: user is not defined', $records[0]['message']); 209 $this->assertContains('WallabagImport: user is not defined', $records[0]['message']);
268 $this->assertEquals('ERROR', $records[0]['level_name']); 210 $this->assertSame('ERROR', $records[0]['level_name']);
211 }
212
213 private function getWallabagV1Import($unsetUser = false, $dispatched = 0)
214 {
215 $this->user = new User();
216
217 $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
218 ->disableOriginalConstructor()
219 ->getMock();
220
221 $this->uow = $this->getMockBuilder('Doctrine\ORM\UnitOfWork')
222 ->disableOriginalConstructor()
223 ->getMock();
224
225 $this->em
226 ->expects($this->any())
227 ->method('getUnitOfWork')
228 ->willReturn($this->uow);
229
230 $this->uow
231 ->expects($this->any())
232 ->method('getScheduledEntityInsertions')
233 ->willReturn([]);
234
235 $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy')
236 ->disableOriginalConstructor()
237 ->getMock();
238
239 $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
240 ->disableOriginalConstructor()
241 ->getMock();
242
243 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
244 ->disableOriginalConstructor()
245 ->getMock();
246
247 $dispatcher
248 ->expects($this->exactly($dispatched))
249 ->method('dispatch');
250
251 $wallabag = new WallabagV1Import(
252 $this->em,
253 $this->contentProxy,
254 $this->tagsAssigner,
255 $dispatcher,
256 $this->fetchingErrorMessageTitle,
257 $this->fetchingErrorMessage
258 );
259
260 $this->logHandler = new TestHandler();
261 $logger = new Logger('test', [$this->logHandler]);
262 $wallabag->setLogger($logger);
263
264 if (false === $unsetUser) {
265 $wallabag->setUser($this->user);
266 }
267
268 return $wallabag;
269 } 269 }
270} 270}
diff --git a/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php b/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php
index 5cc04aa5..fab50a45 100644
--- a/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php
+++ b/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php
@@ -2,14 +2,14 @@
2 2
3namespace Tests\Wallabag\ImportBundle\Import; 3namespace Tests\Wallabag\ImportBundle\Import;
4 4
5use Wallabag\ImportBundle\Import\WallabagV2Import; 5use M6Web\Component\RedisMock\RedisMockFactory;
6use Wallabag\UserBundle\Entity\User;
7use Wallabag\CoreBundle\Entity\Entry;
8use Wallabag\ImportBundle\Redis\Producer;
9use Monolog\Logger;
10use Monolog\Handler\TestHandler; 6use Monolog\Handler\TestHandler;
7use Monolog\Logger;
11use Simpleue\Queue\RedisQueue; 8use Simpleue\Queue\RedisQueue;
12use M6Web\Component\RedisMock\RedisMockFactory; 9use Wallabag\CoreBundle\Entity\Entry;
10use Wallabag\ImportBundle\Import\WallabagV2Import;
11use Wallabag\ImportBundle\Redis\Producer;
12use Wallabag\UserBundle\Entity\User;
13 13
14class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase 14class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
15{ 15{
@@ -20,70 +20,19 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
20 protected $tagsAssigner; 20 protected $tagsAssigner;
21 protected $uow; 21 protected $uow;
22 22
23 private function getWallabagV2Import($unsetUser = false, $dispatched = 0)
24 {
25 $this->user = new User();
26
27 $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
28 ->disableOriginalConstructor()
29 ->getMock();
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
45 $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy')
46 ->disableOriginalConstructor()
47 ->getMock();
48
49 $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
50 ->disableOriginalConstructor()
51 ->getMock();
52
53 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
54 ->disableOriginalConstructor()
55 ->getMock();
56
57 $dispatcher
58 ->expects($this->exactly($dispatched))
59 ->method('dispatch');
60
61 $wallabag = new WallabagV2Import($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher);
62
63 $this->logHandler = new TestHandler();
64 $logger = new Logger('test', [$this->logHandler]);
65 $wallabag->setLogger($logger);
66
67 if (false === $unsetUser) {
68 $wallabag->setUser($this->user);
69 }
70
71 return $wallabag;
72 }
73
74 public function testInit() 23 public function testInit()
75 { 24 {
76 $wallabagV2Import = $this->getWallabagV2Import(); 25 $wallabagV2Import = $this->getWallabagV2Import();
77 26
78 $this->assertEquals('wallabag v2', $wallabagV2Import->getName()); 27 $this->assertSame('wallabag v2', $wallabagV2Import->getName());
79 $this->assertNotEmpty($wallabagV2Import->getUrl()); 28 $this->assertNotEmpty($wallabagV2Import->getUrl());
80 $this->assertEquals('import.wallabag_v2.description', $wallabagV2Import->getDescription()); 29 $this->assertSame('import.wallabag_v2.description', $wallabagV2Import->getDescription());
81 } 30 }
82 31
83 public function testImport() 32 public function testImport()
84 { 33 {
85 $wallabagV2Import = $this->getWallabagV2Import(false, 2); 34 $wallabagV2Import = $this->getWallabagV2Import(false, 2);
86 $wallabagV2Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2.json'); 35 $wallabagV2Import->setFilepath(__DIR__ . '/../fixtures/wallabag-v2.json');
87 36
88 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 37 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
89 ->disableOriginalConstructor() 38 ->disableOriginalConstructor()
@@ -106,13 +55,13 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
106 $res = $wallabagV2Import->import(); 55 $res = $wallabagV2Import->import();
107 56
108 $this->assertTrue($res); 57 $this->assertTrue($res);
109 $this->assertEquals(['skipped' => 4, 'imported' => 2, 'queued' => 0], $wallabagV2Import->getSummary()); 58 $this->assertSame(['skipped' => 4, 'imported' => 2, 'queued' => 0], $wallabagV2Import->getSummary());
110 } 59 }
111 60
112 public function testImportAndMarkAllAsRead() 61 public function testImportAndMarkAllAsRead()
113 { 62 {
114 $wallabagV2Import = $this->getWallabagV2Import(false, 2); 63 $wallabagV2Import = $this->getWallabagV2Import(false, 2);
115 $wallabagV2Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2-read.json'); 64 $wallabagV2Import->setFilepath(__DIR__ . '/../fixtures/wallabag-v2-read.json');
116 65
117 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 66 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
118 ->disableOriginalConstructor() 67 ->disableOriginalConstructor()
@@ -144,13 +93,13 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
144 93
145 $this->assertTrue($res); 94 $this->assertTrue($res);
146 95
147 $this->assertEquals(['skipped' => 0, 'imported' => 2, 'queued' => 0], $wallabagV2Import->getSummary()); 96 $this->assertSame(['skipped' => 0, 'imported' => 2, 'queued' => 0], $wallabagV2Import->getSummary());
148 } 97 }
149 98
150 public function testImportWithRabbit() 99 public function testImportWithRabbit()
151 { 100 {
152 $wallabagV2Import = $this->getWallabagV2Import(); 101 $wallabagV2Import = $this->getWallabagV2Import();
153 $wallabagV2Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2.json'); 102 $wallabagV2Import->setFilepath(__DIR__ . '/../fixtures/wallabag-v2.json');
154 103
155 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 104 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
156 ->disableOriginalConstructor() 105 ->disableOriginalConstructor()
@@ -180,13 +129,13 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
180 $res = $wallabagV2Import->setMarkAsRead(true)->import(); 129 $res = $wallabagV2Import->setMarkAsRead(true)->import();
181 130
182 $this->assertTrue($res); 131 $this->assertTrue($res);
183 $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 6], $wallabagV2Import->getSummary()); 132 $this->assertSame(['skipped' => 0, 'imported' => 0, 'queued' => 6], $wallabagV2Import->getSummary());
184 } 133 }
185 134
186 public function testImportWithRedis() 135 public function testImportWithRedis()
187 { 136 {
188 $wallabagV2Import = $this->getWallabagV2Import(); 137 $wallabagV2Import = $this->getWallabagV2Import();
189 $wallabagV2Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2.json'); 138 $wallabagV2Import->setFilepath(__DIR__ . '/../fixtures/wallabag-v2.json');
190 139
191 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 140 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
192 ->disableOriginalConstructor() 141 ->disableOriginalConstructor()
@@ -214,7 +163,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
214 $res = $wallabagV2Import->setMarkAsRead(true)->import(); 163 $res = $wallabagV2Import->setMarkAsRead(true)->import();
215 164
216 $this->assertTrue($res); 165 $this->assertTrue($res);
217 $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 6], $wallabagV2Import->getSummary()); 166 $this->assertSame(['skipped' => 0, 'imported' => 0, 'queued' => 6], $wallabagV2Import->getSummary());
218 167
219 $this->assertNotEmpty($redisMock->lpop('wallabag_v2')); 168 $this->assertNotEmpty($redisMock->lpop('wallabag_v2'));
220 } 169 }
@@ -222,7 +171,7 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
222 public function testImportBadFile() 171 public function testImportBadFile()
223 { 172 {
224 $wallabagV1Import = $this->getWallabagV2Import(); 173 $wallabagV1Import = $this->getWallabagV2Import();
225 $wallabagV1Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2.jsonx'); 174 $wallabagV1Import->setFilepath(__DIR__ . '/../fixtures/wallabag-v2.jsonx');
226 175
227 $res = $wallabagV1Import->import(); 176 $res = $wallabagV1Import->import();
228 177
@@ -230,13 +179,13 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
230 179
231 $records = $this->logHandler->getRecords(); 180 $records = $this->logHandler->getRecords();
232 $this->assertContains('WallabagImport: unable to read file', $records[0]['message']); 181 $this->assertContains('WallabagImport: unable to read file', $records[0]['message']);
233 $this->assertEquals('ERROR', $records[0]['level_name']); 182 $this->assertSame('ERROR', $records[0]['level_name']);
234 } 183 }
235 184
236 public function testImportUserNotDefined() 185 public function testImportUserNotDefined()
237 { 186 {
238 $wallabagV1Import = $this->getWallabagV2Import(true); 187 $wallabagV1Import = $this->getWallabagV2Import(true);
239 $wallabagV1Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2.json'); 188 $wallabagV1Import->setFilepath(__DIR__ . '/../fixtures/wallabag-v2.json');
240 189
241 $res = $wallabagV1Import->import(); 190 $res = $wallabagV1Import->import();
242 191
@@ -244,24 +193,24 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
244 193
245 $records = $this->logHandler->getRecords(); 194 $records = $this->logHandler->getRecords();
246 $this->assertContains('WallabagImport: user is not defined', $records[0]['message']); 195 $this->assertContains('WallabagImport: user is not defined', $records[0]['message']);
247 $this->assertEquals('ERROR', $records[0]['level_name']); 196 $this->assertSame('ERROR', $records[0]['level_name']);
248 } 197 }
249 198
250 public function testImportEmptyFile() 199 public function testImportEmptyFile()
251 { 200 {
252 $wallabagV2Import = $this->getWallabagV2Import(); 201 $wallabagV2Import = $this->getWallabagV2Import();
253 $wallabagV2Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2-empty.json'); 202 $wallabagV2Import->setFilepath(__DIR__ . '/../fixtures/wallabag-v2-empty.json');
254 203
255 $res = $wallabagV2Import->import(); 204 $res = $wallabagV2Import->import();
256 205
257 $this->assertFalse($res); 206 $this->assertFalse($res);
258 $this->assertEquals(['skipped' => 0, 'imported' => 0, 'queued' => 0], $wallabagV2Import->getSummary()); 207 $this->assertSame(['skipped' => 0, 'imported' => 0, 'queued' => 0], $wallabagV2Import->getSummary());
259 } 208 }
260 209
261 public function testImportWithExceptionFromGraby() 210 public function testImportWithExceptionFromGraby()
262 { 211 {
263 $wallabagV2Import = $this->getWallabagV2Import(false, 2); 212 $wallabagV2Import = $this->getWallabagV2Import(false, 2);
264 $wallabagV2Import->setFilepath(__DIR__.'/../fixtures/wallabag-v2.json'); 213 $wallabagV2Import->setFilepath(__DIR__ . '/../fixtures/wallabag-v2.json');
265 214
266 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository') 215 $entryRepo = $this->getMockBuilder('Wallabag\CoreBundle\Repository\EntryRepository')
267 ->disableOriginalConstructor() 216 ->disableOriginalConstructor()
@@ -284,6 +233,57 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase
284 $res = $wallabagV2Import->import(); 233 $res = $wallabagV2Import->import();
285 234
286 $this->assertTrue($res); 235 $this->assertTrue($res);
287 $this->assertEquals(['skipped' => 4, 'imported' => 2, 'queued' => 0], $wallabagV2Import->getSummary()); 236 $this->assertSame(['skipped' => 4, 'imported' => 2, 'queued' => 0], $wallabagV2Import->getSummary());
237 }
238
239 private function getWallabagV2Import($unsetUser = false, $dispatched = 0)
240 {
241 $this->user = new User();
242
243 $this->em = $this->getMockBuilder('Doctrine\ORM\EntityManager')
244 ->disableOriginalConstructor()
245 ->getMock();
246
247 $this->uow = $this->getMockBuilder('Doctrine\ORM\UnitOfWork')
248 ->disableOriginalConstructor()
249 ->getMock();
250
251 $this->em
252 ->expects($this->any())
253 ->method('getUnitOfWork')
254 ->willReturn($this->uow);
255
256 $this->uow
257 ->expects($this->any())
258 ->method('getScheduledEntityInsertions')
259 ->willReturn([]);
260
261 $this->contentProxy = $this->getMockBuilder('Wallabag\CoreBundle\Helper\ContentProxy')
262 ->disableOriginalConstructor()
263 ->getMock();
264
265 $this->tagsAssigner = $this->getMockBuilder('Wallabag\CoreBundle\Helper\TagsAssigner')
266 ->disableOriginalConstructor()
267 ->getMock();
268
269 $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
270 ->disableOriginalConstructor()
271 ->getMock();
272
273 $dispatcher
274 ->expects($this->exactly($dispatched))
275 ->method('dispatch');
276
277 $wallabag = new WallabagV2Import($this->em, $this->contentProxy, $this->tagsAssigner, $dispatcher);
278
279 $this->logHandler = new TestHandler();
280 $logger = new Logger('test', [$this->logHandler]);
281 $wallabag->setLogger($logger);
282
283 if (false === $unsetUser) {
284 $wallabag->setUser($this->user);
285 }
286
287 return $wallabag;
288 } 288 }
289} 289}