aboutsummaryrefslogtreecommitdiffhomepage
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
parent822c877949aff8ae57677671115f8f4fc69588d5 (diff)
downloadwallabag-f808b01692a835673f328d7221ba8c212caa9b61.tar.gz
wallabag-f808b01692a835673f328d7221ba8c212caa9b61.tar.zst
wallabag-f808b01692a835673f328d7221ba8c212caa9b61.zip
Add a real configuration for CS-Fixer
-rw-r--r--.gitignore1
-rw-r--r--.php_cs47
-rw-r--r--app/AppKernel.php14
-rw-r--r--app/DoctrineMigrations/Version20160410190541.php16
-rw-r--r--app/DoctrineMigrations/Version20160812120952.php10
-rw-r--r--app/DoctrineMigrations/Version20160911214952.php22
-rw-r--r--app/DoctrineMigrations/Version20160916201049.php14
-rw-r--r--app/DoctrineMigrations/Version20161001072726.php42
-rw-r--r--app/DoctrineMigrations/Version20161022134138.php60
-rw-r--r--app/DoctrineMigrations/Version20161024212538.php12
-rw-r--r--app/DoctrineMigrations/Version20161031132655.php16
-rw-r--r--app/DoctrineMigrations/Version20161104073720.php10
-rw-r--r--app/DoctrineMigrations/Version20161106113822.php10
-rw-r--r--app/DoctrineMigrations/Version20161117071626.php22
-rw-r--r--app/DoctrineMigrations/Version20161118134328.php10
-rw-r--r--app/DoctrineMigrations/Version20161122144743.php16
-rw-r--r--app/DoctrineMigrations/Version20161122203647.php10
-rw-r--r--app/DoctrineMigrations/Version20161128084725.php10
-rw-r--r--app/DoctrineMigrations/Version20161128131503.php10
-rw-r--r--app/DoctrineMigrations/Version20161214094402.php26
-rw-r--r--app/DoctrineMigrations/Version20161214094403.php10
-rw-r--r--app/DoctrineMigrations/Version20170127093841.php10
-rw-r--r--app/DoctrineMigrations/Version20170327194233.php20
-rw-r--r--app/DoctrineMigrations/Version20170405182620.php10
-rw-r--r--app/DoctrineMigrations/Version20170407200919.php10
-rw-r--r--app/DoctrineMigrations/Version20170420134133.php16
-rw-r--r--app/DoctrineMigrations/Version20170501115751.php12
-rw-r--r--app/DoctrineMigrations/Version20170510082609.php14
-rw-r--r--app/DoctrineMigrations/Version20170511115400.php10
-rw-r--r--app/DoctrineMigrations/Version20170511211659.php24
-rw-r--r--app/DoctrineMigrations/Version20170602075214.php16
-rw-r--r--app/DoctrineMigrations/Version20170606155640.php18
-rw-r--r--app/autoload.php6
-rw-r--r--composer.json2
-rw-r--r--src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php2
-rw-r--r--src/Wallabag/AnnotationBundle/Entity/Annotation.php10
-rw-r--r--src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php32
-rw-r--r--src/Wallabag/ApiBundle/Controller/AnnotationRestController.php4
-rw-r--r--src/Wallabag/ApiBundle/Controller/DeveloperController.php4
-rw-r--r--src/Wallabag/ApiBundle/Controller/EntryRestController.php18
-rw-r--r--src/Wallabag/ApiBundle/Controller/TagRestController.php2
-rw-r--r--src/Wallabag/ApiBundle/Controller/UserRestController.php4
-rw-r--r--src/Wallabag/ApiBundle/Controller/WallabagRestController.php4
-rw-r--r--src/Wallabag/ApiBundle/Entity/Client.php4
-rw-r--r--src/Wallabag/ApiBundle/Form/Type/ClientType.php2
-rw-r--r--src/Wallabag/CoreBundle/Command/CleanDuplicatesCommand.php4
-rw-r--r--src/Wallabag/CoreBundle/Command/ExportCommand.php2
-rw-r--r--src/Wallabag/CoreBundle/Command/InstallCommand.php22
-rw-r--r--src/Wallabag/CoreBundle/Controller/ConfigController.php140
-rw-r--r--src/Wallabag/CoreBundle/Controller/EntryController.php260
-rw-r--r--src/Wallabag/CoreBundle/Controller/ExceptionController.php2
-rw-r--r--src/Wallabag/CoreBundle/Controller/ExportController.php4
-rw-r--r--src/Wallabag/CoreBundle/Controller/RssController.php18
-rw-r--r--src/Wallabag/CoreBundle/Controller/SiteCredentialController.php8
-rw-r--r--src/Wallabag/CoreBundle/Controller/StaticController.php7
-rw-r--r--src/Wallabag/CoreBundle/Controller/TagController.php2
-rw-r--r--src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php2
-rw-r--r--src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php2
-rw-r--r--src/Wallabag/CoreBundle/Entity/Entry.php10
-rw-r--r--src/Wallabag/CoreBundle/Entity/SiteCredential.php2
-rw-r--r--src/Wallabag/CoreBundle/Entity/Tag.php2
-rw-r--r--src/Wallabag/CoreBundle/Event/Subscriber/DownloadImagesSubscriber.php8
-rw-r--r--src/Wallabag/CoreBundle/Event/Subscriber/SQLiteCascadeDeleteSubscriber.php2
-rw-r--r--src/Wallabag/CoreBundle/Event/Subscriber/TablePrefixSubscriber.php4
-rw-r--r--src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php16
-rw-r--r--src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php4
-rw-r--r--src/Wallabag/CoreBundle/Helper/ContentProxy.php10
-rw-r--r--src/Wallabag/CoreBundle/Helper/CryptoProxy.php12
-rw-r--r--src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php2
-rw-r--r--src/Wallabag/CoreBundle/Helper/DownloadImages.php44
-rw-r--r--src/Wallabag/CoreBundle/Helper/EntriesExport.php46
-rw-r--r--src/Wallabag/CoreBundle/Helper/HttpClientFactory.php2
-rw-r--r--src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php2
-rw-r--r--src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php2
-rw-r--r--src/Wallabag/CoreBundle/Repository/EntryRepository.php34
-rw-r--r--src/Wallabag/CoreBundle/Twig/WallabagExtension.php12
-rw-r--r--src/Wallabag/ImportBundle/Command/ImportCommand.php10
-rw-r--r--src/Wallabag/ImportBundle/Command/RedisWorkerCommand.php12
-rw-r--r--src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php10
-rw-r--r--src/Wallabag/ImportBundle/Controller/BrowserController.php43
-rw-r--r--src/Wallabag/ImportBundle/Controller/ChromeController.php16
-rw-r--r--src/Wallabag/ImportBundle/Controller/FirefoxController.php16
-rw-r--r--src/Wallabag/ImportBundle/Controller/ImportController.php6
-rw-r--r--src/Wallabag/ImportBundle/Controller/InstapaperController.php20
-rw-r--r--src/Wallabag/ImportBundle/Controller/PinboardController.php20
-rw-r--r--src/Wallabag/ImportBundle/Controller/PocketController.php46
-rw-r--r--src/Wallabag/ImportBundle/Controller/ReadabilityController.php20
-rw-r--r--src/Wallabag/ImportBundle/Controller/WallabagController.php46
-rw-r--r--src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php16
-rw-r--r--src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php16
-rw-r--r--src/Wallabag/ImportBundle/DependencyInjection/WallabagImportExtension.php6
-rw-r--r--src/Wallabag/ImportBundle/Form/Type/UploadImportType.php6
-rw-r--r--src/Wallabag/ImportBundle/Import/AbstractImport.php52
-rw-r--r--src/Wallabag/ImportBundle/Import/BrowserImport.php150
-rw-r--r--src/Wallabag/ImportBundle/Import/ChromeImport.php2
-rw-r--r--src/Wallabag/ImportBundle/Import/FirefoxImport.php2
-rw-r--r--src/Wallabag/ImportBundle/Import/ImportCompilerPass.php2
-rw-r--r--src/Wallabag/ImportBundle/Import/InstapaperImport.php2
-rw-r--r--src/Wallabag/ImportBundle/Import/PocketImport.php13
-rw-r--r--src/Wallabag/ImportBundle/Import/WallabagV1Import.php4
-rw-r--r--src/Wallabag/ImportBundle/Redis/Producer.php2
-rw-r--r--src/Wallabag/ImportBundle/WallabagImportBundle.php2
-rw-r--r--src/Wallabag/UserBundle/Controller/ManageController.php48
-rw-r--r--src/Wallabag/UserBundle/DependencyInjection/WallabagUserExtension.php6
-rw-r--r--src/Wallabag/UserBundle/Entity/User.php36
-rw-r--r--src/Wallabag/UserBundle/EventListener/AuthenticationFailureListener.php2
-rw-r--r--src/Wallabag/UserBundle/EventListener/PasswordResettingListener.php2
-rw-r--r--src/Wallabag/UserBundle/Form/UserType.php10
-rw-r--r--src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php2
-rw-r--r--src/Wallabag/UserBundle/Repository/UserRepository.php2
-rw-r--r--tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php44
-rw-r--r--tests/Wallabag/AnnotationBundle/WallabagAnnotationTestCase.php2
-rw-r--r--tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php24
-rw-r--r--tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php296
-rw-r--r--tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php38
-rw-r--r--tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php54
-rw-r--r--tests/Wallabag/ApiBundle/Controller/WallabagRestControllerTest.php4
-rw-r--r--tests/Wallabag/ApiBundle/WallabagApiTestCase.php2
-rw-r--r--tests/Wallabag/CoreBundle/Command/CleanDuplicatesCommandTest.php2
-rw-r--r--tests/Wallabag/CoreBundle/Command/ExportCommandTest.php2
-rw-r--r--tests/Wallabag/CoreBundle/Command/InstallCommandTest.php20
-rw-r--r--tests/Wallabag/CoreBundle/Command/TagAllCommandTest.php2
-rw-r--r--tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php116
-rw-r--r--tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php202
-rw-r--r--tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php108
-rw-r--r--tests/Wallabag/CoreBundle/Controller/RssControllerTest.php58
-rw-r--r--tests/Wallabag/CoreBundle/Controller/SettingsControllerTest.php4
-rw-r--r--tests/Wallabag/CoreBundle/Controller/SiteCredentialControllerTest.php22
-rw-r--r--tests/Wallabag/CoreBundle/Controller/StaticControllerTest.php4
-rw-r--r--tests/Wallabag/CoreBundle/Controller/TagControllerTest.php36
-rw-r--r--tests/Wallabag/CoreBundle/Event/Listener/LocaleListenerTest.php28
-rw-r--r--tests/Wallabag/CoreBundle/Event/Listener/UserLocaleListenerTest.php4
-rw-r--r--tests/Wallabag/CoreBundle/Event/Subscriber/TablePrefixSubscriberTest.php18
-rw-r--r--tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php10
-rw-r--r--tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php152
-rw-r--r--tests/Wallabag/CoreBundle/Helper/CryptoProxyTest.php10
-rw-r--r--tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php46
-rw-r--r--tests/Wallabag/CoreBundle/Helper/RedirectTest.php20
-rw-r--r--tests/Wallabag/CoreBundle/Helper/RuleBasedTaggerTest.php2
-rw-r--r--tests/Wallabag/CoreBundle/Helper/TagsAssignerTest.php16
-rw-r--r--tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php2
-rw-r--r--tests/Wallabag/CoreBundle/Tools/UtilsTest.php2
-rw-r--r--tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php6
-rw-r--r--tests/Wallabag/CoreBundle/WallabagCoreTestCase.php14
-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
-rw-r--r--tests/Wallabag/UserBundle/Controller/ManageControllerTest.php16
-rw-r--r--tests/Wallabag/UserBundle/EventListener/AuthenticationFailureListenerTest.php6
-rw-r--r--tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php2
-rw-r--r--tests/Wallabag/UserBundle/Mailer/AuthCodeMailerTest.php4
170 files changed, 2339 insertions, 2312 deletions
diff --git a/.gitignore b/.gitignore
index 8fd762fa..736ef852 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,6 +13,7 @@
13/bin/* 13/bin/*
14!/bin/console 14!/bin/console
15!/bin/symfony_requirements 15!/bin/symfony_requirements
16.php_cs.cache
16 17
17# Parameters 18# Parameters
18/app/config/parameters.yml 19/app/config/parameters.yml
diff --git a/.php_cs b/.php_cs
new file mode 100644
index 00000000..8bc79a95
--- /dev/null
+++ b/.php_cs
@@ -0,0 +1,47 @@
1<?php
2
3return PhpCsFixer\Config::create()
4 ->setRiskyAllowed(true)
5 ->setRules([
6 '@Symfony' => true,
7 '@Symfony:risky' => true,
8 'array_syntax' => [
9 'syntax' => 'short'
10 ],
11 'combine_consecutive_unsets' => true,
12 'heredoc_to_nowdoc' => true,
13 'no_extra_consecutive_blank_lines' => [
14 'break',
15 'continue',
16 'extra',
17 'return',
18 'throw',
19 'use',
20 'parenthesis_brace_block',
21 'square_brace_block',
22 'curly_brace_block'
23 ],
24 'no_unreachable_default_argument_value' => true,
25 'no_useless_else' => true,
26 'no_useless_return' => true,
27 'ordered_class_elements' => true,
28 'ordered_imports' => true,
29 'php_unit_strict' => true,
30 'phpdoc_order' => true,
31 // 'psr4' => true,
32 'strict_comparison' => true,
33 'strict_param' => true,
34 'concat_space' => [
35 'spacing' => 'one'
36 ],
37 ])
38 ->setFinder(
39 PhpCsFixer\Finder::create()
40 ->exclude([
41 'vendor',
42 'var',
43 'web'
44 ])
45 ->in(__DIR__)
46 )
47;
diff --git a/app/AppKernel.php b/app/AppKernel.php
index c50783a6..f1140943 100644
--- a/app/AppKernel.php
+++ b/app/AppKernel.php
@@ -1,7 +1,7 @@
1<?php 1<?php
2 2
3use Symfony\Component\HttpKernel\Kernel;
4use Symfony\Component\Config\Loader\LoaderInterface; 3use Symfony\Component\Config\Loader\LoaderInterface;
4use Symfony\Component\HttpKernel\Kernel;
5 5
6class AppKernel extends Kernel 6class AppKernel extends Kernel
7{ 7{
@@ -64,25 +64,25 @@ class AppKernel extends Kernel
64 64
65 public function getCacheDir() 65 public function getCacheDir()
66 { 66 {
67 return dirname(__DIR__).'/var/cache/'.$this->getEnvironment(); 67 return dirname(__DIR__) . '/var/cache/' . $this->getEnvironment();
68 } 68 }
69 69
70 public function getLogDir() 70 public function getLogDir()
71 { 71 {
72 return dirname(__DIR__).'/var/logs'; 72 return dirname(__DIR__) . '/var/logs';
73 } 73 }
74 74
75 public function registerContainerConfiguration(LoaderInterface $loader) 75 public function registerContainerConfiguration(LoaderInterface $loader)
76 { 76 {
77 $loader->load($this->getRootDir().'/config/config_'.$this->getEnvironment().'.yml'); 77 $loader->load($this->getRootDir() . '/config/config_' . $this->getEnvironment() . '.yml');
78 $loader->load(function ($container) { 78 $loader->load(function ($container) {
79 if ($container->getParameter('use_webpack_dev_server')) { 79 if ($container->getParameter('use_webpack_dev_server')) {
80 $container->loadFromExtension('framework', [ 80 $container->loadFromExtension('framework', [
81 'assets' => [ 81 'assets' => [
82 'base_url' => 'http://localhost:8080/', 82 'base_url' => 'http://localhost:8080/',
83 ], 83 ],
84 ]); 84 ]);
85 } 85 }
86 }); 86 });
87 } 87 }
88} 88}
diff --git a/app/DoctrineMigrations/Version20160410190541.php b/app/DoctrineMigrations/Version20160410190541.php
index 5e5cae35..55c12ce1 100644
--- a/app/DoctrineMigrations/Version20160410190541.php
+++ b/app/DoctrineMigrations/Version20160410190541.php
@@ -22,11 +22,6 @@ class Version20160410190541 extends AbstractMigration implements ContainerAwareI
22 $this->container = $container; 22 $this->container = $container;
23 } 23 }
24 24
25 private function getTable($tableName)
26 {
27 return $this->container->getParameter('database_table_prefix').$tableName;
28 }
29
30 /** 25 /**
31 * @param Schema $schema 26 * @param Schema $schema
32 */ 27 */
@@ -44,10 +39,10 @@ class Version20160410190541 extends AbstractMigration implements ContainerAwareI
44 $sharePublic = $this->container 39 $sharePublic = $this->container
45 ->get('doctrine.orm.default_entity_manager') 40 ->get('doctrine.orm.default_entity_manager')
46 ->getConnection() 41 ->getConnection()
47 ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'share_public'"); 42 ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'share_public'");
48 43
49 if (false === $sharePublic) { 44 if (false === $sharePublic) {
50 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('share_public', '1', 'entry')"); 45 $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('share_public', '1', 'entry')");
51 } 46 }
52 } 47 }
53 48
@@ -59,6 +54,11 @@ class Version20160410190541 extends AbstractMigration implements ContainerAwareI
59 $entryTable = $schema->getTable($this->getTable('entry')); 54 $entryTable = $schema->getTable($this->getTable('entry'));
60 $entryTable->dropColumn('uid'); 55 $entryTable->dropColumn('uid');
61 56
62 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'share_public'"); 57 $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'share_public'");
58 }
59
60 private function getTable($tableName)
61 {
62 return $this->container->getParameter('database_table_prefix') . $tableName;
63 } 63 }
64} 64}
diff --git a/app/DoctrineMigrations/Version20160812120952.php b/app/DoctrineMigrations/Version20160812120952.php
index 13272267..677f30c3 100644
--- a/app/DoctrineMigrations/Version20160812120952.php
+++ b/app/DoctrineMigrations/Version20160812120952.php
@@ -22,11 +22,6 @@ class Version20160812120952 extends AbstractMigration implements ContainerAwareI
22 $this->container = $container; 22 $this->container = $container;
23 } 23 }
24 24
25 private function getTable($tableName)
26 {
27 return $this->container->getParameter('database_table_prefix').$tableName;
28 }
29
30 /** 25 /**
31 * @param Schema $schema 26 * @param Schema $schema
32 */ 27 */
@@ -46,4 +41,9 @@ class Version20160812120952 extends AbstractMigration implements ContainerAwareI
46 $clientsTable = $schema->getTable($this->getTable('oauth2_clients')); 41 $clientsTable = $schema->getTable($this->getTable('oauth2_clients'));
47 $clientsTable->dropColumn('name'); 42 $clientsTable->dropColumn('name');
48 } 43 }
44
45 private function getTable($tableName)
46 {
47 return $this->container->getParameter('database_table_prefix') . $tableName;
48 }
49} 49}
diff --git a/app/DoctrineMigrations/Version20160911214952.php b/app/DoctrineMigrations/Version20160911214952.php
index 4eae46e7..08cc8a03 100644
--- a/app/DoctrineMigrations/Version20160911214952.php
+++ b/app/DoctrineMigrations/Version20160911214952.php
@@ -22,11 +22,6 @@ class Version20160911214952 extends AbstractMigration implements ContainerAwareI
22 $this->container = $container; 22 $this->container = $container;
23 } 23 }
24 24
25 private function getTable($tableName)
26 {
27 return $this->container->getParameter('database_table_prefix').$tableName;
28 }
29
30 /** 25 /**
31 * @param Schema $schema 26 * @param Schema $schema
32 */ 27 */
@@ -35,19 +30,19 @@ class Version20160911214952 extends AbstractMigration implements ContainerAwareI
35 $redis = $this->container 30 $redis = $this->container
36 ->get('doctrine.orm.default_entity_manager') 31 ->get('doctrine.orm.default_entity_manager')
37 ->getConnection() 32 ->getConnection()
38 ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'import_with_redis'"); 33 ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'import_with_redis'");
39 34
40 if (false === $redis) { 35 if (false === $redis) {
41 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('import_with_redis', 0, 'import')"); 36 $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('import_with_redis', 0, 'import')");
42 } 37 }
43 38
44 $rabbitmq = $this->container 39 $rabbitmq = $this->container
45 ->get('doctrine.orm.default_entity_manager') 40 ->get('doctrine.orm.default_entity_manager')
46 ->getConnection() 41 ->getConnection()
47 ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'import_with_rabbitmq'"); 42 ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'import_with_rabbitmq'");
48 43
49 if (false === $rabbitmq) { 44 if (false === $rabbitmq) {
50 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('import_with_rabbitmq', 0, 'import')"); 45 $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('import_with_rabbitmq', 0, 'import')");
51 } 46 }
52 47
53 $this->skipIf(false !== $rabbitmq && false !== $redis, 'It seems that you already played this migration.'); 48 $this->skipIf(false !== $rabbitmq && false !== $redis, 'It seems that you already played this migration.');
@@ -58,7 +53,12 @@ class Version20160911214952 extends AbstractMigration implements ContainerAwareI
58 */ 53 */
59 public function down(Schema $schema) 54 public function down(Schema $schema)
60 { 55 {
61 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'import_with_redis';"); 56 $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'import_with_redis';");
62 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'import_with_rabbitmq';"); 57 $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'import_with_rabbitmq';");
58 }
59
60 private function getTable($tableName)
61 {
62 return $this->container->getParameter('database_table_prefix') . $tableName;
63 } 63 }
64} 64}
diff --git a/app/DoctrineMigrations/Version20160916201049.php b/app/DoctrineMigrations/Version20160916201049.php
index ff34c894..83503bc4 100644
--- a/app/DoctrineMigrations/Version20160916201049.php
+++ b/app/DoctrineMigrations/Version20160916201049.php
@@ -22,11 +22,6 @@ class Version20160916201049 extends AbstractMigration implements ContainerAwareI
22 $this->container = $container; 22 $this->container = $container;
23 } 23 }
24 24
25 private function getTable($tableName)
26 {
27 return $this->container->getParameter('database_table_prefix').$tableName;
28 }
29
30 /** 25 /**
31 * @param Schema $schema 26 * @param Schema $schema
32 */ 27 */
@@ -37,7 +32,7 @@ class Version20160916201049 extends AbstractMigration implements ContainerAwareI
37 $this->skipIf($configTable->hasColumn('pocket_consumer_key'), 'It seems that you already played this migration.'); 32 $this->skipIf($configTable->hasColumn('pocket_consumer_key'), 'It seems that you already played this migration.');
38 33
39 $configTable->addColumn('pocket_consumer_key', 'string', ['notnull' => false]); 34 $configTable->addColumn('pocket_consumer_key', 'string', ['notnull' => false]);
40 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'pocket_consumer_key';"); 35 $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'pocket_consumer_key';");
41 } 36 }
42 37
43 /** 38 /**
@@ -47,6 +42,11 @@ class Version20160916201049 extends AbstractMigration implements ContainerAwareI
47 { 42 {
48 $configTable = $schema->getTable($this->getTable('config')); 43 $configTable = $schema->getTable($this->getTable('config'));
49 $configTable->dropColumn('pocket_consumer_key'); 44 $configTable->dropColumn('pocket_consumer_key');
50 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('pocket_consumer_key', NULL, 'import')"); 45 $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('pocket_consumer_key', NULL, 'import')");
46 }
47
48 private function getTable($tableName)
49 {
50 return $this->container->getParameter('database_table_prefix') . $tableName;
51 } 51 }
52} 52}
diff --git a/app/DoctrineMigrations/Version20161001072726.php b/app/DoctrineMigrations/Version20161001072726.php
index ad761541..4babe172 100644
--- a/app/DoctrineMigrations/Version20161001072726.php
+++ b/app/DoctrineMigrations/Version20161001072726.php
@@ -3,10 +3,10 @@
3namespace Application\Migrations; 3namespace Application\Migrations;
4 4
5use Doctrine\DBAL\Migrations\AbstractMigration; 5use Doctrine\DBAL\Migrations\AbstractMigration;
6use Doctrine\DBAL\Migrations\SkipMigrationException;
6use Doctrine\DBAL\Schema\Schema; 7use Doctrine\DBAL\Schema\Schema;
7use Symfony\Component\DependencyInjection\ContainerAwareInterface; 8use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface; 9use Symfony\Component\DependencyInjection\ContainerInterface;
9use Doctrine\DBAL\Migrations\SkipMigrationException;
10 10
11/** 11/**
12 * Added pocket_consumer_key field on wallabag_config. 12 * Added pocket_consumer_key field on wallabag_config.
@@ -23,17 +23,12 @@ class Version20161001072726 extends AbstractMigration implements ContainerAwareI
23 $this->container = $container; 23 $this->container = $container;
24 } 24 }
25 25
26 private function getTable($tableName)
27 {
28 return $this->container->getParameter('database_table_prefix').$tableName;
29 }
30
31 /** 26 /**
32 * @param Schema $schema 27 * @param Schema $schema
33 */ 28 */
34 public function up(Schema $schema) 29 public function up(Schema $schema)
35 { 30 {
36 $this->skipIf($this->connection->getDatabasePlatform()->getName() == 'sqlite', 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.'); 31 $this->skipIf($this->connection->getDatabasePlatform()->getName() === 'sqlite', 'Migration can only be executed safely on \'mysql\' or \'postgresql\'.');
37 32
38 // remove all FK from entry_tag 33 // remove all FK from entry_tag
39 switch ($this->connection->getDatabasePlatform()->getName()) { 34 switch ($this->connection->getDatabasePlatform()->getName()) {
@@ -41,16 +36,15 @@ class Version20161001072726 extends AbstractMigration implements ContainerAwareI
41 $query = $this->connection->query(" 36 $query = $this->connection->query("
42 SELECT CONSTRAINT_NAME 37 SELECT CONSTRAINT_NAME
43 FROM information_schema.key_column_usage 38 FROM information_schema.key_column_usage
44 WHERE TABLE_NAME = '".$this->getTable('entry_tag')."' AND CONSTRAINT_NAME LIKE 'FK_%' 39 WHERE TABLE_NAME = '" . $this->getTable('entry_tag') . "' AND CONSTRAINT_NAME LIKE 'FK_%'
45 AND TABLE_SCHEMA = '".$this->connection->getDatabase()."'" 40 AND TABLE_SCHEMA = '" . $this->connection->getDatabase() . "'"
46 ); 41 );
47 $query->execute(); 42 $query->execute();
48 43
49 foreach ($query->fetchAll() as $fk) { 44 foreach ($query->fetchAll() as $fk) {
50 $this->addSql('ALTER TABLE '.$this->getTable('entry_tag').' DROP FOREIGN KEY '.$fk['CONSTRAINT_NAME']); 45 $this->addSql('ALTER TABLE ' . $this->getTable('entry_tag') . ' DROP FOREIGN KEY ' . $fk['CONSTRAINT_NAME']);
51 } 46 }
52 break; 47 break;
53
54 case 'postgresql': 48 case 'postgresql':
55 // http://dba.stackexchange.com/questions/36979/retrieving-all-pk-and-fk 49 // http://dba.stackexchange.com/questions/36979/retrieving-all-pk-and-fk
56 $query = $this->connection->query(" 50 $query = $this->connection->query("
@@ -60,19 +54,19 @@ class Version20161001072726 extends AbstractMigration implements ContainerAwareI
60 FROM pg_constraint c 54 FROM pg_constraint c
61 JOIN pg_namespace n ON n.oid = c.connamespace 55 JOIN pg_namespace n ON n.oid = c.connamespace
62 WHERE contype = 'f' 56 WHERE contype = 'f'
63 AND conrelid::regclass::text = '".$this->getTable('entry_tag')."' 57 AND conrelid::regclass::text = '" . $this->getTable('entry_tag') . "'
64 AND n.nspname = 'public';" 58 AND n.nspname = 'public';"
65 ); 59 );
66 $query->execute(); 60 $query->execute();
67 61
68 foreach ($query->fetchAll() as $fk) { 62 foreach ($query->fetchAll() as $fk) {
69 $this->addSql('ALTER TABLE '.$this->getTable('entry_tag').' DROP CONSTRAINT '.$fk['conname']); 63 $this->addSql('ALTER TABLE ' . $this->getTable('entry_tag') . ' DROP CONSTRAINT ' . $fk['conname']);
70 } 64 }
71 break; 65 break;
72 } 66 }
73 67
74 $this->addSql('ALTER TABLE '.$this->getTable('entry_tag').' ADD CONSTRAINT FK_entry_tag_entry FOREIGN KEY (entry_id) REFERENCES '.$this->getTable('entry').' (id) ON DELETE CASCADE'); 68 $this->addSql('ALTER TABLE ' . $this->getTable('entry_tag') . ' ADD CONSTRAINT FK_entry_tag_entry FOREIGN KEY (entry_id) REFERENCES ' . $this->getTable('entry') . ' (id) ON DELETE CASCADE');
75 $this->addSql('ALTER TABLE '.$this->getTable('entry_tag').' ADD CONSTRAINT FK_entry_tag_tag FOREIGN KEY (tag_id) REFERENCES '.$this->getTable('tag').' (id) ON DELETE CASCADE'); 69 $this->addSql('ALTER TABLE ' . $this->getTable('entry_tag') . ' ADD CONSTRAINT FK_entry_tag_tag FOREIGN KEY (tag_id) REFERENCES ' . $this->getTable('tag') . ' (id) ON DELETE CASCADE');
76 70
77 // remove entry FK from annotation 71 // remove entry FK from annotation
78 72
@@ -81,18 +75,17 @@ class Version20161001072726 extends AbstractMigration implements ContainerAwareI
81 $query = $this->connection->query(" 75 $query = $this->connection->query("
82 SELECT CONSTRAINT_NAME 76 SELECT CONSTRAINT_NAME
83 FROM information_schema.key_column_usage 77 FROM information_schema.key_column_usage
84 WHERE TABLE_NAME = '".$this->getTable('annotation')."' 78 WHERE TABLE_NAME = '" . $this->getTable('annotation') . "'
85 AND CONSTRAINT_NAME LIKE 'FK_%' 79 AND CONSTRAINT_NAME LIKE 'FK_%'
86 AND COLUMN_NAME = 'entry_id' 80 AND COLUMN_NAME = 'entry_id'
87 AND TABLE_SCHEMA = '".$this->connection->getDatabase()."'" 81 AND TABLE_SCHEMA = '" . $this->connection->getDatabase() . "'"
88 ); 82 );
89 $query->execute(); 83 $query->execute();
90 84
91 foreach ($query->fetchAll() as $fk) { 85 foreach ($query->fetchAll() as $fk) {
92 $this->addSql('ALTER TABLE '.$this->getTable('annotation').' DROP FOREIGN KEY '.$fk['CONSTRAINT_NAME']); 86 $this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' DROP FOREIGN KEY ' . $fk['CONSTRAINT_NAME']);
93 } 87 }
94 break; 88 break;
95
96 case 'postgresql': 89 case 'postgresql':
97 // http://dba.stackexchange.com/questions/36979/retrieving-all-pk-and-fk 90 // http://dba.stackexchange.com/questions/36979/retrieving-all-pk-and-fk
98 $query = $this->connection->query(" 91 $query = $this->connection->query("
@@ -102,19 +95,19 @@ class Version20161001072726 extends AbstractMigration implements ContainerAwareI
102 FROM pg_constraint c 95 FROM pg_constraint c
103 JOIN pg_namespace n ON n.oid = c.connamespace 96 JOIN pg_namespace n ON n.oid = c.connamespace
104 WHERE contype = 'f' 97 WHERE contype = 'f'
105 AND conrelid::regclass::text = '".$this->getTable('annotation')."' 98 AND conrelid::regclass::text = '" . $this->getTable('annotation') . "'
106 AND n.nspname = 'public' 99 AND n.nspname = 'public'
107 AND pg_get_constraintdef(c.oid) LIKE '%entry_id%';" 100 AND pg_get_constraintdef(c.oid) LIKE '%entry_id%';"
108 ); 101 );
109 $query->execute(); 102 $query->execute();
110 103
111 foreach ($query->fetchAll() as $fk) { 104 foreach ($query->fetchAll() as $fk) {
112 $this->addSql('ALTER TABLE '.$this->getTable('annotation').' DROP CONSTRAINT '.$fk['conname']); 105 $this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' DROP CONSTRAINT ' . $fk['conname']);
113 } 106 }
114 break; 107 break;
115 } 108 }
116 109
117 $this->addSql('ALTER TABLE '.$this->getTable('annotation').' ADD CONSTRAINT FK_annotation_entry FOREIGN KEY (entry_id) REFERENCES '.$this->getTable('entry').' (id) ON DELETE CASCADE'); 110 $this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' ADD CONSTRAINT FK_annotation_entry FOREIGN KEY (entry_id) REFERENCES ' . $this->getTable('entry') . ' (id) ON DELETE CASCADE');
118 } 111 }
119 112
120 /** 113 /**
@@ -124,4 +117,9 @@ class Version20161001072726 extends AbstractMigration implements ContainerAwareI
124 { 117 {
125 throw new SkipMigrationException('Too complex ...'); 118 throw new SkipMigrationException('Too complex ...');
126 } 119 }
120
121 private function getTable($tableName)
122 {
123 return $this->container->getParameter('database_table_prefix') . $tableName;
124 }
127} 125}
diff --git a/app/DoctrineMigrations/Version20161022134138.php b/app/DoctrineMigrations/Version20161022134138.php
index 39949e7d..89ba9973 100644
--- a/app/DoctrineMigrations/Version20161022134138.php
+++ b/app/DoctrineMigrations/Version20161022134138.php
@@ -22,11 +22,6 @@ class Version20161022134138 extends AbstractMigration implements ContainerAwareI
22 $this->container = $container; 22 $this->container = $container;
23 } 23 }
24 24
25 private function getTable($tableName)
26 {
27 return $this->container->getParameter('database_table_prefix').$tableName;
28 }
29
30 /** 25 /**
31 * @param Schema $schema 26 * @param Schema $schema
32 */ 27 */
@@ -34,28 +29,28 @@ class Version20161022134138 extends AbstractMigration implements ContainerAwareI
34 { 29 {
35 $this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL'); 30 $this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL');
36 31
37 $this->addSql('ALTER DATABASE '.$this->connection->getParams()['dbname'].' CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;'); 32 $this->addSql('ALTER DATABASE ' . $this->connection->getParams()['dbname'] . ' CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;');
38 33
39 // convert field length for utf8mb4 34 // convert field length for utf8mb4
40 // http://stackoverflow.com/a/31474509/569101 35 // http://stackoverflow.com/a/31474509/569101
41 $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE confirmation_token confirmation_token VARCHAR(180) DEFAULT NULL;'); 36 $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE confirmation_token confirmation_token VARCHAR(180) DEFAULT NULL;');
42 $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE salt salt VARCHAR(180) NOT NULL;'); 37 $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE salt salt VARCHAR(180) NOT NULL;');
43 $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE password password VARCHAR(180) NOT NULL;'); 38 $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE password password VARCHAR(180) NOT NULL;');
44 39
45 $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); 40 $this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
46 $this->addSql('ALTER TABLE '.$this->getTable('entry').' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); 41 $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
47 $this->addSql('ALTER TABLE '.$this->getTable('tag').' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); 42 $this->addSql('ALTER TABLE ' . $this->getTable('tag') . ' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
48 $this->addSql('ALTER TABLE '.$this->getTable('user').' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); 43 $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
49 44
50 $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CHANGE `text` `text` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); 45 $this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' CHANGE `text` `text` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
51 $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CHANGE `quote` `quote` VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); 46 $this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' CHANGE `quote` `quote` VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
52 47
53 $this->addSql('ALTER TABLE '.$this->getTable('entry').' CHANGE `title` `title` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); 48 $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CHANGE `title` `title` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
54 $this->addSql('ALTER TABLE '.$this->getTable('entry').' CHANGE `content` `content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); 49 $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CHANGE `content` `content` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
55 50
56 $this->addSql('ALTER TABLE '.$this->getTable('tag').' CHANGE `label` `label` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); 51 $this->addSql('ALTER TABLE ' . $this->getTable('tag') . ' CHANGE `label` `label` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
57 52
58 $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE `name` `name` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;'); 53 $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE `name` `name` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;');
59 } 54 }
60 55
61 /** 56 /**
@@ -65,21 +60,26 @@ class Version20161022134138 extends AbstractMigration implements ContainerAwareI
65 { 60 {
66 $this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL'); 61 $this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL');
67 62
68 $this->addSql('ALTER DATABASE '.$this->connection->getParams()['dbname'].' CHARACTER SET = utf8 COLLATE = utf8_unicode_ci;'); 63 $this->addSql('ALTER DATABASE ' . $this->connection->getParams()['dbname'] . ' CHARACTER SET = utf8 COLLATE = utf8_unicode_ci;');
69 64
70 $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); 65 $this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
71 $this->addSql('ALTER TABLE '.$this->getTable('entry').' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); 66 $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
72 $this->addSql('ALTER TABLE '.$this->getTable('tag').' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); 67 $this->addSql('ALTER TABLE ' . $this->getTable('tag') . ' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
73 $this->addSql('ALTER TABLE '.$this->getTable('user').' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); 68 $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
74 69
75 $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CHANGE `text` `text` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); 70 $this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' CHANGE `text` `text` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
76 $this->addSql('ALTER TABLE '.$this->getTable('annotation').' CHANGE `quote` `quote` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); 71 $this->addSql('ALTER TABLE ' . $this->getTable('annotation') . ' CHANGE `quote` `quote` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
77 72
78 $this->addSql('ALTER TABLE '.$this->getTable('entry').' CHANGE `title` `title` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); 73 $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CHANGE `title` `title` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
79 $this->addSql('ALTER TABLE '.$this->getTable('entry').' CHANGE `content` `content` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); 74 $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CHANGE `content` `content` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
80 75
81 $this->addSql('ALTER TABLE '.$this->getTable('tag').' CHANGE `label` `label` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); 76 $this->addSql('ALTER TABLE ' . $this->getTable('tag') . ' CHANGE `label` `label` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
82 77
83 $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE `name` `name` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;'); 78 $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE `name` `name` longtext CHARACTER SET utf8 COLLATE utf8_unicode_ci;');
79 }
80
81 private function getTable($tableName)
82 {
83 return $this->container->getParameter('database_table_prefix') . $tableName;
84 } 84 }
85} 85}
diff --git a/app/DoctrineMigrations/Version20161024212538.php b/app/DoctrineMigrations/Version20161024212538.php
index b2f6aaf8..35853d03 100644
--- a/app/DoctrineMigrations/Version20161024212538.php
+++ b/app/DoctrineMigrations/Version20161024212538.php
@@ -24,11 +24,6 @@ class Version20161024212538 extends AbstractMigration implements ContainerAwareI
24 $this->container = $container; 24 $this->container = $container;
25 } 25 }
26 26
27 private function getTable($tableName)
28 {
29 return $this->container->getParameter('database_table_prefix').$tableName;
30 }
31
32 /** 27 /**
33 * @param Schema $schema 28 * @param Schema $schema
34 */ 29 */
@@ -60,8 +55,13 @@ class Version20161024212538 extends AbstractMigration implements ContainerAwareI
60 55
61 $clientsTable->dropColumn('user_id', 'integer'); 56 $clientsTable->dropColumn('user_id', 'integer');
62 57
63 if ($this->connection->getDatabasePlatform()->getName() != 'sqlite') { 58 if ($this->connection->getDatabasePlatform()->getName() !== 'sqlite') {
64 $clientsTable->removeForeignKey($this->constraintName); 59 $clientsTable->removeForeignKey($this->constraintName);
65 } 60 }
66 } 61 }
62
63 private function getTable($tableName)
64 {
65 return $this->container->getParameter('database_table_prefix') . $tableName;
66 }
67} 67}
diff --git a/app/DoctrineMigrations/Version20161031132655.php b/app/DoctrineMigrations/Version20161031132655.php
index ef846412..0deebdf9 100644
--- a/app/DoctrineMigrations/Version20161031132655.php
+++ b/app/DoctrineMigrations/Version20161031132655.php
@@ -22,11 +22,6 @@ class Version20161031132655 extends AbstractMigration implements ContainerAwareI
22 $this->container = $container; 22 $this->container = $container;
23 } 23 }
24 24
25 private function getTable($tableName)
26 {
27 return $this->container->getParameter('database_table_prefix').$tableName;
28 }
29
30 /** 25 /**
31 * @param Schema $schema 26 * @param Schema $schema
32 */ 27 */
@@ -35,11 +30,11 @@ class Version20161031132655 extends AbstractMigration implements ContainerAwareI
35 $images = $this->container 30 $images = $this->container
36 ->get('doctrine.orm.default_entity_manager') 31 ->get('doctrine.orm.default_entity_manager')
37 ->getConnection() 32 ->getConnection()
38 ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'download_images_enabled'"); 33 ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'download_images_enabled'");
39 34
40 $this->skipIf(false !== $images, 'It seems that you already played this migration.'); 35 $this->skipIf(false !== $images, 'It seems that you already played this migration.');
41 36
42 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('download_images_enabled', 0, 'misc')"); 37 $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('download_images_enabled', 0, 'misc')");
43 } 38 }
44 39
45 /** 40 /**
@@ -47,6 +42,11 @@ class Version20161031132655 extends AbstractMigration implements ContainerAwareI
47 */ 42 */
48 public function down(Schema $schema) 43 public function down(Schema $schema)
49 { 44 {
50 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'download_images_enabled';"); 45 $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'download_images_enabled';");
46 }
47
48 private function getTable($tableName)
49 {
50 return $this->container->getParameter('database_table_prefix') . $tableName;
51 } 51 }
52} 52}
diff --git a/app/DoctrineMigrations/Version20161104073720.php b/app/DoctrineMigrations/Version20161104073720.php
index 0e05f02e..f59ad7ba 100644
--- a/app/DoctrineMigrations/Version20161104073720.php
+++ b/app/DoctrineMigrations/Version20161104073720.php
@@ -24,11 +24,6 @@ class Version20161104073720 extends AbstractMigration implements ContainerAwareI
24 $this->container = $container; 24 $this->container = $container;
25 } 25 }
26 26
27 private function getTable($tableName)
28 {
29 return $this->container->getParameter('database_table_prefix').$tableName;
30 }
31
32 /** 27 /**
33 * @param Schema $schema 28 * @param Schema $schema
34 */ 29 */
@@ -50,4 +45,9 @@ class Version20161104073720 extends AbstractMigration implements ContainerAwareI
50 45
51 $entryTable->dropIndex($this->indexName); 46 $entryTable->dropIndex($this->indexName);
52 } 47 }
48
49 private function getTable($tableName)
50 {
51 return $this->container->getParameter('database_table_prefix') . $tableName;
52 }
53} 53}
diff --git a/app/DoctrineMigrations/Version20161106113822.php b/app/DoctrineMigrations/Version20161106113822.php
index facc14f4..1d5a865b 100644
--- a/app/DoctrineMigrations/Version20161106113822.php
+++ b/app/DoctrineMigrations/Version20161106113822.php
@@ -22,11 +22,6 @@ class Version20161106113822 extends AbstractMigration implements ContainerAwareI
22 $this->container = $container; 22 $this->container = $container;
23 } 23 }
24 24
25 private function getTable($tableName)
26 {
27 return $this->container->getParameter('database_table_prefix').$tableName;
28 }
29
30 /** 25 /**
31 * @param Schema $schema 26 * @param Schema $schema
32 */ 27 */
@@ -53,4 +48,9 @@ class Version20161106113822 extends AbstractMigration implements ContainerAwareI
53 48
54 $configTable->dropColumn('action_mark_as_read'); 49 $configTable->dropColumn('action_mark_as_read');
55 } 50 }
51
52 private function getTable($tableName)
53 {
54 return $this->container->getParameter('database_table_prefix') . $tableName;
55 }
56} 56}
diff --git a/app/DoctrineMigrations/Version20161117071626.php b/app/DoctrineMigrations/Version20161117071626.php
index e779eacf..0b34caab 100644
--- a/app/DoctrineMigrations/Version20161117071626.php
+++ b/app/DoctrineMigrations/Version20161117071626.php
@@ -22,11 +22,6 @@ class Version20161117071626 extends AbstractMigration implements ContainerAwareI
22 $this->container = $container; 22 $this->container = $container;
23 } 23 }
24 24
25 private function getTable($tableName)
26 {
27 return $this->container->getParameter('database_table_prefix').$tableName;
28 }
29
30 /** 25 /**
31 * @param Schema $schema 26 * @param Schema $schema
32 */ 27 */
@@ -35,19 +30,19 @@ class Version20161117071626 extends AbstractMigration implements ContainerAwareI
35 $share = $this->container 30 $share = $this->container
36 ->get('doctrine.orm.default_entity_manager') 31 ->get('doctrine.orm.default_entity_manager')
37 ->getConnection() 32 ->getConnection()
38 ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'share_unmark'"); 33 ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'share_unmark'");
39 34
40 if (false === $share) { 35 if (false === $share) {
41 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('share_unmark', 0, 'entry')"); 36 $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('share_unmark', 0, 'entry')");
42 } 37 }
43 38
44 $unmark = $this->container 39 $unmark = $this->container
45 ->get('doctrine.orm.default_entity_manager') 40 ->get('doctrine.orm.default_entity_manager')
46 ->getConnection() 41 ->getConnection()
47 ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'unmark_url'"); 42 ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'unmark_url'");
48 43
49 if (false === $unmark) { 44 if (false === $unmark) {
50 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('unmark_url', 'https://unmark.it', 'entry')"); 45 $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('unmark_url', 'https://unmark.it', 'entry')");
51 } 46 }
52 47
53 $this->skipIf(false !== $share && false !== $unmark, 'It seems that you already played this migration.'); 48 $this->skipIf(false !== $share && false !== $unmark, 'It seems that you already played this migration.');
@@ -58,7 +53,12 @@ class Version20161117071626 extends AbstractMigration implements ContainerAwareI
58 */ 53 */
59 public function down(Schema $schema) 54 public function down(Schema $schema)
60 { 55 {
61 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'share_unmark';"); 56 $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'share_unmark';");
62 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'unmark_url';"); 57 $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'unmark_url';");
58 }
59
60 private function getTable($tableName)
61 {
62 return $this->container->getParameter('database_table_prefix') . $tableName;
63 } 63 }
64} 64}
diff --git a/app/DoctrineMigrations/Version20161118134328.php b/app/DoctrineMigrations/Version20161118134328.php
index 7b2eeb7b..dab0ff5b 100644
--- a/app/DoctrineMigrations/Version20161118134328.php
+++ b/app/DoctrineMigrations/Version20161118134328.php
@@ -22,11 +22,6 @@ class Version20161118134328 extends AbstractMigration implements ContainerAwareI
22 $this->container = $container; 22 $this->container = $container;
23 } 23 }
24 24
25 private function getTable($tableName)
26 {
27 return $this->container->getParameter('database_table_prefix').$tableName;
28 }
29
30 /** 25 /**
31 * @param Schema $schema 26 * @param Schema $schema
32 */ 27 */
@@ -53,4 +48,9 @@ class Version20161118134328 extends AbstractMigration implements ContainerAwareI
53 48
54 $entryTable->dropColumn('http_status'); 49 $entryTable->dropColumn('http_status');
55 } 50 }
51
52 private function getTable($tableName)
53 {
54 return $this->container->getParameter('database_table_prefix') . $tableName;
55 }
56} 56}
diff --git a/app/DoctrineMigrations/Version20161122144743.php b/app/DoctrineMigrations/Version20161122144743.php
index 388a0e4b..15052ad7 100644
--- a/app/DoctrineMigrations/Version20161122144743.php
+++ b/app/DoctrineMigrations/Version20161122144743.php
@@ -22,11 +22,6 @@ class Version20161122144743 extends AbstractMigration implements ContainerAwareI
22 $this->container = $container; 22 $this->container = $container;
23 } 23 }
24 24
25 private function getTable($tableName)
26 {
27 return $this->container->getParameter('database_table_prefix').$tableName;
28 }
29
30 /** 25 /**
31 * @param Schema $schema 26 * @param Schema $schema
32 */ 27 */
@@ -35,11 +30,11 @@ class Version20161122144743 extends AbstractMigration implements ContainerAwareI
35 $access = $this->container 30 $access = $this->container
36 ->get('doctrine.orm.default_entity_manager') 31 ->get('doctrine.orm.default_entity_manager')
37 ->getConnection() 32 ->getConnection()
38 ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'restricted_access'"); 33 ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'restricted_access'");
39 34
40 $this->skipIf(false !== $access, 'It seems that you already played this migration.'); 35 $this->skipIf(false !== $access, 'It seems that you already played this migration.');
41 36
42 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('restricted_access', 0, 'entry')"); 37 $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('restricted_access', 0, 'entry')");
43 } 38 }
44 39
45 /** 40 /**
@@ -47,6 +42,11 @@ class Version20161122144743 extends AbstractMigration implements ContainerAwareI
47 */ 42 */
48 public function down(Schema $schema) 43 public function down(Schema $schema)
49 { 44 {
50 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'restricted_access';"); 45 $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'restricted_access';");
46 }
47
48 private function getTable($tableName)
49 {
50 return $this->container->getParameter('database_table_prefix') . $tableName;
51 } 51 }
52} 52}
diff --git a/app/DoctrineMigrations/Version20161122203647.php b/app/DoctrineMigrations/Version20161122203647.php
index 9b17d6ef..ef08bd59 100644
--- a/app/DoctrineMigrations/Version20161122203647.php
+++ b/app/DoctrineMigrations/Version20161122203647.php
@@ -30,11 +30,6 @@ class Version20161122203647 extends AbstractMigration implements ContainerAwareI
30 $this->container = $container; 30 $this->container = $container;
31 } 31 }
32 32
33 private function getTable($tableName)
34 {
35 return $this->container->getParameter('database_table_prefix').$tableName;
36 }
37
38 /** 33 /**
39 * @param Schema $schema 34 * @param Schema $schema
40 */ 35 */
@@ -60,4 +55,9 @@ class Version20161122203647 extends AbstractMigration implements ContainerAwareI
60 $userTable->addColumn('expired', 'smallint', ['notnull' => false]); 55 $userTable->addColumn('expired', 'smallint', ['notnull' => false]);
61 $userTable->addColumn('credentials_expired', 'smallint', ['notnull' => false]); 56 $userTable->addColumn('credentials_expired', 'smallint', ['notnull' => false]);
62 } 57 }
58
59 private function getTable($tableName)
60 {
61 return $this->container->getParameter('database_table_prefix') . $tableName;
62 }
63} 63}
diff --git a/app/DoctrineMigrations/Version20161128084725.php b/app/DoctrineMigrations/Version20161128084725.php
index ea370076..497a9f21 100644
--- a/app/DoctrineMigrations/Version20161128084725.php
+++ b/app/DoctrineMigrations/Version20161128084725.php
@@ -22,11 +22,6 @@ class Version20161128084725 extends AbstractMigration implements ContainerAwareI
22 $this->container = $container; 22 $this->container = $container;
23 } 23 }
24 24
25 private function getTable($tableName)
26 {
27 return $this->container->getParameter('database_table_prefix').$tableName;
28 }
29
30 /** 25 /**
31 * @param Schema $schema 26 * @param Schema $schema
32 */ 27 */
@@ -46,4 +41,9 @@ class Version20161128084725 extends AbstractMigration implements ContainerAwareI
46 $configTable = $schema->getTable($this->getTable('config')); 41 $configTable = $schema->getTable($this->getTable('config'));
47 $configTable->dropColumn('list_mode'); 42 $configTable->dropColumn('list_mode');
48 } 43 }
44
45 private function getTable($tableName)
46 {
47 return $this->container->getParameter('database_table_prefix') . $tableName;
48 }
49} 49}
diff --git a/app/DoctrineMigrations/Version20161128131503.php b/app/DoctrineMigrations/Version20161128131503.php
index b71aa38b..9d92983a 100644
--- a/app/DoctrineMigrations/Version20161128131503.php
+++ b/app/DoctrineMigrations/Version20161128131503.php
@@ -28,11 +28,6 @@ class Version20161128131503 extends AbstractMigration implements ContainerAwareI
28 $this->container = $container; 28 $this->container = $container;
29 } 29 }
30 30
31 private function getTable($tableName)
32 {
33 return $this->container->getParameter('database_table_prefix').$tableName;
34 }
35
36 /** 31 /**
37 * @param Schema $schema 32 * @param Schema $schema
38 */ 33 */
@@ -58,4 +53,9 @@ class Version20161128131503 extends AbstractMigration implements ContainerAwareI
58 $userTable->addColumn($field, $type, ['notnull' => false]); 53 $userTable->addColumn($field, $type, ['notnull' => false]);
59 } 54 }
60 } 55 }
56
57 private function getTable($tableName)
58 {
59 return $this->container->getParameter('database_table_prefix') . $tableName;
60 }
61} 61}
diff --git a/app/DoctrineMigrations/Version20161214094402.php b/app/DoctrineMigrations/Version20161214094402.php
index 8ca32b09..07090b2f 100644
--- a/app/DoctrineMigrations/Version20161214094402.php
+++ b/app/DoctrineMigrations/Version20161214094402.php
@@ -22,11 +22,6 @@ class Version20161214094402 extends AbstractMigration implements ContainerAwareI
22 $this->container = $container; 22 $this->container = $container;
23 } 23 }
24 24
25 private function getTable($tableName)
26 {
27 return $this->container->getParameter('database_table_prefix').$tableName;
28 }
29
30 /** 25 /**
31 * @param Schema $schema 26 * @param Schema $schema
32 */ 27 */
@@ -38,17 +33,17 @@ class Version20161214094402 extends AbstractMigration implements ContainerAwareI
38 33
39 switch ($this->connection->getDatabasePlatform()->getName()) { 34 switch ($this->connection->getDatabasePlatform()->getName()) {
40 case 'sqlite': 35 case 'sqlite':
41 $this->addSql('CREATE TEMPORARY TABLE __temp__wallabag_entry AS SELECT id, user_id, uuid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public FROM '.$this->getTable('entry')); 36 $this->addSql('CREATE TEMPORARY TABLE __temp__wallabag_entry AS SELECT id, user_id, uuid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public FROM ' . $this->getTable('entry'));
42 $this->addSql('DROP TABLE '.$this->getTable('entry')); 37 $this->addSql('DROP TABLE ' . $this->getTable('entry'));
43 $this->addSql('CREATE TABLE '.$this->getTable('entry').' (id INTEGER NOT NULL, user_id INTEGER DEFAULT NULL, uid CLOB DEFAULT NULL COLLATE BINARY, title CLOB DEFAULT NULL COLLATE BINARY, url CLOB DEFAULT NULL COLLATE BINARY, is_archived BOOLEAN NOT NULL, is_starred BOOLEAN NOT NULL, content CLOB DEFAULT NULL COLLATE BINARY, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, mimetype CLOB DEFAULT NULL COLLATE BINARY, language CLOB DEFAULT NULL COLLATE BINARY, reading_time INTEGER DEFAULT NULL, domain_name CLOB DEFAULT NULL COLLATE BINARY, preview_picture CLOB DEFAULT NULL COLLATE BINARY, is_public BOOLEAN DEFAULT "0", PRIMARY KEY(id));'); 38 $this->addSql('CREATE TABLE ' . $this->getTable('entry') . ' (id INTEGER NOT NULL, user_id INTEGER DEFAULT NULL, uid CLOB DEFAULT NULL COLLATE BINARY, title CLOB DEFAULT NULL COLLATE BINARY, url CLOB DEFAULT NULL COLLATE BINARY, is_archived BOOLEAN NOT NULL, is_starred BOOLEAN NOT NULL, content CLOB DEFAULT NULL COLLATE BINARY, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, mimetype CLOB DEFAULT NULL COLLATE BINARY, language CLOB DEFAULT NULL COLLATE BINARY, reading_time INTEGER DEFAULT NULL, domain_name CLOB DEFAULT NULL COLLATE BINARY, preview_picture CLOB DEFAULT NULL COLLATE BINARY, is_public BOOLEAN DEFAULT "0", PRIMARY KEY(id));');
44 $this->addSql('INSERT INTO '.$this->getTable('entry').' (id, user_id, uid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public) SELECT id, user_id, uuid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public FROM __temp__wallabag_entry;'); 39 $this->addSql('INSERT INTO ' . $this->getTable('entry') . ' (id, user_id, uid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public) SELECT id, user_id, uuid, title, url, is_archived, is_starred, content, created_at, updated_at, mimetype, language, reading_time, domain_name, preview_picture, is_public FROM __temp__wallabag_entry;');
45 $this->addSql('DROP TABLE __temp__wallabag_entry'); 40 $this->addSql('DROP TABLE __temp__wallabag_entry');
46 break; 41 break;
47 case 'mysql': 42 case 'mysql':
48 $this->addSql('ALTER TABLE '.$this->getTable('entry').' CHANGE uuid uid VARCHAR(23)'); 43 $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CHANGE uuid uid VARCHAR(23)');
49 break; 44 break;
50 case 'postgresql': 45 case 'postgresql':
51 $this->addSql('ALTER TABLE '.$this->getTable('entry').' RENAME uuid TO uid'); 46 $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' RENAME uuid TO uid');
52 } 47 }
53 } 48 }
54 49
@@ -66,10 +61,15 @@ class Version20161214094402 extends AbstractMigration implements ContainerAwareI
66 throw new SkipMigrationException('Too complex ...'); 61 throw new SkipMigrationException('Too complex ...');
67 break; 62 break;
68 case 'mysql': 63 case 'mysql':
69 $this->addSql('ALTER TABLE '.$this->getTable('entry').' CHANGE uid uuid VARCHAR(23)'); 64 $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' CHANGE uid uuid VARCHAR(23)');
70 break; 65 break;
71 case 'postgresql': 66 case 'postgresql':
72 $this->addSql('ALTER TABLE '.$this->getTable('entry').' RENAME uid TO uuid'); 67 $this->addSql('ALTER TABLE ' . $this->getTable('entry') . ' RENAME uid TO uuid');
73 } 68 }
74 } 69 }
70
71 private function getTable($tableName)
72 {
73 return $this->container->getParameter('database_table_prefix') . $tableName;
74 }
75} 75}
diff --git a/app/DoctrineMigrations/Version20161214094403.php b/app/DoctrineMigrations/Version20161214094403.php
index c7326f95..6b5640e5 100644
--- a/app/DoctrineMigrations/Version20161214094403.php
+++ b/app/DoctrineMigrations/Version20161214094403.php
@@ -24,11 +24,6 @@ class Version20161214094403 extends AbstractMigration implements ContainerAwareI
24 $this->container = $container; 24 $this->container = $container;
25 } 25 }
26 26
27 private function getTable($tableName)
28 {
29 return $this->container->getParameter('database_table_prefix').$tableName;
30 }
31
32 /** 27 /**
33 * @param Schema $schema 28 * @param Schema $schema
34 */ 29 */
@@ -50,4 +45,9 @@ class Version20161214094403 extends AbstractMigration implements ContainerAwareI
50 45
51 $entryTable->dropIndex($this->indexName); 46 $entryTable->dropIndex($this->indexName);
52 } 47 }
48
49 private function getTable($tableName)
50 {
51 return $this->container->getParameter('database_table_prefix') . $tableName;
52 }
53} 53}
diff --git a/app/DoctrineMigrations/Version20170127093841.php b/app/DoctrineMigrations/Version20170127093841.php
index 5bfd9670..fc78a246 100644
--- a/app/DoctrineMigrations/Version20170127093841.php
+++ b/app/DoctrineMigrations/Version20170127093841.php
@@ -25,11 +25,6 @@ class Version20170127093841 extends AbstractMigration implements ContainerAwareI
25 $this->container = $container; 25 $this->container = $container;
26 } 26 }
27 27
28 private function getTable($tableName)
29 {
30 return $this->container->getParameter('database_table_prefix').$tableName;
31 }
32
33 /** 28 /**
34 * @param Schema $schema 29 * @param Schema $schema
35 */ 30 */
@@ -53,4 +48,9 @@ class Version20170127093841 extends AbstractMigration implements ContainerAwareI
53 $entryTable->dropIndex($this->indexStarredName); 48 $entryTable->dropIndex($this->indexStarredName);
54 $entryTable->dropIndex($this->indexArchivedName); 49 $entryTable->dropIndex($this->indexArchivedName);
55 } 50 }
51
52 private function getTable($tableName)
53 {
54 return $this->container->getParameter('database_table_prefix') . $tableName;
55 }
56} 56}
diff --git a/app/DoctrineMigrations/Version20170327194233.php b/app/DoctrineMigrations/Version20170327194233.php
index e1466b2f..3e7e722d 100644
--- a/app/DoctrineMigrations/Version20170327194233.php
+++ b/app/DoctrineMigrations/Version20170327194233.php
@@ -22,11 +22,6 @@ class Version20170327194233 extends AbstractMigration implements ContainerAwareI
22 $this->container = $container; 22 $this->container = $container;
23 } 23 }
24 24
25 private function getTable($tableName)
26 {
27 return $this->container->getParameter('database_table_prefix').$tableName;
28 }
29
30 /** 25 /**
31 * @param Schema $schema 26 * @param Schema $schema
32 */ 27 */
@@ -35,12 +30,12 @@ class Version20170327194233 extends AbstractMigration implements ContainerAwareI
35 $scuttle = $this->container 30 $scuttle = $this->container
36 ->get('doctrine.orm.default_entity_manager') 31 ->get('doctrine.orm.default_entity_manager')
37 ->getConnection() 32 ->getConnection()
38 ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'share_scuttle'"); 33 ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'share_scuttle'");
39 34
40 $this->skipIf(false !== $scuttle, 'It seems that you already played this migration.'); 35 $this->skipIf(false !== $scuttle, 'It seems that you already played this migration.');
41 36
42 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('share_scuttle', '1', 'entry')"); 37 $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('share_scuttle', '1', 'entry')");
43 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('scuttle_url', 'http://scuttle.org', 'entry')"); 38 $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('scuttle_url', 'http://scuttle.org', 'entry')");
44 } 39 }
45 40
46 /** 41 /**
@@ -48,7 +43,12 @@ class Version20170327194233 extends AbstractMigration implements ContainerAwareI
48 */ 43 */
49 public function down(Schema $schema) 44 public function down(Schema $schema)
50 { 45 {
51 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'share_scuttle';"); 46 $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'share_scuttle';");
52 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'scuttle_url';"); 47 $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'scuttle_url';");
48 }
49
50 private function getTable($tableName)
51 {
52 return $this->container->getParameter('database_table_prefix') . $tableName;
53 } 53 }
54} 54}
diff --git a/app/DoctrineMigrations/Version20170405182620.php b/app/DoctrineMigrations/Version20170405182620.php
index 3ef9633f..75793fcb 100644
--- a/app/DoctrineMigrations/Version20170405182620.php
+++ b/app/DoctrineMigrations/Version20170405182620.php
@@ -22,11 +22,6 @@ class Version20170405182620 extends AbstractMigration implements ContainerAwareI
22 $this->container = $container; 22 $this->container = $container;
23 } 23 }
24 24
25 private function getTable($tableName)
26 {
27 return $this->container->getParameter('database_table_prefix').$tableName;
28 }
29
30 /** 25 /**
31 * @param Schema $schema 26 * @param Schema $schema
32 */ 27 */
@@ -62,4 +57,9 @@ class Version20170405182620 extends AbstractMigration implements ContainerAwareI
62 57
63 $entryTable->dropColumn('published_by'); 58 $entryTable->dropColumn('published_by');
64 } 59 }
60
61 private function getTable($tableName)
62 {
63 return $this->container->getParameter('database_table_prefix') . $tableName;
64 }
65} 65}
diff --git a/app/DoctrineMigrations/Version20170407200919.php b/app/DoctrineMigrations/Version20170407200919.php
index 4b9d475a..8a11ffe3 100644
--- a/app/DoctrineMigrations/Version20170407200919.php
+++ b/app/DoctrineMigrations/Version20170407200919.php
@@ -22,11 +22,6 @@ class Version20170407200919 extends AbstractMigration implements ContainerAwareI
22 $this->container = $container; 22 $this->container = $container;
23 } 23 }
24 24
25 private function getTable($tableName)
26 {
27 return $this->container->getParameter('database_table_prefix').$tableName;
28 }
29
30 /** 25 /**
31 * @param Schema $schema 26 * @param Schema $schema
32 */ 27 */
@@ -48,4 +43,9 @@ class Version20170407200919 extends AbstractMigration implements ContainerAwareI
48 43
49 $entryTable->addColumn('is_public', 'boolean', ['notnull' => false, 'default' => 0]); 44 $entryTable->addColumn('is_public', 'boolean', ['notnull' => false, 'default' => 0]);
50 } 45 }
46
47 private function getTable($tableName)
48 {
49 return $this->container->getParameter('database_table_prefix') . $tableName;
50 }
51} 51}
diff --git a/app/DoctrineMigrations/Version20170420134133.php b/app/DoctrineMigrations/Version20170420134133.php
index b1ab7bcb..e1947a49 100644
--- a/app/DoctrineMigrations/Version20170420134133.php
+++ b/app/DoctrineMigrations/Version20170420134133.php
@@ -22,17 +22,12 @@ class Version20170420134133 extends AbstractMigration implements ContainerAwareI
22 $this->container = $container; 22 $this->container = $container;
23 } 23 }
24 24
25 private function getTable($tableName)
26 {
27 return $this->container->getParameter('database_table_prefix').$tableName;
28 }
29
30 /** 25 /**
31 * @param Schema $schema 26 * @param Schema $schema
32 */ 27 */
33 public function up(Schema $schema) 28 public function up(Schema $schema)
34 { 29 {
35 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'download_pictures';"); 30 $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'download_pictures';");
36 } 31 }
37 32
38 /** 33 /**
@@ -43,10 +38,15 @@ class Version20170420134133 extends AbstractMigration implements ContainerAwareI
43 $downloadPictures = $this->container 38 $downloadPictures = $this->container
44 ->get('doctrine.orm.default_entity_manager') 39 ->get('doctrine.orm.default_entity_manager')
45 ->getConnection() 40 ->getConnection()
46 ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'download_pictures'"); 41 ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'download_pictures'");
47 42
48 $this->skipIf(false !== $downloadPictures, 'It seems that you already played this migration.'); 43 $this->skipIf(false !== $downloadPictures, 'It seems that you already played this migration.');
49 44
50 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('download_pictures', '1', 'entry')"); 45 $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('download_pictures', '1', 'entry')");
46 }
47
48 private function getTable($tableName)
49 {
50 return $this->container->getParameter('database_table_prefix') . $tableName;
51 } 51 }
52} 52}
diff --git a/app/DoctrineMigrations/Version20170501115751.php b/app/DoctrineMigrations/Version20170501115751.php
index 7f068eb8..adf2f841 100644
--- a/app/DoctrineMigrations/Version20170501115751.php
+++ b/app/DoctrineMigrations/Version20170501115751.php
@@ -8,7 +8,7 @@ use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8use Symfony\Component\DependencyInjection\ContainerInterface; 8use Symfony\Component\DependencyInjection\ContainerInterface;
9 9
10/** 10/**
11 * Add site credential table to store username & password for some website (behind authentication or paywall) 11 * Add site credential table to store username & password for some website (behind authentication or paywall).
12 */ 12 */
13class Version20170501115751 extends AbstractMigration implements ContainerAwareInterface 13class Version20170501115751 extends AbstractMigration implements ContainerAwareInterface
14{ 14{
@@ -22,11 +22,6 @@ class Version20170501115751 extends AbstractMigration implements ContainerAwareI
22 $this->container = $container; 22 $this->container = $container;
23 } 23 }
24 24
25 private function getTable($tableName)
26 {
27 return $this->container->getParameter('database_table_prefix').$tableName;
28 }
29
30 /** 25 /**
31 * @param Schema $schema 26 * @param Schema $schema
32 */ 27 */
@@ -58,4 +53,9 @@ class Version20170501115751 extends AbstractMigration implements ContainerAwareI
58 { 53 {
59 $schema->dropTable($this->getTable('site_credential')); 54 $schema->dropTable($this->getTable('site_credential'));
60 } 55 }
56
57 private function getTable($tableName)
58 {
59 return $this->container->getParameter('database_table_prefix') . $tableName;
60 }
61} 61}
diff --git a/app/DoctrineMigrations/Version20170510082609.php b/app/DoctrineMigrations/Version20170510082609.php
index a99af2d2..329613b1 100644
--- a/app/DoctrineMigrations/Version20170510082609.php
+++ b/app/DoctrineMigrations/Version20170510082609.php
@@ -29,11 +29,6 @@ class Version20170510082609 extends AbstractMigration implements ContainerAwareI
29 $this->container = $container; 29 $this->container = $container;
30 } 30 }
31 31
32 private function getTable($tableName)
33 {
34 return $this->container->getParameter('database_table_prefix').$tableName;
35 }
36
37 /** 32 /**
38 * @param Schema $schema 33 * @param Schema $schema
39 */ 34 */
@@ -42,7 +37,7 @@ class Version20170510082609 extends AbstractMigration implements ContainerAwareI
42 $this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL'); 37 $this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL');
43 38
44 foreach ($this->fields as $field) { 39 foreach ($this->fields as $field) {
45 $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE '.$field.' '.$field.' VARCHAR(180) NOT NULL;'); 40 $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE ' . $field . ' ' . $field . ' VARCHAR(180) NOT NULL;');
46 } 41 }
47 } 42 }
48 43
@@ -54,7 +49,12 @@ class Version20170510082609 extends AbstractMigration implements ContainerAwareI
54 $this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL'); 49 $this->skipIf($this->connection->getDatabasePlatform()->getName() !== 'mysql', 'This migration only apply to MySQL');
55 50
56 foreach ($this->fields as $field) { 51 foreach ($this->fields as $field) {
57 $this->addSql('ALTER TABLE '.$this->getTable('user').' CHANGE '.$field.' '.$field.' VARCHAR(255) NOT NULL;'); 52 $this->addSql('ALTER TABLE ' . $this->getTable('user') . ' CHANGE ' . $field . ' ' . $field . ' VARCHAR(255) NOT NULL;');
58 } 53 }
59 } 54 }
55
56 private function getTable($tableName)
57 {
58 return $this->container->getParameter('database_table_prefix') . $tableName;
59 }
60} 60}
diff --git a/app/DoctrineMigrations/Version20170511115400.php b/app/DoctrineMigrations/Version20170511115400.php
index 64ee9e0a..cad2b637 100644
--- a/app/DoctrineMigrations/Version20170511115400.php
+++ b/app/DoctrineMigrations/Version20170511115400.php
@@ -22,11 +22,6 @@ class Version20170511115400 extends AbstractMigration implements ContainerAwareI
22 $this->container = $container; 22 $this->container = $container;
23 } 23 }
24 24
25 private function getTable($tableName)
26 {
27 return $this->container->getParameter('database_table_prefix').$tableName;
28 }
29
30 /** 25 /**
31 * @param Schema $schema 26 * @param Schema $schema
32 */ 27 */
@@ -52,4 +47,9 @@ class Version20170511115400 extends AbstractMigration implements ContainerAwareI
52 47
53 $entryTable->dropColumn('headers'); 48 $entryTable->dropColumn('headers');
54 } 49 }
50
51 private function getTable($tableName)
52 {
53 return $this->container->getParameter('database_table_prefix') . $tableName;
54 }
55} 55}
diff --git a/app/DoctrineMigrations/Version20170511211659.php b/app/DoctrineMigrations/Version20170511211659.php
index f2d5cf5e..f004d1b3 100644
--- a/app/DoctrineMigrations/Version20170511211659.php
+++ b/app/DoctrineMigrations/Version20170511211659.php
@@ -9,7 +9,7 @@ use Symfony\Component\DependencyInjection\ContainerAwareInterface;
9use Symfony\Component\DependencyInjection\ContainerInterface; 9use Symfony\Component\DependencyInjection\ContainerInterface;
10 10
11/** 11/**
12 * Increase the length of the "quote" column of "annotation" table 12 * Increase the length of the "quote" column of "annotation" table.
13 */ 13 */
14class Version20170511211659 extends AbstractMigration implements ContainerAwareInterface 14class Version20170511211659 extends AbstractMigration implements ContainerAwareInterface
15{ 15{
@@ -23,11 +23,6 @@ class Version20170511211659 extends AbstractMigration implements ContainerAwareI
23 $this->container = $container; 23 $this->container = $container;
24 } 24 }
25 25
26 private function getTable($tableName)
27 {
28 return $this->container->getParameter('database_table_prefix') . $tableName;
29 }
30
31 public function up(Schema $schema) 26 public function up(Schema $schema)
32 { 27 {
33 $tableName = $this->getTable('annotation'); 28 $tableName = $this->getTable('annotation');
@@ -68,13 +63,11 @@ EOD
68 ); 63 );
69 $this->addSql('DROP TABLE __temp__wallabag_annotation'); 64 $this->addSql('DROP TABLE __temp__wallabag_annotation');
70 break; 65 break;
71
72 case 'mysql': 66 case 'mysql':
73 $this->addSql('ALTER TABLE '.$tableName.' MODIFY quote TEXT NOT NULL'); 67 $this->addSql('ALTER TABLE ' . $tableName . ' MODIFY quote TEXT NOT NULL');
74 break; 68 break;
75
76 case 'postgresql': 69 case 'postgresql':
77 $this->addSql('ALTER TABLE '.$tableName.' ALTER COLUMN quote TYPE TEXT'); 70 $this->addSql('ALTER TABLE ' . $tableName . ' ALTER COLUMN quote TYPE TEXT');
78 break; 71 break;
79 } 72 }
80 } 73 }
@@ -87,14 +80,17 @@ EOD
87 case 'sqlite': 80 case 'sqlite':
88 throw new SkipMigrationException('Too complex ...'); 81 throw new SkipMigrationException('Too complex ...');
89 break; 82 break;
90
91 case 'mysql': 83 case 'mysql':
92 $this->addSql('ALTER TABLE '.$tableName.' MODIFY quote VARCHAR(255) NOT NULL'); 84 $this->addSql('ALTER TABLE ' . $tableName . ' MODIFY quote VARCHAR(255) NOT NULL');
93 break; 85 break;
94
95 case 'postgresql': 86 case 'postgresql':
96 $this->addSql('ALTER TABLE '.$tableName.' ALTER COLUMN quote TYPE VARCHAR(255)'); 87 $this->addSql('ALTER TABLE ' . $tableName . ' ALTER COLUMN quote TYPE VARCHAR(255)');
97 break; 88 break;
98 } 89 }
99 } 90 }
91
92 private function getTable($tableName)
93 {
94 return $this->container->getParameter('database_table_prefix') . $tableName;
95 }
100} 96}
diff --git a/app/DoctrineMigrations/Version20170602075214.php b/app/DoctrineMigrations/Version20170602075214.php
index 451d16ba..6b6f0035 100644
--- a/app/DoctrineMigrations/Version20170602075214.php
+++ b/app/DoctrineMigrations/Version20170602075214.php
@@ -22,11 +22,6 @@ class Version20170602075214 extends AbstractMigration implements ContainerAwareI
22 $this->container = $container; 22 $this->container = $container;
23 } 23 }
24 24
25 private function getTable($tableName)
26 {
27 return $this->container->getParameter('database_table_prefix').$tableName;
28 }
29
30 /** 25 /**
31 * @param Schema $schema 26 * @param Schema $schema
32 */ 27 */
@@ -35,11 +30,11 @@ class Version20170602075214 extends AbstractMigration implements ContainerAwareI
35 $apiUserRegistration = $this->container 30 $apiUserRegistration = $this->container
36 ->get('doctrine.orm.default_entity_manager') 31 ->get('doctrine.orm.default_entity_manager')
37 ->getConnection() 32 ->getConnection()
38 ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'api_user_registration'"); 33 ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'api_user_registration'");
39 34
40 $this->skipIf(false !== $apiUserRegistration, 'It seems that you already played this migration.'); 35 $this->skipIf(false !== $apiUserRegistration, 'It seems that you already played this migration.');
41 36
42 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('api_user_registration', '0', 'api')"); 37 $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('api_user_registration', '0', 'api')");
43 } 38 }
44 39
45 /** 40 /**
@@ -47,6 +42,11 @@ class Version20170602075214 extends AbstractMigration implements ContainerAwareI
47 */ 42 */
48 public function down(Schema $schema) 43 public function down(Schema $schema)
49 { 44 {
50 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'api_user_registration';"); 45 $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'api_user_registration';");
46 }
47
48 private function getTable($tableName)
49 {
50 return $this->container->getParameter('database_table_prefix') . $tableName;
51 } 51 }
52} 52}
diff --git a/app/DoctrineMigrations/Version20170606155640.php b/app/DoctrineMigrations/Version20170606155640.php
index e9b50428..5f58fc29 100644
--- a/app/DoctrineMigrations/Version20170606155640.php
+++ b/app/DoctrineMigrations/Version20170606155640.php
@@ -9,7 +9,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
9 9
10/** 10/**
11 * Remove wallabag_url from craue_config_setting. 11 * Remove wallabag_url from craue_config_setting.
12 * It has been moved into the parameters.yml 12 * It has been moved into the parameters.yml.
13 */ 13 */
14class Version20170606155640 extends AbstractMigration implements ContainerAwareInterface 14class Version20170606155640 extends AbstractMigration implements ContainerAwareInterface
15{ 15{
@@ -23,11 +23,6 @@ class Version20170606155640 extends AbstractMigration implements ContainerAwareI
23 $this->container = $container; 23 $this->container = $container;
24 } 24 }
25 25
26 private function getTable($tableName)
27 {
28 return $this->container->getParameter('database_table_prefix').$tableName;
29 }
30
31 /** 26 /**
32 * @param Schema $schema 27 * @param Schema $schema
33 */ 28 */
@@ -36,11 +31,11 @@ class Version20170606155640 extends AbstractMigration implements ContainerAwareI
36 $apiUserRegistration = $this->container 31 $apiUserRegistration = $this->container
37 ->get('doctrine.orm.default_entity_manager') 32 ->get('doctrine.orm.default_entity_manager')
38 ->getConnection() 33 ->getConnection()
39 ->fetchArray('SELECT * FROM '.$this->getTable('craue_config_setting')." WHERE name = 'wallabag_url'"); 34 ->fetchArray('SELECT * FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'wallabag_url'");
40 35
41 $this->skipIf(false === $apiUserRegistration, 'It seems that you already played this migration.'); 36 $this->skipIf(false === $apiUserRegistration, 'It seems that you already played this migration.');
42 37
43 $this->addSql('DELETE FROM '.$this->getTable('craue_config_setting')." WHERE name = 'wallabag_url'"); 38 $this->addSql('DELETE FROM ' . $this->getTable('craue_config_setting') . " WHERE name = 'wallabag_url'");
44 } 39 }
45 40
46 /** 41 /**
@@ -48,6 +43,11 @@ class Version20170606155640 extends AbstractMigration implements ContainerAwareI
48 */ 43 */
49 public function down(Schema $schema) 44 public function down(Schema $schema)
50 { 45 {
51 $this->addSql('INSERT INTO '.$this->getTable('craue_config_setting')." (name, value, section) VALUES ('wallabag_url', 'wallabag.me', 'misc')"); 46 $this->addSql('INSERT INTO ' . $this->getTable('craue_config_setting') . " (name, value, section) VALUES ('wallabag_url', 'wallabag.me', 'misc')");
47 }
48
49 private function getTable($tableName)
50 {
51 return $this->container->getParameter('database_table_prefix') . $tableName;
52 } 52 }
53} 53}
diff --git a/app/autoload.php b/app/autoload.php
index fa582ecd..c5f664dc 100644
--- a/app/autoload.php
+++ b/app/autoload.php
@@ -1,12 +1,12 @@
1<?php 1<?php
2 2
3use Doctrine\Common\Annotations\AnnotationRegistry;
4use Composer\Autoload\ClassLoader; 3use Composer\Autoload\ClassLoader;
4use Doctrine\Common\Annotations\AnnotationRegistry;
5 5
6/** 6/**
7 * @var ClassLoader $loader 7 * @var ClassLoader
8 */ 8 */
9$loader = require __DIR__.'/../vendor/autoload.php'; 9$loader = require __DIR__ . '/../vendor/autoload.php';
10 10
11AnnotationRegistry::registerLoader([$loader, 'loadClass']); 11AnnotationRegistry::registerLoader([$loader, 'loadClass']);
12 12
diff --git a/composer.json b/composer.json
index 7428f688..e609af40 100644
--- a/composer.json
+++ b/composer.json
@@ -91,7 +91,7 @@
91 "doctrine/data-fixtures": "~1.1.1", 91 "doctrine/data-fixtures": "~1.1.1",
92 "sensio/generator-bundle": "^3.0", 92 "sensio/generator-bundle": "^3.0",
93 "symfony/phpunit-bridge": "^3.3", 93 "symfony/phpunit-bridge": "^3.3",
94 "friendsofphp/php-cs-fixer": "~1.9", 94 "friendsofphp/php-cs-fixer": "~2.0",
95 "m6web/redis-mock": "^2.0", 95 "m6web/redis-mock": "^2.0",
96 "dama/doctrine-test-bundle": "^1.0" 96 "dama/doctrine-test-bundle": "^1.0"
97 }, 97 },
diff --git a/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php b/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php
index 2b4b0e8d..8d7b6ee9 100644
--- a/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php
+++ b/src/Wallabag/AnnotationBundle/Controller/WallabagAnnotationController.php
@@ -3,9 +3,9 @@
3namespace Wallabag\AnnotationBundle\Controller; 3namespace Wallabag\AnnotationBundle\Controller;
4 4
5use FOS\RestBundle\Controller\FOSRestController; 5use FOS\RestBundle\Controller\FOSRestController;
6use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
6use Symfony\Component\HttpFoundation\JsonResponse; 7use Symfony\Component\HttpFoundation\JsonResponse;
7use Symfony\Component\HttpFoundation\Request; 8use Symfony\Component\HttpFoundation\Request;
8use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
9use Wallabag\AnnotationBundle\Entity\Annotation; 9use Wallabag\AnnotationBundle\Entity\Annotation;
10use Wallabag\AnnotationBundle\Form\EditAnnotationType; 10use Wallabag\AnnotationBundle\Form\EditAnnotationType;
11use Wallabag\AnnotationBundle\Form\NewAnnotationType; 11use Wallabag\AnnotationBundle\Form\NewAnnotationType;
diff --git a/src/Wallabag/AnnotationBundle/Entity/Annotation.php b/src/Wallabag/AnnotationBundle/Entity/Annotation.php
index c8e41649..04d83001 100644
--- a/src/Wallabag/AnnotationBundle/Entity/Annotation.php
+++ b/src/Wallabag/AnnotationBundle/Entity/Annotation.php
@@ -3,14 +3,14 @@
3namespace Wallabag\AnnotationBundle\Entity; 3namespace Wallabag\AnnotationBundle\Entity;
4 4
5use Doctrine\ORM\Mapping as ORM; 5use Doctrine\ORM\Mapping as ORM;
6use JMS\Serializer\Annotation\ExclusionPolicy;
7use JMS\Serializer\Annotation\Exclude; 6use JMS\Serializer\Annotation\Exclude;
8use JMS\Serializer\Annotation\VirtualProperty; 7use JMS\Serializer\Annotation\ExclusionPolicy;
9use JMS\Serializer\Annotation\SerializedName;
10use JMS\Serializer\Annotation\Groups; 8use JMS\Serializer\Annotation\Groups;
9use JMS\Serializer\Annotation\SerializedName;
10use JMS\Serializer\Annotation\VirtualProperty;
11use Symfony\Component\Validator\Constraints as Assert; 11use Symfony\Component\Validator\Constraints as Assert;
12use Wallabag\UserBundle\Entity\User;
13use Wallabag\CoreBundle\Entity\Entry; 12use Wallabag\CoreBundle\Entity\Entry;
13use Wallabag\UserBundle\Entity\User;
14 14
15/** 15/**
16 * Annotation. 16 * Annotation.
@@ -139,7 +139,7 @@ class Annotation
139 */ 139 */
140 public function timestamps() 140 public function timestamps()
141 { 141 {
142 if (is_null($this->createdAt)) { 142 if (null === $this->createdAt) {
143 $this->createdAt = new \DateTime(); 143 $this->createdAt = new \DateTime();
144 } 144 }
145 $this->updatedAt = new \DateTime(); 145 $this->updatedAt = new \DateTime();
diff --git a/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php b/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php
index da361308..014c29b6 100644
--- a/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php
+++ b/src/Wallabag/AnnotationBundle/Repository/AnnotationRepository.php
@@ -10,22 +10,6 @@ use Doctrine\ORM\EntityRepository;
10class AnnotationRepository extends EntityRepository 10class AnnotationRepository extends EntityRepository
11{ 11{
12 /** 12 /**
13 * Return a query builder to used by other getBuilderFor* method.
14 *
15 * @param int $userId
16 *
17 * @return QueryBuilder
18 */
19 private function getBuilderByUser($userId)
20 {
21 return $this->createQueryBuilder('a')
22 ->leftJoin('a.user', 'u')
23 ->andWhere('u.id = :userId')->setParameter('userId', $userId)
24 ->orderBy('a.id', 'desc')
25 ;
26 }
27
28 /**
29 * Retrieves all annotations for a user. 13 * Retrieves all annotations for a user.
30 * 14 *
31 * @param int $userId 15 * @param int $userId
@@ -139,4 +123,20 @@ class AnnotationRepository extends EntityRepository
139 ->getQuery() 123 ->getQuery()
140 ->getResult(); 124 ->getResult();
141 } 125 }
126
127 /**
128 * Return a query builder to used by other getBuilderFor* method.
129 *
130 * @param int $userId
131 *
132 * @return QueryBuilder
133 */
134 private function getBuilderByUser($userId)
135 {
136 return $this->createQueryBuilder('a')
137 ->leftJoin('a.user', 'u')
138 ->andWhere('u.id = :userId')->setParameter('userId', $userId)
139 ->orderBy('a.id', 'desc')
140 ;
141 }
142} 142}
diff --git a/src/Wallabag/ApiBundle/Controller/AnnotationRestController.php b/src/Wallabag/ApiBundle/Controller/AnnotationRestController.php
index 2dd26c07..28d55ba9 100644
--- a/src/Wallabag/ApiBundle/Controller/AnnotationRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/AnnotationRestController.php
@@ -4,10 +4,10 @@ namespace Wallabag\ApiBundle\Controller;
4 4
5use Nelmio\ApiDocBundle\Annotation\ApiDoc; 5use Nelmio\ApiDocBundle\Annotation\ApiDoc;
6use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; 6use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
7use Symfony\Component\HttpFoundation\Request;
8use Symfony\Component\HttpFoundation\JsonResponse; 7use Symfony\Component\HttpFoundation\JsonResponse;
9use Wallabag\CoreBundle\Entity\Entry; 8use Symfony\Component\HttpFoundation\Request;
10use Wallabag\AnnotationBundle\Entity\Annotation; 9use Wallabag\AnnotationBundle\Entity\Annotation;
10use Wallabag\CoreBundle\Entity\Entry;
11 11
12class AnnotationRestController extends WallabagRestController 12class AnnotationRestController extends WallabagRestController
13{ 13{
diff --git a/src/Wallabag/ApiBundle/Controller/DeveloperController.php b/src/Wallabag/ApiBundle/Controller/DeveloperController.php
index 9cb73f4c..c8a1c635 100644
--- a/src/Wallabag/ApiBundle/Controller/DeveloperController.php
+++ b/src/Wallabag/ApiBundle/Controller/DeveloperController.php
@@ -3,8 +3,8 @@
3namespace Wallabag\ApiBundle\Controller; 3namespace Wallabag\ApiBundle\Controller;
4 4
5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Component\HttpFoundation\Request;
7use Symfony\Bundle\FrameworkBundle\Controller\Controller; 6use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7use Symfony\Component\HttpFoundation\Request;
8use Wallabag\ApiBundle\Entity\Client; 8use Wallabag\ApiBundle\Entity\Client;
9use Wallabag\ApiBundle\Form\Type\ClientType; 9use Wallabag\ApiBundle\Form\Type\ClientType;
10 10
@@ -75,7 +75,7 @@ class DeveloperController extends Controller
75 */ 75 */
76 public function deleteClientAction(Client $client) 76 public function deleteClientAction(Client $client)
77 { 77 {
78 if (null === $this->getUser() || $client->getUser()->getId() != $this->getUser()->getId()) { 78 if (null === $this->getUser() || $client->getUser()->getId() !== $this->getUser()->getId()) {
79 throw $this->createAccessDeniedException('You can not access this client.'); 79 throw $this->createAccessDeniedException('You can not access this client.');
80 } 80 }
81 81
diff --git a/src/Wallabag/ApiBundle/Controller/EntryRestController.php b/src/Wallabag/ApiBundle/Controller/EntryRestController.php
index c7938633..ca460c84 100644
--- a/src/Wallabag/ApiBundle/Controller/EntryRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/EntryRestController.php
@@ -6,14 +6,14 @@ use Hateoas\Configuration\Route;
6use Hateoas\Representation\Factory\PagerfantaFactory; 6use Hateoas\Representation\Factory\PagerfantaFactory;
7use JMS\Serializer\SerializationContext; 7use JMS\Serializer\SerializationContext;
8use Nelmio\ApiDocBundle\Annotation\ApiDoc; 8use Nelmio\ApiDocBundle\Annotation\ApiDoc;
9use Symfony\Component\HttpKernel\Exception\HttpException;
10use Symfony\Component\HttpFoundation\Request;
11use Symfony\Component\HttpFoundation\JsonResponse; 9use Symfony\Component\HttpFoundation\JsonResponse;
10use Symfony\Component\HttpFoundation\Request;
11use Symfony\Component\HttpKernel\Exception\HttpException;
12use Symfony\Component\Routing\Generator\UrlGeneratorInterface; 12use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
13use Wallabag\CoreBundle\Entity\Entry; 13use Wallabag\CoreBundle\Entity\Entry;
14use Wallabag\CoreBundle\Entity\Tag; 14use Wallabag\CoreBundle\Entity\Tag;
15use Wallabag\CoreBundle\Event\EntrySavedEvent;
16use Wallabag\CoreBundle\Event\EntryDeletedEvent; 15use Wallabag\CoreBundle\Event\EntryDeletedEvent;
16use Wallabag\CoreBundle\Event\EntrySavedEvent;
17 17
18class EntryRestController extends WallabagRestController 18class EntryRestController extends WallabagRestController
19{ 19{
@@ -59,7 +59,7 @@ class EntryRestController extends WallabagRestController
59 $url = $request->query->get('url', ''); 59 $url = $request->query->get('url', '');
60 60
61 if (empty($url)) { 61 if (empty($url)) {
62 throw $this->createAccessDeniedException('URL is empty?, logged user id: '.$this->getUser()->getId()); 62 throw $this->createAccessDeniedException('URL is empty?, logged user id: ' . $this->getUser()->getId());
63 } 63 }
64 64
65 $res = $this->getDoctrine() 65 $res = $this->getDoctrine()
@@ -239,9 +239,9 @@ class EntryRestController extends WallabagRestController
239 * } 239 * }
240 * ) 240 * )
241 * 241 *
242 * @return JsonResponse
243 *
244 * @throws HttpException When limit is reached 242 * @throws HttpException When limit is reached
243 *
244 * @return JsonResponse
245 */ 245 */
246 public function postEntriesListAction(Request $request) 246 public function postEntriesListAction(Request $request)
247 { 247 {
@@ -678,11 +678,11 @@ class EntryRestController extends WallabagRestController
678 ]); 678 ]);
679 } 679 }
680 680
681 if (!is_null($isArchived)) { 681 if (null !== $isArchived) {
682 $entry->setArchived((bool) $isArchived); 682 $entry->setArchived((bool) $isArchived);
683 } 683 }
684 684
685 if (!is_null($isStarred)) { 685 if (null !== $isStarred) {
686 $entry->setStarred((bool) $isStarred); 686 $entry->setStarred((bool) $isStarred);
687 } 687 }
688 688
@@ -690,7 +690,7 @@ class EntryRestController extends WallabagRestController
690 $this->get('wallabag_core.tags_assigner')->assignTagsToEntry($entry, $tags); 690 $this->get('wallabag_core.tags_assigner')->assignTagsToEntry($entry, $tags);
691 } 691 }
692 692
693 if (!is_null($isPublic)) { 693 if (null !== $isPublic) {
694 if (true === (bool) $isPublic && null === $entry->getUid()) { 694 if (true === (bool) $isPublic && null === $entry->getUid()) {
695 $entry->generateUid(); 695 $entry->generateUid();
696 } elseif (false === (bool) $isPublic) { 696 } elseif (false === (bool) $isPublic) {
diff --git a/src/Wallabag/ApiBundle/Controller/TagRestController.php b/src/Wallabag/ApiBundle/Controller/TagRestController.php
index 354187a0..efa4e8cf 100644
--- a/src/Wallabag/ApiBundle/Controller/TagRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/TagRestController.php
@@ -3,8 +3,8 @@
3namespace Wallabag\ApiBundle\Controller; 3namespace Wallabag\ApiBundle\Controller;
4 4
5use Nelmio\ApiDocBundle\Annotation\ApiDoc; 5use Nelmio\ApiDocBundle\Annotation\ApiDoc;
6use Symfony\Component\HttpFoundation\Request;
7use Symfony\Component\HttpFoundation\JsonResponse; 6use Symfony\Component\HttpFoundation\JsonResponse;
7use Symfony\Component\HttpFoundation\Request;
8use Wallabag\CoreBundle\Entity\Entry; 8use Wallabag\CoreBundle\Entity\Entry;
9use Wallabag\CoreBundle\Entity\Tag; 9use Wallabag\CoreBundle\Entity\Tag;
10 10
diff --git a/src/Wallabag/ApiBundle/Controller/UserRestController.php b/src/Wallabag/ApiBundle/Controller/UserRestController.php
index 7471f5f6..6f47cff0 100644
--- a/src/Wallabag/ApiBundle/Controller/UserRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/UserRestController.php
@@ -6,10 +6,10 @@ use FOS\UserBundle\Event\UserEvent;
6use FOS\UserBundle\FOSUserEvents; 6use FOS\UserBundle\FOSUserEvents;
7use JMS\Serializer\SerializationContext; 7use JMS\Serializer\SerializationContext;
8use Nelmio\ApiDocBundle\Annotation\ApiDoc; 8use Nelmio\ApiDocBundle\Annotation\ApiDoc;
9use Symfony\Component\HttpFoundation\Request;
10use Symfony\Component\HttpFoundation\JsonResponse; 9use Symfony\Component\HttpFoundation\JsonResponse;
11use Wallabag\UserBundle\Entity\User; 10use Symfony\Component\HttpFoundation\Request;
12use Wallabag\ApiBundle\Entity\Client; 11use Wallabag\ApiBundle\Entity\Client;
12use Wallabag\UserBundle\Entity\User;
13 13
14class UserRestController extends WallabagRestController 14class UserRestController extends WallabagRestController
15{ 15{
diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
index b1e08ca4..71da2a64 100644
--- a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php
@@ -40,8 +40,8 @@ class WallabagRestController extends FOSRestController
40 protected function validateUserAccess($requestUserId) 40 protected function validateUserAccess($requestUserId)
41 { 41 {
42 $user = $this->get('security.token_storage')->getToken()->getUser(); 42 $user = $this->get('security.token_storage')->getToken()->getUser();
43 if ($requestUserId != $user->getId()) { 43 if ($requestUserId !== $user->getId()) {
44 throw $this->createAccessDeniedException('Access forbidden. Entry user id: '.$requestUserId.', logged user id: '.$user->getId()); 44 throw $this->createAccessDeniedException('Access forbidden. Entry user id: ' . $requestUserId . ', logged user id: ' . $user->getId());
45 } 45 }
46 } 46 }
47} 47}
diff --git a/src/Wallabag/ApiBundle/Entity/Client.php b/src/Wallabag/ApiBundle/Entity/Client.php
index c15fd3fa..e6f98f98 100644
--- a/src/Wallabag/ApiBundle/Entity/Client.php
+++ b/src/Wallabag/ApiBundle/Entity/Client.php
@@ -4,10 +4,10 @@ namespace Wallabag\ApiBundle\Entity;
4 4
5use Doctrine\ORM\Mapping as ORM; 5use Doctrine\ORM\Mapping as ORM;
6use FOS\OAuthServerBundle\Entity\Client as BaseClient; 6use FOS\OAuthServerBundle\Entity\Client as BaseClient;
7use Wallabag\UserBundle\Entity\User;
8use JMS\Serializer\Annotation\Groups; 7use JMS\Serializer\Annotation\Groups;
9use JMS\Serializer\Annotation\SerializedName; 8use JMS\Serializer\Annotation\SerializedName;
10use JMS\Serializer\Annotation\VirtualProperty; 9use JMS\Serializer\Annotation\VirtualProperty;
10use Wallabag\UserBundle\Entity\User;
11 11
12/** 12/**
13 * @ORM\Table("oauth2_clients") 13 * @ORM\Table("oauth2_clients")
@@ -99,6 +99,6 @@ class Client extends BaseClient
99 */ 99 */
100 public function getClientId() 100 public function getClientId()
101 { 101 {
102 return $this->getId().'_'.$this->getRandomId(); 102 return $this->getId() . '_' . $this->getRandomId();
103 } 103 }
104} 104}
diff --git a/src/Wallabag/ApiBundle/Form/Type/ClientType.php b/src/Wallabag/ApiBundle/Form/Type/ClientType.php
index eaea4feb..fc22538f 100644
--- a/src/Wallabag/ApiBundle/Form/Type/ClientType.php
+++ b/src/Wallabag/ApiBundle/Form/Type/ClientType.php
@@ -5,8 +5,8 @@ namespace Wallabag\ApiBundle\Form\Type;
5use Symfony\Component\Form\AbstractType; 5use Symfony\Component\Form\AbstractType;
6use Symfony\Component\Form\CallbackTransformer; 6use Symfony\Component\Form\CallbackTransformer;
7use Symfony\Component\Form\Extension\Core\Type\SubmitType; 7use Symfony\Component\Form\Extension\Core\Type\SubmitType;
8use Symfony\Component\Form\Extension\Core\Type\UrlType;
9use Symfony\Component\Form\Extension\Core\Type\TextType; 8use Symfony\Component\Form\Extension\Core\Type\TextType;
9use Symfony\Component\Form\Extension\Core\Type\UrlType;
10use Symfony\Component\Form\FormBuilderInterface; 10use Symfony\Component\Form\FormBuilderInterface;
11use Symfony\Component\OptionsResolver\OptionsResolver; 11use Symfony\Component\OptionsResolver\OptionsResolver;
12 12
diff --git a/src/Wallabag/CoreBundle/Command/CleanDuplicatesCommand.php b/src/Wallabag/CoreBundle/Command/CleanDuplicatesCommand.php
index 74da1e5f..d964439d 100644
--- a/src/Wallabag/CoreBundle/Command/CleanDuplicatesCommand.php
+++ b/src/Wallabag/CoreBundle/Command/CleanDuplicatesCommand.php
@@ -76,7 +76,7 @@ class CleanDuplicatesCommand extends ContainerAwareCommand
76 $url = $this->similarUrl($entry['url']); 76 $url = $this->similarUrl($entry['url']);
77 77
78 /* @var $entry Entry */ 78 /* @var $entry Entry */
79 if (in_array($url, $urls)) { 79 if (in_array($url, $urls, true)) {
80 ++$duplicatesCount; 80 ++$duplicatesCount;
81 81
82 $em->remove($repo->find($entry['id'])); 82 $em->remove($repo->find($entry['id']));
@@ -93,7 +93,7 @@ class CleanDuplicatesCommand extends ContainerAwareCommand
93 93
94 private function similarUrl($url) 94 private function similarUrl($url)
95 { 95 {
96 if (in_array(substr($url, -1), ['/', '#'])) { // get rid of "/" and "#" and the end of urls 96 if (in_array(substr($url, -1), ['/', '#'], true)) { // get rid of "/" and "#" and the end of urls
97 return substr($url, 0, strlen($url)); 97 return substr($url, 0, strlen($url));
98 } 98 }
99 99
diff --git a/src/Wallabag/CoreBundle/Command/ExportCommand.php b/src/Wallabag/CoreBundle/Command/ExportCommand.php
index ebb2b4cf..0dacb734 100644
--- a/src/Wallabag/CoreBundle/Command/ExportCommand.php
+++ b/src/Wallabag/CoreBundle/Command/ExportCommand.php
@@ -49,7 +49,7 @@ class ExportCommand extends ContainerAwareCommand
49 $filePath = $input->getArgument('filepath'); 49 $filePath = $input->getArgument('filepath');
50 50
51 if (!$filePath) { 51 if (!$filePath) {
52 $filePath = $this->getContainer()->getParameter('kernel.root_dir').'/../'.sprintf('%s-export.json', $user->getUsername()); 52 $filePath = $this->getContainer()->getParameter('kernel.root_dir') . '/../' . sprintf('%s-export.json', $user->getUsername());
53 } 53 }
54 54
55 try { 55 try {
diff --git a/src/Wallabag/CoreBundle/Command/InstallCommand.php b/src/Wallabag/CoreBundle/Command/InstallCommand.php
index eb725a59..50551480 100644
--- a/src/Wallabag/CoreBundle/Command/InstallCommand.php
+++ b/src/Wallabag/CoreBundle/Command/InstallCommand.php
@@ -2,6 +2,7 @@
2 2
3namespace Wallabag\CoreBundle\Command; 3namespace Wallabag\CoreBundle\Command;
4 4
5use Craue\ConfigBundle\Entity\Setting;
5use FOS\UserBundle\Event\UserEvent; 6use FOS\UserBundle\Event\UserEvent;
6use FOS\UserBundle\FOSUserEvents; 7use FOS\UserBundle\FOSUserEvents;
7use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; 8use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
@@ -14,7 +15,6 @@ use Symfony\Component\Console\Output\OutputInterface;
14use Symfony\Component\Console\Question\ConfirmationQuestion; 15use Symfony\Component\Console\Question\ConfirmationQuestion;
15use Symfony\Component\Console\Question\Question; 16use Symfony\Component\Console\Question\Question;
16use Wallabag\CoreBundle\Entity\Config; 17use Wallabag\CoreBundle\Entity\Config;
17use Craue\ConfigBundle\Entity\Setting;
18 18
19class InstallCommand extends ContainerAwareCommand 19class InstallCommand extends ContainerAwareCommand
20{ 20{
@@ -86,7 +86,7 @@ class InstallCommand extends ContainerAwareCommand
86 if (!extension_loaded($this->getContainer()->getParameter('database_driver'))) { 86 if (!extension_loaded($this->getContainer()->getParameter('database_driver'))) {
87 $fulfilled = false; 87 $fulfilled = false;
88 $status = '<error>ERROR!</error>'; 88 $status = '<error>ERROR!</error>';
89 $help = 'Database driver "'.$this->getContainer()->getParameter('database_driver').'" is not installed.'; 89 $help = 'Database driver "' . $this->getContainer()->getParameter('database_driver') . '" is not installed.';
90 } 90 }
91 91
92 $rows[] = [sprintf($label, $this->getContainer()->getParameter('database_driver')), $status, $help]; 92 $rows[] = [sprintf($label, $this->getContainer()->getParameter('database_driver')), $status, $help];
@@ -101,10 +101,10 @@ class InstallCommand extends ContainerAwareCommand
101 $conn->connect(); 101 $conn->connect();
102 } catch (\Exception $e) { 102 } catch (\Exception $e) {
103 if (false === strpos($e->getMessage(), 'Unknown database') 103 if (false === strpos($e->getMessage(), 'Unknown database')
104 && false === strpos($e->getMessage(), 'database "'.$this->getContainer()->getParameter('database_name').'" does not exist')) { 104 && false === strpos($e->getMessage(), 'database "' . $this->getContainer()->getParameter('database_name') . '" does not exist')) {
105 $fulfilled = false; 105 $fulfilled = false;
106 $status = '<error>ERROR!</error>'; 106 $status = '<error>ERROR!</error>';
107 $help = 'Can\'t connect to the database: '.$e->getMessage(); 107 $help = 'Can\'t connect to the database: ' . $e->getMessage();
108 } 108 }
109 } 109 }
110 110
@@ -123,7 +123,7 @@ class InstallCommand extends ContainerAwareCommand
123 if (false === version_compare($version, $minimalVersion, '>')) { 123 if (false === version_compare($version, $minimalVersion, '>')) {
124 $fulfilled = false; 124 $fulfilled = false;
125 $status = '<error>ERROR!</error>'; 125 $status = '<error>ERROR!</error>';
126 $help = 'Your MySQL version ('.$version.') is too old, consider upgrading ('.$minimalVersion.'+).'; 126 $help = 'Your MySQL version (' . $version . ') is too old, consider upgrading (' . $minimalVersion . '+).';
127 } 127 }
128 } 128 }
129 129
@@ -137,21 +137,21 @@ class InstallCommand extends ContainerAwareCommand
137 if (isset($matches[1]) & version_compare($matches[1], '9.2.0', '<')) { 137 if (isset($matches[1]) & version_compare($matches[1], '9.2.0', '<')) {
138 $fulfilled = false; 138 $fulfilled = false;
139 $status = '<error>ERROR!</error>'; 139 $status = '<error>ERROR!</error>';
140 $help = 'PostgreSQL should be greater than 9.1 (actual version: '.$matches[1].')'; 140 $help = 'PostgreSQL should be greater than 9.1 (actual version: ' . $matches[1] . ')';
141 } 141 }
142 } 142 }
143 143
144 $rows[] = [$label, $status, $help]; 144 $rows[] = [$label, $status, $help];
145 145
146 foreach ($this->functionExists as $functionRequired) { 146 foreach ($this->functionExists as $functionRequired) {
147 $label = '<comment>'.$functionRequired.'</comment>'; 147 $label = '<comment>' . $functionRequired . '</comment>';
148 $status = '<info>OK!</info>'; 148 $status = '<info>OK!</info>';
149 $help = ''; 149 $help = '';
150 150
151 if (!function_exists($functionRequired)) { 151 if (!function_exists($functionRequired)) {
152 $fulfilled = false; 152 $fulfilled = false;
153 $status = '<error>ERROR!</error>'; 153 $status = '<error>ERROR!</error>';
154 $help = 'You need the '.$functionRequired.' function activated'; 154 $help = 'You need the ' . $functionRequired . ' function activated';
155 } 155 }
156 156
157 $rows[] = [$label, $status, $help]; 157 $rows[] = [$label, $status, $help];
@@ -351,8 +351,8 @@ class InstallCommand extends ContainerAwareCommand
351 $this->getApplication()->setAutoExit(true); 351 $this->getApplication()->setAutoExit(true);
352 352
353 throw new \RuntimeException( 353 throw new \RuntimeException(
354 'The command "'.$command."\" generates some errors: \n\n" 354 'The command "' . $command . "\" generates some errors: \n\n"
355 .$output->fetch()); 355 . $output->fetch());
356 } 356 }
357 357
358 return $this; 358 return $this;
@@ -396,7 +396,7 @@ class InstallCommand extends ContainerAwareCommand
396 } 396 }
397 397
398 try { 398 try {
399 return in_array($databaseName, $schemaManager->listDatabases()); 399 return in_array($databaseName, $schemaManager->listDatabases(), true);
400 } catch (\Doctrine\DBAL\Exception\DriverException $e) { 400 } catch (\Doctrine\DBAL\Exception\DriverException $e) {
401 // it means we weren't able to get database list, assume the database doesn't exist 401 // it means we weren't able to get database list, assume the database doesn't exist
402 402
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php
index d4170d39..7e39992d 100644
--- a/src/Wallabag/CoreBundle/Controller/ConfigController.php
+++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php
@@ -10,8 +10,8 @@ use Symfony\Component\HttpFoundation\Request;
10use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; 10use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
11use Wallabag\CoreBundle\Entity\Config; 11use Wallabag\CoreBundle\Entity\Config;
12use Wallabag\CoreBundle\Entity\TaggingRule; 12use Wallabag\CoreBundle\Entity\TaggingRule;
13use Wallabag\CoreBundle\Form\Type\ConfigType;
14use Wallabag\CoreBundle\Form\Type\ChangePasswordType; 13use Wallabag\CoreBundle\Form\Type\ChangePasswordType;
14use Wallabag\CoreBundle\Form\Type\ConfigType;
15use Wallabag\CoreBundle\Form\Type\RssType; 15use Wallabag\CoreBundle\Form\Type\RssType;
16use Wallabag\CoreBundle\Form\Type\TaggingRuleType; 16use Wallabag\CoreBundle\Form\Type\TaggingRuleType;
17use Wallabag\CoreBundle\Form\Type\UserInformationType; 17use Wallabag\CoreBundle\Form\Type\UserInformationType;
@@ -54,7 +54,7 @@ class ConfigController extends Controller
54 } 54 }
55 55
56 // handle changing password 56 // handle changing password
57 $pwdForm = $this->createForm(ChangePasswordType::class, null, ['action' => $this->generateUrl('config').'#set4']); 57 $pwdForm = $this->createForm(ChangePasswordType::class, null, ['action' => $this->generateUrl('config') . '#set4']);
58 $pwdForm->handleRequest($request); 58 $pwdForm->handleRequest($request);
59 59
60 if ($pwdForm->isSubmitted() && $pwdForm->isValid()) { 60 if ($pwdForm->isSubmitted() && $pwdForm->isValid()) {
@@ -69,13 +69,13 @@ class ConfigController extends Controller
69 69
70 $this->get('session')->getFlashBag()->add('notice', $message); 70 $this->get('session')->getFlashBag()->add('notice', $message);
71 71
72 return $this->redirect($this->generateUrl('config').'#set4'); 72 return $this->redirect($this->generateUrl('config') . '#set4');
73 } 73 }
74 74
75 // handle changing user information 75 // handle changing user information
76 $userForm = $this->createForm(UserInformationType::class, $user, [ 76 $userForm = $this->createForm(UserInformationType::class, $user, [
77 'validation_groups' => ['Profile'], 77 'validation_groups' => ['Profile'],
78 'action' => $this->generateUrl('config').'#set3', 78 'action' => $this->generateUrl('config') . '#set3',
79 ]); 79 ]);
80 $userForm->handleRequest($request); 80 $userForm->handleRequest($request);
81 81
@@ -87,11 +87,11 @@ class ConfigController extends Controller
87 'flashes.config.notice.user_updated' 87 'flashes.config.notice.user_updated'
88 ); 88 );
89 89
90 return $this->redirect($this->generateUrl('config').'#set3'); 90 return $this->redirect($this->generateUrl('config') . '#set3');
91 } 91 }
92 92
93 // handle rss information 93 // handle rss information
94 $rssForm = $this->createForm(RssType::class, $config, ['action' => $this->generateUrl('config').'#set2']); 94 $rssForm = $this->createForm(RssType::class, $config, ['action' => $this->generateUrl('config') . '#set2']);
95 $rssForm->handleRequest($request); 95 $rssForm->handleRequest($request);
96 96
97 if ($rssForm->isSubmitted() && $rssForm->isValid()) { 97 if ($rssForm->isSubmitted() && $rssForm->isValid()) {
@@ -103,12 +103,12 @@ class ConfigController extends Controller
103 'flashes.config.notice.rss_updated' 103 'flashes.config.notice.rss_updated'
104 ); 104 );
105 105
106 return $this->redirect($this->generateUrl('config').'#set2'); 106 return $this->redirect($this->generateUrl('config') . '#set2');
107 } 107 }
108 108
109 // handle tagging rule 109 // handle tagging rule
110 $taggingRule = new TaggingRule(); 110 $taggingRule = new TaggingRule();
111 $action = $this->generateUrl('config').'#set5'; 111 $action = $this->generateUrl('config') . '#set5';
112 112
113 if ($request->query->has('tagging-rule')) { 113 if ($request->query->has('tagging-rule')) {
114 $taggingRule = $this->getDoctrine() 114 $taggingRule = $this->getDoctrine()
@@ -119,7 +119,7 @@ class ConfigController extends Controller
119 return $this->redirect($action); 119 return $this->redirect($action);
120 } 120 }
121 121
122 $action = $this->generateUrl('config').'?tagging-rule='.$taggingRule->getId().'#set5'; 122 $action = $this->generateUrl('config') . '?tagging-rule=' . $taggingRule->getId() . '#set5';
123 } 123 }
124 124
125 $newTaggingRule = $this->createForm(TaggingRuleType::class, $taggingRule, ['action' => $action]); 125 $newTaggingRule = $this->createForm(TaggingRuleType::class, $taggingRule, ['action' => $action]);
@@ -135,7 +135,7 @@ class ConfigController extends Controller
135 'flashes.config.notice.tagging_rules_updated' 135 'flashes.config.notice.tagging_rules_updated'
136 ); 136 );
137 137
138 return $this->redirect($this->generateUrl('config').'#set5'); 138 return $this->redirect($this->generateUrl('config') . '#set5');
139 } 139 }
140 140
141 return $this->render('WallabagCoreBundle:Config:index.html.twig', [ 141 return $this->render('WallabagCoreBundle:Config:index.html.twig', [
@@ -182,7 +182,7 @@ class ConfigController extends Controller
182 'flashes.config.notice.rss_token_updated' 182 'flashes.config.notice.rss_token_updated'
183 ); 183 );
184 184
185 return $this->redirect($this->generateUrl('config').'#set2'); 185 return $this->redirect($this->generateUrl('config') . '#set2');
186 } 186 }
187 187
188 /** 188 /**
@@ -207,7 +207,7 @@ class ConfigController extends Controller
207 'flashes.config.notice.tagging_rules_deleted' 207 'flashes.config.notice.tagging_rules_deleted'
208 ); 208 );
209 209
210 return $this->redirect($this->generateUrl('config').'#set5'); 210 return $this->redirect($this->generateUrl('config') . '#set5');
211 } 211 }
212 212
213 /** 213 /**
@@ -223,7 +223,7 @@ class ConfigController extends Controller
223 { 223 {
224 $this->validateRuleAction($rule); 224 $this->validateRuleAction($rule);
225 225
226 return $this->redirect($this->generateUrl('config').'?tagging-rule='.$rule->getId().'#set5'); 226 return $this->redirect($this->generateUrl('config') . '?tagging-rule=' . $rule->getId() . '#set5');
227 } 227 }
228 228
229 /** 229 /**
@@ -241,11 +241,9 @@ class ConfigController extends Controller
241 ->getRepository('WallabagAnnotationBundle:Annotation') 241 ->getRepository('WallabagAnnotationBundle:Annotation')
242 ->removeAllByUserId($this->getUser()->getId()); 242 ->removeAllByUserId($this->getUser()->getId());
243 break; 243 break;
244
245 case 'tags': 244 case 'tags':
246 $this->removeAllTagsByUserId($this->getUser()->getId()); 245 $this->removeAllTagsByUserId($this->getUser()->getId());
247 break; 246 break;
248
249 case 'entries': 247 case 'entries':
250 // SQLite doesn't care about cascading remove, so we need to manually remove associated stuff 248 // SQLite doesn't care about cascading remove, so we need to manually remove associated stuff
251 // otherwise they won't be removed ... 249 // otherwise they won't be removed ...
@@ -272,10 +270,63 @@ class ConfigController extends Controller
272 270
273 $this->get('session')->getFlashBag()->add( 271 $this->get('session')->getFlashBag()->add(
274 'notice', 272 'notice',
275 'flashes.config.notice.'.$type.'_reset' 273 'flashes.config.notice.' . $type . '_reset'
276 ); 274 );
277 275
278 return $this->redirect($this->generateUrl('config').'#set3'); 276 return $this->redirect($this->generateUrl('config') . '#set3');
277 }
278
279 /**
280 * Delete account for current user.
281 *
282 * @Route("/account/delete", name="delete_account")
283 *
284 * @param Request $request
285 *
286 * @throws AccessDeniedHttpException
287 *
288 * @return \Symfony\Component\HttpFoundation\RedirectResponse
289 */
290 public function deleteAccountAction(Request $request)
291 {
292 $enabledUsers = $this->get('wallabag_user.user_repository')
293 ->getSumEnabledUsers();
294
295 if ($enabledUsers <= 1) {
296 throw new AccessDeniedHttpException();
297 }
298
299 $user = $this->getUser();
300
301 // logout current user
302 $this->get('security.token_storage')->setToken(null);
303 $request->getSession()->invalidate();
304
305 $em = $this->get('fos_user.user_manager');
306 $em->deleteUser($user);
307
308 return $this->redirect($this->generateUrl('fos_user_security_login'));
309 }
310
311 /**
312 * Switch view mode for current user.
313 *
314 * @Route("/config/view-mode", name="switch_view_mode")
315 *
316 * @param Request $request
317 *
318 * @return \Symfony\Component\HttpFoundation\RedirectResponse
319 */
320 public function changeViewModeAction(Request $request)
321 {
322 $user = $this->getUser();
323 $user->getConfig()->setListMode(!$user->getConfig()->getListMode());
324
325 $em = $this->getDoctrine()->getManager();
326 $em->persist($user);
327 $em->flush();
328
329 return $this->redirect($request->headers->get('referer'));
279 } 330 }
280 331
281 /** 332 /**
@@ -349,7 +400,7 @@ class ConfigController extends Controller
349 */ 400 */
350 private function validateRuleAction(TaggingRule $rule) 401 private function validateRuleAction(TaggingRule $rule)
351 { 402 {
352 if ($this->getUser()->getId() != $rule->getConfig()->getUser()->getId()) { 403 if ($this->getUser()->getId() !== $rule->getConfig()->getUser()->getId()) {
353 throw $this->createAccessDeniedException('You can not access this tagging rule.'); 404 throw $this->createAccessDeniedException('You can not access this tagging rule.');
354 } 405 }
355 } 406 }
@@ -373,57 +424,4 @@ class ConfigController extends Controller
373 424
374 return $config; 425 return $config;
375 } 426 }
376
377 /**
378 * Delete account for current user.
379 *
380 * @Route("/account/delete", name="delete_account")
381 *
382 * @param Request $request
383 *
384 * @throws AccessDeniedHttpException
385 *
386 * @return \Symfony\Component\HttpFoundation\RedirectResponse
387 */
388 public function deleteAccountAction(Request $request)
389 {
390 $enabledUsers = $this->get('wallabag_user.user_repository')
391 ->getSumEnabledUsers();
392
393 if ($enabledUsers <= 1) {
394 throw new AccessDeniedHttpException();
395 }
396
397 $user = $this->getUser();
398
399 // logout current user
400 $this->get('security.token_storage')->setToken(null);
401 $request->getSession()->invalidate();
402
403 $em = $this->get('fos_user.user_manager');
404 $em->deleteUser($user);
405
406 return $this->redirect($this->generateUrl('fos_user_security_login'));
407 }
408
409 /**
410 * Switch view mode for current user.
411 *
412 * @Route("/config/view-mode", name="switch_view_mode")
413 *
414 * @param Request $request
415 *
416 * @return \Symfony\Component\HttpFoundation\RedirectResponse
417 */
418 public function changeViewModeAction(Request $request)
419 {
420 $user = $this->getUser();
421 $user->getConfig()->setListMode(!$user->getConfig()->getListMode());
422
423 $em = $this->getDoctrine()->getManager();
424 $em->persist($user);
425 $em->flush();
426
427 return $this->redirect($request->headers->get('referer'));
428 }
429} 427}
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php
index fafa49f1..445cfeeb 100644
--- a/src/Wallabag/CoreBundle/Controller/EntryController.php
+++ b/src/Wallabag/CoreBundle/Controller/EntryController.php
@@ -4,17 +4,17 @@ namespace Wallabag\CoreBundle\Controller;
4 4
5use Pagerfanta\Adapter\DoctrineORMAdapter; 5use Pagerfanta\Adapter\DoctrineORMAdapter;
6use Pagerfanta\Exception\OutOfRangeCurrentPageException; 6use Pagerfanta\Exception\OutOfRangeCurrentPageException;
7use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
7use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 8use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
8use Symfony\Bundle\FrameworkBundle\Controller\Controller; 9use Symfony\Bundle\FrameworkBundle\Controller\Controller;
9use Symfony\Component\HttpFoundation\Request; 10use Symfony\Component\HttpFoundation\Request;
10use Symfony\Component\Routing\Generator\UrlGeneratorInterface; 11use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
11use Wallabag\CoreBundle\Entity\Entry; 12use Wallabag\CoreBundle\Entity\Entry;
12use Wallabag\CoreBundle\Form\Type\EntryFilterType; 13use Wallabag\CoreBundle\Event\EntryDeletedEvent;
14use Wallabag\CoreBundle\Event\EntrySavedEvent;
13use Wallabag\CoreBundle\Form\Type\EditEntryType; 15use Wallabag\CoreBundle\Form\Type\EditEntryType;
16use Wallabag\CoreBundle\Form\Type\EntryFilterType;
14use Wallabag\CoreBundle\Form\Type\NewEntryType; 17use Wallabag\CoreBundle\Form\Type\NewEntryType;
15use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
16use Wallabag\CoreBundle\Event\EntrySavedEvent;
17use Wallabag\CoreBundle\Event\EntryDeletedEvent;
18use Wallabag\CoreBundle\Form\Type\SearchEntryType; 18use Wallabag\CoreBundle\Form\Type\SearchEntryType;
19 19
20class EntryController extends Controller 20class EntryController extends Controller
@@ -52,31 +52,6 @@ class EntryController extends Controller
52 } 52 }
53 53
54 /** 54 /**
55 * Fetch content and update entry.
56 * In case it fails, $entry->getContent will return an error message.
57 *
58 * @param Entry $entry
59 * @param string $prefixMessage Should be the translation key: entry_saved or entry_reloaded
60 */
61 private function updateEntry(Entry $entry, $prefixMessage = 'entry_saved')
62 {
63 $message = 'flashes.entry.notice.'.$prefixMessage;
64
65 try {
66 $this->get('wallabag_core.content_proxy')->updateEntry($entry, $entry->getUrl());
67 } catch (\Exception $e) {
68 $this->get('logger')->error('Error while saving an entry', [
69 'exception' => $e,
70 'entry' => $entry,
71 ]);
72
73 $message = 'flashes.entry.notice.'.$prefixMessage.'_failed';
74 }
75
76 $this->get('session')->getFlashBag()->add('notice', $message);
77 }
78
79 /**
80 * @param Request $request 55 * @param Request $request
81 * 56 *
82 * @Route("/new-entry", name="new_entry") 57 * @Route("/new-entry", name="new_entry")
@@ -220,7 +195,7 @@ class EntryController extends Controller
220 public function showUnreadAction(Request $request, $page) 195 public function showUnreadAction(Request $request, $page)
221 { 196 {
222 // load the quickstart if no entry in database 197 // load the quickstart if no entry in database
223 if ($page == 1 && $this->get('wallabag_core.entry_repository')->countAllEntriesByUser($this->getUser()->getId()) == 0) { 198 if ($page === 1 && $this->get('wallabag_core.entry_repository')->countAllEntriesByUser($this->getUser()->getId()) === 0) {
224 return $this->redirect($this->generateUrl('quickstart')); 199 return $this->redirect($this->generateUrl('quickstart'));
225 } 200 }
226 201
@@ -258,83 +233,6 @@ class EntryController extends Controller
258 } 233 }
259 234
260 /** 235 /**
261 * Global method to retrieve entries depending on the given type
262 * It returns the response to be send.
263 *
264 * @param string $type Entries type: unread, starred or archive
265 * @param Request $request
266 * @param int $page
267 *
268 * @return \Symfony\Component\HttpFoundation\Response
269 */
270 private function showEntries($type, Request $request, $page)
271 {
272 $repository = $this->get('wallabag_core.entry_repository');
273 $searchTerm = (isset($request->get('search_entry')['term']) ? $request->get('search_entry')['term'] : '');
274 $currentRoute = (!is_null($request->query->get('currentRoute')) ? $request->query->get('currentRoute') : '');
275
276 switch ($type) {
277 case 'search':
278 $qb = $repository->getBuilderForSearchByUser($this->getUser()->getId(), $searchTerm, $currentRoute);
279
280 break;
281 case 'untagged':
282 $qb = $repository->getBuilderForUntaggedByUser($this->getUser()->getId());
283
284 break;
285 case 'starred':
286 $qb = $repository->getBuilderForStarredByUser($this->getUser()->getId());
287 break;
288
289 case 'archive':
290 $qb = $repository->getBuilderForArchiveByUser($this->getUser()->getId());
291 break;
292
293 case 'unread':
294 $qb = $repository->getBuilderForUnreadByUser($this->getUser()->getId());
295 break;
296
297 case 'all':
298 $qb = $repository->getBuilderForAllByUser($this->getUser()->getId());
299 break;
300
301 default:
302 throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type));
303 }
304
305 $form = $this->createForm(EntryFilterType::class);
306
307 if ($request->query->has($form->getName())) {
308 // manually bind values from the request
309 $form->submit($request->query->get($form->getName()));
310
311 // build the query from the given form object
312 $this->get('lexik_form_filter.query_builder_updater')->addFilterConditions($form, $qb);
313 }
314
315 $pagerAdapter = new DoctrineORMAdapter($qb->getQuery(), true, false);
316
317 $entries = $this->get('wallabag_core.helper.prepare_pager_for_entries')->prepare($pagerAdapter);
318
319 try {
320 $entries->setCurrentPage($page);
321 } catch (OutOfRangeCurrentPageException $e) {
322 if ($page > 1) {
323 return $this->redirect($this->generateUrl($type, ['page' => $entries->getNbPages()]), 302);
324 }
325 }
326
327 return $this->render(
328 'WallabagCoreBundle:Entry:entries.html.twig', [
329 'form' => $form->createView(),
330 'entries' => $entries,
331 'currentPage' => $page,
332 'searchTerm' => $searchTerm,
333 ]
334 );
335 }
336
337 /**
338 * Shows entry content. 236 * Shows entry content.
339 * 237 *
340 * @param Entry $entry 238 * @param Entry $entry
@@ -487,7 +385,7 @@ class EntryController extends Controller
487 385
488 // don't redirect user to the deleted entry (check that the referer doesn't end with the same url) 386 // don't redirect user to the deleted entry (check that the referer doesn't end with the same url)
489 $referer = $request->headers->get('referer'); 387 $referer = $request->headers->get('referer');
490 $to = (1 !== preg_match('#'.$url.'$#i', $referer) ? $referer : null); 388 $to = (1 !== preg_match('#' . $url . '$#i', $referer) ? $referer : null);
491 389
492 $redirectUrl = $this->get('wallabag_core.helper.redirect')->to($to); 390 $redirectUrl = $this->get('wallabag_core.helper.redirect')->to($to);
493 391
@@ -495,30 +393,6 @@ class EntryController extends Controller
495 } 393 }
496 394
497 /** 395 /**
498 * Check if the logged user can manage the given entry.
499 *
500 * @param Entry $entry
501 */
502 private function checkUserAction(Entry $entry)
503 {
504 if (null === $this->getUser() || $this->getUser()->getId() != $entry->getUser()->getId()) {
505 throw $this->createAccessDeniedException('You can not access this entry.');
506 }
507 }
508
509 /**
510 * Check for existing entry, if it exists, redirect to it with a message.
511 *
512 * @param Entry $entry
513 *
514 * @return Entry|bool
515 */
516 private function checkIfEntryAlreadyExists(Entry $entry)
517 {
518 return $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($entry->getUrl(), $this->getUser()->getId());
519 }
520
521 /**
522 * Get public URL for entry (and generate it if necessary). 396 * Get public URL for entry (and generate it if necessary).
523 * 397 *
524 * @param Entry $entry 398 * @param Entry $entry
@@ -604,4 +478,126 @@ class EntryController extends Controller
604 { 478 {
605 return $this->showEntries('untagged', $request, $page); 479 return $this->showEntries('untagged', $request, $page);
606 } 480 }
481
482 /**
483 * Fetch content and update entry.
484 * In case it fails, $entry->getContent will return an error message.
485 *
486 * @param Entry $entry
487 * @param string $prefixMessage Should be the translation key: entry_saved or entry_reloaded
488 */
489 private function updateEntry(Entry $entry, $prefixMessage = 'entry_saved')
490 {
491 $message = 'flashes.entry.notice.' . $prefixMessage;
492
493 try {
494 $this->get('wallabag_core.content_proxy')->updateEntry($entry, $entry->getUrl());
495 } catch (\Exception $e) {
496 $this->get('logger')->error('Error while saving an entry', [
497 'exception' => $e,
498 'entry' => $entry,
499 ]);
500
501 $message = 'flashes.entry.notice.' . $prefixMessage . '_failed';
502 }
503
504 $this->get('session')->getFlashBag()->add('notice', $message);
505 }
506
507 /**
508 * Global method to retrieve entries depending on the given type
509 * It returns the response to be send.
510 *
511 * @param string $type Entries type: unread, starred or archive
512 * @param Request $request
513 * @param int $page
514 *
515 * @return \Symfony\Component\HttpFoundation\Response
516 */
517 private function showEntries($type, Request $request, $page)
518 {
519 $repository = $this->get('wallabag_core.entry_repository');
520 $searchTerm = (isset($request->get('search_entry')['term']) ? $request->get('search_entry')['term'] : '');
521 $currentRoute = (null !== $request->query->get('currentRoute') ? $request->query->get('currentRoute') : '');
522
523 switch ($type) {
524 case 'search':
525 $qb = $repository->getBuilderForSearchByUser($this->getUser()->getId(), $searchTerm, $currentRoute);
526
527 break;
528 case 'untagged':
529 $qb = $repository->getBuilderForUntaggedByUser($this->getUser()->getId());
530
531 break;
532 case 'starred':
533 $qb = $repository->getBuilderForStarredByUser($this->getUser()->getId());
534 break;
535 case 'archive':
536 $qb = $repository->getBuilderForArchiveByUser($this->getUser()->getId());
537 break;
538 case 'unread':
539 $qb = $repository->getBuilderForUnreadByUser($this->getUser()->getId());
540 break;
541 case 'all':
542 $qb = $repository->getBuilderForAllByUser($this->getUser()->getId());
543 break;
544 default:
545 throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type));
546 }
547
548 $form = $this->createForm(EntryFilterType::class);
549
550 if ($request->query->has($form->getName())) {
551 // manually bind values from the request
552 $form->submit($request->query->get($form->getName()));
553
554 // build the query from the given form object
555 $this->get('lexik_form_filter.query_builder_updater')->addFilterConditions($form, $qb);
556 }
557
558 $pagerAdapter = new DoctrineORMAdapter($qb->getQuery(), true, false);
559
560 $entries = $this->get('wallabag_core.helper.prepare_pager_for_entries')->prepare($pagerAdapter);
561
562 try {
563 $entries->setCurrentPage($page);
564 } catch (OutOfRangeCurrentPageException $e) {
565 if ($page > 1) {
566 return $this->redirect($this->generateUrl($type, ['page' => $entries->getNbPages()]), 302);
567 }
568 }
569
570 return $this->render(
571 'WallabagCoreBundle:Entry:entries.html.twig', [
572 'form' => $form->createView(),
573 'entries' => $entries,
574 'currentPage' => $page,
575 'searchTerm' => $searchTerm,
576 ]
577 );
578 }
579
580 /**
581 * Check if the logged user can manage the given entry.
582 *
583 * @param Entry $entry
584 */
585 private function checkUserAction(Entry $entry)
586 {
587 if (null === $this->getUser() || $this->getUser()->getId() !== $entry->getUser()->getId()) {
588 throw $this->createAccessDeniedException('You can not access this entry.');
589 }
590 }
591
592 /**
593 * Check for existing entry, if it exists, redirect to it with a message.
594 *
595 * @param Entry $entry
596 *
597 * @return Entry|bool
598 */
599 private function checkIfEntryAlreadyExists(Entry $entry)
600 {
601 return $this->get('wallabag_core.entry_repository')->findByUrlAndUserId($entry->getUrl(), $this->getUser()->getId());
602 }
607} 603}
diff --git a/src/Wallabag/CoreBundle/Controller/ExceptionController.php b/src/Wallabag/CoreBundle/Controller/ExceptionController.php
index abfa9c2f..461309ea 100644
--- a/src/Wallabag/CoreBundle/Controller/ExceptionController.php
+++ b/src/Wallabag/CoreBundle/Controller/ExceptionController.php
@@ -14,7 +14,7 @@ class ExceptionController extends BaseExceptionController
14 protected function findTemplate(Request $request, $format, $code, $showException) 14 protected function findTemplate(Request $request, $format, $code, $showException)
15 { 15 {
16 $name = $showException ? 'exception' : 'error'; 16 $name = $showException ? 'exception' : 'error';
17 if ($showException && 'html' == $format) { 17 if ($showException && 'html' === $format) {
18 $name = 'exception_full'; 18 $name = 'exception_full';
19 } 19 }
20 20
diff --git a/src/Wallabag/CoreBundle/Controller/ExportController.php b/src/Wallabag/CoreBundle/Controller/ExportController.php
index fda04cfb..6fad122e 100644
--- a/src/Wallabag/CoreBundle/Controller/ExportController.php
+++ b/src/Wallabag/CoreBundle/Controller/ExportController.php
@@ -55,10 +55,10 @@ class ExportController extends Controller
55 public function downloadEntriesAction(Request $request, $format, $category) 55 public function downloadEntriesAction(Request $request, $format, $category)
56 { 56 {
57 $method = ucfirst($category); 57 $method = ucfirst($category);
58 $methodBuilder = 'getBuilderFor'.$method.'ByUser'; 58 $methodBuilder = 'getBuilderFor' . $method . 'ByUser';
59 $repository = $this->get('wallabag_core.entry_repository'); 59 $repository = $this->get('wallabag_core.entry_repository');
60 60
61 if ($category == 'tag_entries') { 61 if ($category === 'tag_entries') {
62 $tag = $this->get('wallabag_core.tag_repository')->findOneBySlug($request->query->get('tag')); 62 $tag = $this->get('wallabag_core.tag_repository')->findOneBySlug($request->query->get('tag'));
63 63
64 $entries = $repository->findAllByTagId( 64 $entries = $repository->findAllByTagId(
diff --git a/src/Wallabag/CoreBundle/Controller/RssController.php b/src/Wallabag/CoreBundle/Controller/RssController.php
index e87dd9a1..e84044b1 100644
--- a/src/Wallabag/CoreBundle/Controller/RssController.php
+++ b/src/Wallabag/CoreBundle/Controller/RssController.php
@@ -2,19 +2,19 @@
2 2
3namespace Wallabag\CoreBundle\Controller; 3namespace Wallabag\CoreBundle\Controller;
4 4
5use Pagerfanta\Adapter\DoctrineORMAdapter;
6use Pagerfanta\Adapter\ArrayAdapter; 5use Pagerfanta\Adapter\ArrayAdapter;
6use Pagerfanta\Adapter\DoctrineORMAdapter;
7use Pagerfanta\Exception\OutOfRangeCurrentPageException; 7use Pagerfanta\Exception\OutOfRangeCurrentPageException;
8use Pagerfanta\Pagerfanta; 8use Pagerfanta\Pagerfanta;
9use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; 9use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
10use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 10use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
11use Symfony\Bundle\FrameworkBundle\Controller\Controller;
11use Symfony\Component\HttpFoundation\Request; 12use Symfony\Component\HttpFoundation\Request;
12use Symfony\Component\HttpFoundation\Response; 13use Symfony\Component\HttpFoundation\Response;
13use Symfony\Bundle\FrameworkBundle\Controller\Controller; 14use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
14use Wallabag\CoreBundle\Entity\Entry; 15use Wallabag\CoreBundle\Entity\Entry;
15use Wallabag\CoreBundle\Entity\Tag; 16use Wallabag\CoreBundle\Entity\Tag;
16use Wallabag\UserBundle\Entity\User; 17use Wallabag\UserBundle\Entity\User;
17use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
18 18
19class RssController extends Controller 19class RssController extends Controller
20{ 20{
@@ -113,7 +113,7 @@ class RssController extends Controller
113 $entries->setCurrentPage($page); 113 $entries->setCurrentPage($page);
114 } catch (OutOfRangeCurrentPageException $e) { 114 } catch (OutOfRangeCurrentPageException $e) {
115 if ($page > 1) { 115 if ($page > 1) {
116 return $this->redirect($url.'?page='.$entries->getNbPages(), 302); 116 return $this->redirect($url . '?page=' . $entries->getNbPages(), 302);
117 } 117 }
118 } 118 }
119 119
@@ -121,7 +121,7 @@ class RssController extends Controller
121 '@WallabagCore/themes/common/Entry/entries.xml.twig', 121 '@WallabagCore/themes/common/Entry/entries.xml.twig',
122 [ 122 [
123 'url_html' => $this->generateUrl('tag_entries', ['slug' => $tag->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL), 123 'url_html' => $this->generateUrl('tag_entries', ['slug' => $tag->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL),
124 'type' => 'tag ('.$tag->getLabel().')', 124 'type' => 'tag (' . $tag->getLabel() . ')',
125 'url' => $url, 125 'url' => $url,
126 'entries' => $entries, 126 'entries' => $entries,
127 ], 127 ],
@@ -147,19 +147,15 @@ class RssController extends Controller
147 case 'starred': 147 case 'starred':
148 $qb = $repository->getBuilderForStarredByUser($user->getId()); 148 $qb = $repository->getBuilderForStarredByUser($user->getId());
149 break; 149 break;
150
151 case 'archive': 150 case 'archive':
152 $qb = $repository->getBuilderForArchiveByUser($user->getId()); 151 $qb = $repository->getBuilderForArchiveByUser($user->getId());
153 break; 152 break;
154
155 case 'unread': 153 case 'unread':
156 $qb = $repository->getBuilderForUnreadByUser($user->getId()); 154 $qb = $repository->getBuilderForUnreadByUser($user->getId());
157 break; 155 break;
158
159 case 'all': 156 case 'all':
160 $qb = $repository->getBuilderForAllByUser($user->getId()); 157 $qb = $repository->getBuilderForAllByUser($user->getId());
161 break; 158 break;
162
163 default: 159 default:
164 throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type)); 160 throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type));
165 } 161 }
@@ -171,7 +167,7 @@ class RssController extends Controller
171 $entries->setMaxPerPage($perPage); 167 $entries->setMaxPerPage($perPage);
172 168
173 $url = $this->generateUrl( 169 $url = $this->generateUrl(
174 $type.'_rss', 170 $type . '_rss',
175 [ 171 [
176 'username' => $user->getUsername(), 172 'username' => $user->getUsername(),
177 'token' => $user->getConfig()->getRssToken(), 173 'token' => $user->getConfig()->getRssToken(),
@@ -183,7 +179,7 @@ class RssController extends Controller
183 $entries->setCurrentPage((int) $page); 179 $entries->setCurrentPage((int) $page);
184 } catch (OutOfRangeCurrentPageException $e) { 180 } catch (OutOfRangeCurrentPageException $e) {
185 if ($page > 1) { 181 if ($page > 1) {
186 return $this->redirect($url.'?page='.$entries->getNbPages(), 302); 182 return $this->redirect($url . '?page=' . $entries->getNbPages(), 302);
187 } 183 }
188 } 184 }
189 185
diff --git a/src/Wallabag/CoreBundle/Controller/SiteCredentialController.php b/src/Wallabag/CoreBundle/Controller/SiteCredentialController.php
index 98781dab..fa2066dc 100644
--- a/src/Wallabag/CoreBundle/Controller/SiteCredentialController.php
+++ b/src/Wallabag/CoreBundle/Controller/SiteCredentialController.php
@@ -2,12 +2,12 @@
2 2
3namespace Wallabag\CoreBundle\Controller; 3namespace Wallabag\CoreBundle\Controller;
4 4
5use Symfony\Component\HttpFoundation\Request;
6use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; 5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
8use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 6use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
9use Wallabag\UserBundle\Entity\User; 7use Symfony\Bundle\FrameworkBundle\Controller\Controller;
8use Symfony\Component\HttpFoundation\Request;
10use Wallabag\CoreBundle\Entity\SiteCredential; 9use Wallabag\CoreBundle\Entity\SiteCredential;
10use Wallabag\UserBundle\Entity\User;
11 11
12/** 12/**
13 * SiteCredential controller. 13 * SiteCredential controller.
@@ -167,7 +167,7 @@ class SiteCredentialController extends Controller
167 */ 167 */
168 private function checkUserAction(SiteCredential $siteCredential) 168 private function checkUserAction(SiteCredential $siteCredential)
169 { 169 {
170 if (null === $this->getUser() || $this->getUser()->getId() != $siteCredential->getUser()->getId()) { 170 if (null === $this->getUser() || $this->getUser()->getId() !== $siteCredential->getUser()->getId()) {
171 throw $this->createAccessDeniedException('You can not access this site credential.'); 171 throw $this->createAccessDeniedException('You can not access this site credential.');
172 } 172 }
173 } 173 }
diff --git a/src/Wallabag/CoreBundle/Controller/StaticController.php b/src/Wallabag/CoreBundle/Controller/StaticController.php
index 82714217..318af303 100644
--- a/src/Wallabag/CoreBundle/Controller/StaticController.php
+++ b/src/Wallabag/CoreBundle/Controller/StaticController.php
@@ -16,7 +16,9 @@ class StaticController extends Controller
16 16
17 return $this->render( 17 return $this->render(
18 '@WallabagCore/themes/common/Static/howto.html.twig', 18 '@WallabagCore/themes/common/Static/howto.html.twig',
19 ['addonsUrl' => $addonsUrl] 19 [
20 'addonsUrl' => $addonsUrl,
21 ]
20 ); 22 );
21 } 23 }
22 24
@@ -40,8 +42,7 @@ class StaticController extends Controller
40 public function quickstartAction() 42 public function quickstartAction()
41 { 43 {
42 return $this->render( 44 return $this->render(
43 '@WallabagCore/themes/common/Static/quickstart.html.twig', 45 '@WallabagCore/themes/common/Static/quickstart.html.twig'
44 []
45 ); 46 );
46 } 47 }
47} 48}
diff --git a/src/Wallabag/CoreBundle/Controller/TagController.php b/src/Wallabag/CoreBundle/Controller/TagController.php
index a8b1eadd..f2ca58c6 100644
--- a/src/Wallabag/CoreBundle/Controller/TagController.php
+++ b/src/Wallabag/CoreBundle/Controller/TagController.php
@@ -4,13 +4,13 @@ namespace Wallabag\CoreBundle\Controller;
4 4
5use Pagerfanta\Adapter\ArrayAdapter; 5use Pagerfanta\Adapter\ArrayAdapter;
6use Pagerfanta\Exception\OutOfRangeCurrentPageException; 6use Pagerfanta\Exception\OutOfRangeCurrentPageException;
7use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
7use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 8use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
8use Symfony\Bundle\FrameworkBundle\Controller\Controller; 9use Symfony\Bundle\FrameworkBundle\Controller\Controller;
9use Symfony\Component\HttpFoundation\Request; 10use Symfony\Component\HttpFoundation\Request;
10use Wallabag\CoreBundle\Entity\Entry; 11use Wallabag\CoreBundle\Entity\Entry;
11use Wallabag\CoreBundle\Entity\Tag; 12use Wallabag\CoreBundle\Entity\Tag;
12use Wallabag\CoreBundle\Form\Type\NewTagType; 13use Wallabag\CoreBundle\Form\Type\NewTagType;
13use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
14 14
15class TagController extends Controller 15class TagController extends Controller
16{ 16{
diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php
index a52288e6..3fe88e7f 100644
--- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php
+++ b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadSettingData.php
@@ -2,10 +2,10 @@
2 2
3namespace Wallabag\CoreBundle\DataFixtures\ORM; 3namespace Wallabag\CoreBundle\DataFixtures\ORM;
4 4
5use Craue\ConfigBundle\Entity\Setting;
5use Doctrine\Common\DataFixtures\AbstractFixture; 6use Doctrine\Common\DataFixtures\AbstractFixture;
6use Doctrine\Common\DataFixtures\OrderedFixtureInterface; 7use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
7use Doctrine\Common\Persistence\ObjectManager; 8use Doctrine\Common\Persistence\ObjectManager;
8use Craue\ConfigBundle\Entity\Setting;
9use Symfony\Component\DependencyInjection\ContainerAwareInterface; 9use Symfony\Component\DependencyInjection\ContainerAwareInterface;
10use Symfony\Component\DependencyInjection\ContainerInterface; 10use Symfony\Component\DependencyInjection\ContainerInterface;
11 11
diff --git a/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php b/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php
index 532ce238..a3ef2b53 100644
--- a/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php
+++ b/src/Wallabag/CoreBundle/DependencyInjection/WallabagCoreExtension.php
@@ -31,7 +31,7 @@ class WallabagCoreExtension extends Extension
31 $container->setParameter('wallabag_core.default_internal_settings', $config['default_internal_settings']); 31 $container->setParameter('wallabag_core.default_internal_settings', $config['default_internal_settings']);
32 $container->setParameter('wallabag_core.site_credentials.encryption_key_path', $config['encryption_key_path']); 32 $container->setParameter('wallabag_core.site_credentials.encryption_key_path', $config['encryption_key_path']);
33 33
34 $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); 34 $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
35 $loader->load('services.yml'); 35 $loader->load('services.yml');
36 $loader->load('parameters.yml'); 36 $loader->load('parameters.yml');
37 } 37 }
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php
index a0503c39..581e8906 100644
--- a/src/Wallabag/CoreBundle/Entity/Entry.php
+++ b/src/Wallabag/CoreBundle/Entity/Entry.php
@@ -5,14 +5,14 @@ namespace Wallabag\CoreBundle\Entity;
5use Doctrine\Common\Collections\ArrayCollection; 5use Doctrine\Common\Collections\ArrayCollection;
6use Doctrine\ORM\Mapping as ORM; 6use Doctrine\ORM\Mapping as ORM;
7use Hateoas\Configuration\Annotation as Hateoas; 7use Hateoas\Configuration\Annotation as Hateoas;
8use JMS\Serializer\Annotation\Groups;
9use JMS\Serializer\Annotation\XmlRoot;
10use JMS\Serializer\Annotation\Exclude; 8use JMS\Serializer\Annotation\Exclude;
11use JMS\Serializer\Annotation\VirtualProperty; 9use JMS\Serializer\Annotation\Groups;
12use JMS\Serializer\Annotation\SerializedName; 10use JMS\Serializer\Annotation\SerializedName;
11use JMS\Serializer\Annotation\VirtualProperty;
12use JMS\Serializer\Annotation\XmlRoot;
13use Symfony\Component\Validator\Constraints as Assert; 13use Symfony\Component\Validator\Constraints as Assert;
14use Wallabag\UserBundle\Entity\User;
15use Wallabag\AnnotationBundle\Entity\Annotation; 14use Wallabag\AnnotationBundle\Entity\Annotation;
15use Wallabag\UserBundle\Entity\User;
16 16
17/** 17/**
18 * Entry. 18 * Entry.
@@ -478,7 +478,7 @@ class Entry
478 */ 478 */
479 public function timestamps() 479 public function timestamps()
480 { 480 {
481 if (is_null($this->createdAt)) { 481 if (null === $this->createdAt) {
482 $this->createdAt = new \DateTime(); 482 $this->createdAt = new \DateTime();
483 } 483 }
484 484
diff --git a/src/Wallabag/CoreBundle/Entity/SiteCredential.php b/src/Wallabag/CoreBundle/Entity/SiteCredential.php
index 58075e92..380f820d 100644
--- a/src/Wallabag/CoreBundle/Entity/SiteCredential.php
+++ b/src/Wallabag/CoreBundle/Entity/SiteCredential.php
@@ -188,7 +188,7 @@ class SiteCredential
188 */ 188 */
189 public function timestamps() 189 public function timestamps()
190 { 190 {
191 if (is_null($this->createdAt)) { 191 if (null === $this->createdAt) {
192 $this->createdAt = new \DateTime(); 192 $this->createdAt = new \DateTime();
193 } 193 }
194 } 194 }
diff --git a/src/Wallabag/CoreBundle/Entity/Tag.php b/src/Wallabag/CoreBundle/Entity/Tag.php
index 4b480ff1..c19023af 100644
--- a/src/Wallabag/CoreBundle/Entity/Tag.php
+++ b/src/Wallabag/CoreBundle/Entity/Tag.php
@@ -4,9 +4,9 @@ namespace Wallabag\CoreBundle\Entity;
4 4
5use Doctrine\Common\Collections\ArrayCollection; 5use Doctrine\Common\Collections\ArrayCollection;
6use Doctrine\ORM\Mapping as ORM; 6use Doctrine\ORM\Mapping as ORM;
7use Gedmo\Mapping\Annotation as Gedmo;
7use JMS\Serializer\Annotation\ExclusionPolicy; 8use JMS\Serializer\Annotation\ExclusionPolicy;
8use JMS\Serializer\Annotation\Expose; 9use JMS\Serializer\Annotation\Expose;
9use Gedmo\Mapping\Annotation as Gedmo;
10use JMS\Serializer\Annotation\XmlRoot; 10use JMS\Serializer\Annotation\XmlRoot;
11 11
12/** 12/**
diff --git a/src/Wallabag/CoreBundle/Event/Subscriber/DownloadImagesSubscriber.php b/src/Wallabag/CoreBundle/Event/Subscriber/DownloadImagesSubscriber.php
index 4ebe837b..1dd0a1a4 100644
--- a/src/Wallabag/CoreBundle/Event/Subscriber/DownloadImagesSubscriber.php
+++ b/src/Wallabag/CoreBundle/Event/Subscriber/DownloadImagesSubscriber.php
@@ -2,13 +2,13 @@
2 2
3namespace Wallabag\CoreBundle\Event\Subscriber; 3namespace Wallabag\CoreBundle\Event\Subscriber;
4 4
5use Symfony\Component\EventDispatcher\EventSubscriberInterface; 5use Doctrine\ORM\EntityManager;
6use Psr\Log\LoggerInterface; 6use Psr\Log\LoggerInterface;
7use Wallabag\CoreBundle\Helper\DownloadImages; 7use Symfony\Component\EventDispatcher\EventSubscriberInterface;
8use Wallabag\CoreBundle\Entity\Entry; 8use Wallabag\CoreBundle\Entity\Entry;
9use Wallabag\CoreBundle\Event\EntrySavedEvent;
10use Wallabag\CoreBundle\Event\EntryDeletedEvent; 9use Wallabag\CoreBundle\Event\EntryDeletedEvent;
11use Doctrine\ORM\EntityManager; 10use Wallabag\CoreBundle\Event\EntrySavedEvent;
11use Wallabag\CoreBundle\Helper\DownloadImages;
12 12
13class DownloadImagesSubscriber implements EventSubscriberInterface 13class DownloadImagesSubscriber implements EventSubscriberInterface
14{ 14{
diff --git a/src/Wallabag/CoreBundle/Event/Subscriber/SQLiteCascadeDeleteSubscriber.php b/src/Wallabag/CoreBundle/Event/Subscriber/SQLiteCascadeDeleteSubscriber.php
index 5e6af8cc..9c1d8a1d 100644
--- a/src/Wallabag/CoreBundle/Event/Subscriber/SQLiteCascadeDeleteSubscriber.php
+++ b/src/Wallabag/CoreBundle/Event/Subscriber/SQLiteCascadeDeleteSubscriber.php
@@ -2,10 +2,10 @@
2 2
3namespace Wallabag\CoreBundle\Event\Subscriber; 3namespace Wallabag\CoreBundle\Event\Subscriber;
4 4
5use Doctrine\Bundle\DoctrineBundle\Registry;
5use Doctrine\Common\EventSubscriber; 6use Doctrine\Common\EventSubscriber;
6use Doctrine\ORM\Event\LifecycleEventArgs; 7use Doctrine\ORM\Event\LifecycleEventArgs;
7use Wallabag\CoreBundle\Entity\Entry; 8use Wallabag\CoreBundle\Entity\Entry;
8use Doctrine\Bundle\DoctrineBundle\Registry;
9 9
10/** 10/**
11 * SQLite doesn't care about cascading remove, so we need to manually remove associated stuf for an Entry. 11 * SQLite doesn't care about cascading remove, so we need to manually remove associated stuf for an Entry.
diff --git a/src/Wallabag/CoreBundle/Event/Subscriber/TablePrefixSubscriber.php b/src/Wallabag/CoreBundle/Event/Subscriber/TablePrefixSubscriber.php
index 711c3bf8..35902654 100644
--- a/src/Wallabag/CoreBundle/Event/Subscriber/TablePrefixSubscriber.php
+++ b/src/Wallabag/CoreBundle/Event/Subscriber/TablePrefixSubscriber.php
@@ -39,12 +39,12 @@ class TablePrefixSubscriber implements EventSubscriber
39 return; 39 return;
40 } 40 }
41 41
42 $classMetadata->setPrimaryTable(['name' => $this->prefix.$classMetadata->getTableName()]); 42 $classMetadata->setPrimaryTable(['name' => $this->prefix . $classMetadata->getTableName()]);
43 43
44 foreach ($classMetadata->getAssociationMappings() as $fieldName => $mapping) { 44 foreach ($classMetadata->getAssociationMappings() as $fieldName => $mapping) {
45 if ($mapping['type'] === ClassMetadataInfo::MANY_TO_MANY && isset($classMetadata->associationMappings[$fieldName]['joinTable']['name'])) { 45 if ($mapping['type'] === ClassMetadataInfo::MANY_TO_MANY && isset($classMetadata->associationMappings[$fieldName]['joinTable']['name'])) {
46 $mappedTableName = $classMetadata->associationMappings[$fieldName]['joinTable']['name']; 46 $mappedTableName = $classMetadata->associationMappings[$fieldName]['joinTable']['name'];
47 $classMetadata->associationMappings[$fieldName]['joinTable']['name'] = $this->prefix.$mappedTableName; 47 $classMetadata->associationMappings[$fieldName]['joinTable']['name'] = $this->prefix . $mappedTableName;
48 } 48 }
49 } 49 }
50 } 50 }
diff --git a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php
index 6a4c485f..6f8c9e27 100644
--- a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php
+++ b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php
@@ -4,12 +4,12 @@ namespace Wallabag\CoreBundle\Form\Type;
4 4
5use Doctrine\ORM\EntityRepository; 5use Doctrine\ORM\EntityRepository;
6use Lexik\Bundle\FormFilterBundle\Filter\FilterOperands; 6use Lexik\Bundle\FormFilterBundle\Filter\FilterOperands;
7use Lexik\Bundle\FormFilterBundle\Filter\Query\QueryInterface;
8use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\NumberRangeFilterType;
9use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\DateRangeFilterType;
10use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\TextFilterType;
11use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\CheckboxFilterType; 7use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\CheckboxFilterType;
12use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\ChoiceFilterType; 8use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\ChoiceFilterType;
9use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\DateRangeFilterType;
10use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\NumberRangeFilterType;
11use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\TextFilterType;
12use Lexik\Bundle\FormFilterBundle\Filter\Query\QueryInterface;
13use Symfony\Component\Form\AbstractType; 13use Symfony\Component\Form\AbstractType;
14use Symfony\Component\Form\FormBuilderInterface; 14use Symfony\Component\Form\FormBuilderInterface;
15use Symfony\Component\HttpFoundation\Response; 15use Symfony\Component\HttpFoundation\Response;
@@ -99,7 +99,7 @@ class EntryFilterType extends AbstractType
99 if (strlen($value) <= 2 || empty($value)) { 99 if (strlen($value) <= 2 || empty($value)) {
100 return; 100 return;
101 } 101 }
102 $expression = $filterQuery->getExpr()->like($field, $filterQuery->getExpr()->lower($filterQuery->getExpr()->literal('%'.$value.'%'))); 102 $expression = $filterQuery->getExpr()->like($field, $filterQuery->getExpr()->lower($filterQuery->getExpr()->literal('%' . $value . '%')));
103 103
104 return $filterQuery->createCondition($expression); 104 return $filterQuery->createCondition($expression);
105 }, 105 },
@@ -113,8 +113,8 @@ class EntryFilterType extends AbstractType
113 } 113 }
114 114
115 $paramName = sprintf('%s', str_replace('.', '_', $field)); 115 $paramName = sprintf('%s', str_replace('.', '_', $field));
116 $expression = $filterQuery->getExpr()->eq($field, ':'.$paramName); 116 $expression = $filterQuery->getExpr()->eq($field, ':' . $paramName);
117 $parameters = array($paramName => $value); 117 $parameters = [$paramName => $value];
118 118
119 return $filterQuery->createCondition($expression, $parameters); 119 return $filterQuery->createCondition($expression, $parameters);
120 }, 120 },
@@ -158,7 +158,7 @@ class EntryFilterType extends AbstractType
158 158
159 // is_public isn't a real field 159 // is_public isn't a real field
160 // we should use the "uid" field to determine if the entry has been made public 160 // we should use the "uid" field to determine if the entry has been made public
161 $expression = $filterQuery->getExpr()->isNotNull($values['alias'].'.uid'); 161 $expression = $filterQuery->getExpr()->isNotNull($values['alias'] . '.uid');
162 162
163 return $filterQuery->createCondition($expression); 163 return $filterQuery->createCondition($expression);
164 }, 164 },
diff --git a/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php b/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php
index a79e6ebe..10689c62 100644
--- a/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php
+++ b/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php
@@ -6,8 +6,8 @@ use BD\GuzzleSiteAuthenticator\SiteConfig\SiteConfig;
6use BD\GuzzleSiteAuthenticator\SiteConfig\SiteConfigBuilder; 6use BD\GuzzleSiteAuthenticator\SiteConfig\SiteConfigBuilder;
7use Graby\SiteConfig\ConfigBuilder; 7use Graby\SiteConfig\ConfigBuilder;
8use Psr\Log\LoggerInterface; 8use Psr\Log\LoggerInterface;
9use Wallabag\CoreBundle\Repository\SiteCredentialRepository;
10use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; 9use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
10use Wallabag\CoreBundle\Repository\SiteCredentialRepository;
11 11
12class GrabySiteConfigBuilder implements SiteConfigBuilder 12class GrabySiteConfigBuilder implements SiteConfigBuilder
13{ 13{
@@ -57,7 +57,7 @@ class GrabySiteConfigBuilder implements SiteConfigBuilder
57 { 57 {
58 // required by credentials below 58 // required by credentials below
59 $host = strtolower($host); 59 $host = strtolower($host);
60 if (substr($host, 0, 4) == 'www.') { 60 if (substr($host, 0, 4) === 'www.') {
61 $host = substr($host, 4); 61 $host = substr($host, 4);
62 } 62 }
63 63
diff --git a/src/Wallabag/CoreBundle/Helper/ContentProxy.php b/src/Wallabag/CoreBundle/Helper/ContentProxy.php
index 51bb2ca2..ddecd6f4 100644
--- a/src/Wallabag/CoreBundle/Helper/ContentProxy.php
+++ b/src/Wallabag/CoreBundle/Helper/ContentProxy.php
@@ -4,12 +4,12 @@ namespace Wallabag\CoreBundle\Helper;
4 4
5use Graby\Graby; 5use Graby\Graby;
6use Psr\Log\LoggerInterface; 6use Psr\Log\LoggerInterface;
7use Wallabag\CoreBundle\Entity\Entry;
8use Wallabag\CoreBundle\Tools\Utils;
9use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeExtensionGuesser; 7use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeExtensionGuesser;
10use Symfony\Component\Validator\Constraints\Locale as LocaleConstraint; 8use Symfony\Component\Validator\Constraints\Locale as LocaleConstraint;
11use Symfony\Component\Validator\Constraints\Url as UrlConstraint; 9use Symfony\Component\Validator\Constraints\Url as UrlConstraint;
12use Symfony\Component\Validator\Validator\ValidatorInterface; 10use Symfony\Component\Validator\Validator\ValidatorInterface;
11use Wallabag\CoreBundle\Entity\Entry;
12use Wallabag\CoreBundle\Tools\Utils;
13 13
14/** 14/**
15 * This kind of proxy class take care of getting the content from an url 15 * This kind of proxy class take care of getting the content from an url
@@ -100,7 +100,7 @@ class ContentProxy
100 100
101 // is it a timestamp? 101 // is it a timestamp?
102 if (filter_var($date, FILTER_VALIDATE_INT) !== false) { 102 if (filter_var($date, FILTER_VALIDATE_INT) !== false) {
103 $date = '@'.$content['date']; 103 $date = '@' . $content['date'];
104 } 104 }
105 105
106 try { 106 try {
@@ -189,7 +189,7 @@ class ContentProxy
189 return; 189 return;
190 } 190 }
191 191
192 $this->logger->warning('Language validation failed. '.(string) $errors); 192 $this->logger->warning('Language validation failed. ' . (string) $errors);
193 } 193 }
194 194
195 /** 195 /**
@@ -211,6 +211,6 @@ class ContentProxy
211 return; 211 return;
212 } 212 }
213 213
214 $this->logger->warning('PreviewPicture validation failed. '.(string) $errors); 214 $this->logger->warning('PreviewPicture validation failed. ' . (string) $errors);
215 } 215 }
216} 216}
diff --git a/src/Wallabag/CoreBundle/Helper/CryptoProxy.php b/src/Wallabag/CoreBundle/Helper/CryptoProxy.php
index e8b19cb9..7d8c9888 100644
--- a/src/Wallabag/CoreBundle/Helper/CryptoProxy.php
+++ b/src/Wallabag/CoreBundle/Helper/CryptoProxy.php
@@ -2,10 +2,10 @@
2 2
3namespace Wallabag\CoreBundle\Helper; 3namespace Wallabag\CoreBundle\Helper;
4 4
5use Psr\Log\LoggerInterface;
6use Defuse\Crypto\Key;
7use Defuse\Crypto\Crypto; 5use Defuse\Crypto\Crypto;
8use Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException; 6use Defuse\Crypto\Exception\WrongKeyOrModifiedCiphertextException;
7use Defuse\Crypto\Key;
8use Psr\Log\LoggerInterface;
9 9
10/** 10/**
11 * This is a proxy to crypt and decrypt password used by SiteCredential entity. 11 * This is a proxy to crypt and decrypt password used by SiteCredential entity.
@@ -39,7 +39,7 @@ class CryptoProxy
39 */ 39 */
40 public function crypt($secretValue) 40 public function crypt($secretValue)
41 { 41 {
42 $this->logger->debug('Crypto: crypting value: '.$this->mask($secretValue)); 42 $this->logger->debug('Crypto: crypting value: ' . $this->mask($secretValue));
43 43
44 return Crypto::encrypt($secretValue, $this->loadKey()); 44 return Crypto::encrypt($secretValue, $this->loadKey());
45 } 45 }
@@ -53,12 +53,12 @@ class CryptoProxy
53 */ 53 */
54 public function decrypt($cryptedValue) 54 public function decrypt($cryptedValue)
55 { 55 {
56 $this->logger->debug('Crypto: decrypting value: '.$this->mask($cryptedValue)); 56 $this->logger->debug('Crypto: decrypting value: ' . $this->mask($cryptedValue));
57 57
58 try { 58 try {
59 return Crypto::decrypt($cryptedValue, $this->loadKey()); 59 return Crypto::decrypt($cryptedValue, $this->loadKey());
60 } catch (WrongKeyOrModifiedCiphertextException $e) { 60 } catch (WrongKeyOrModifiedCiphertextException $e) {
61 throw new \RuntimeException('Decrypt fail: '.$e->getMessage()); 61 throw new \RuntimeException('Decrypt fail: ' . $e->getMessage());
62 } 62 }
63 } 63 }
64 64
@@ -81,6 +81,6 @@ class CryptoProxy
81 */ 81 */
82 private function mask($value) 82 private function mask($value)
83 { 83 {
84 return strlen($value) > 0 ? $value[0].'*****'.$value[strlen($value) - 1] : 'Empty value'; 84 return strlen($value) > 0 ? $value[0] . '*****' . $value[strlen($value) - 1] : 'Empty value';
85 } 85 }
86} 86}
diff --git a/src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php b/src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php
index 23e98042..9f90ee3e 100644
--- a/src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php
+++ b/src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php
@@ -44,7 +44,7 @@ class DetectActiveTheme implements DeviceDetectionInterface
44 { 44 {
45 $token = $this->tokenStorage->getToken(); 45 $token = $this->tokenStorage->getToken();
46 46
47 if (is_null($token)) { 47 if (null === $token) {
48 return $this->defaultTheme; 48 return $this->defaultTheme;
49 } 49 }
50 50
diff --git a/src/Wallabag/CoreBundle/Helper/DownloadImages.php b/src/Wallabag/CoreBundle/Helper/DownloadImages.php
index ed888cdb..252ba57c 100644
--- a/src/Wallabag/CoreBundle/Helper/DownloadImages.php
+++ b/src/Wallabag/CoreBundle/Helper/DownloadImages.php
@@ -2,12 +2,12 @@
2 2
3namespace Wallabag\CoreBundle\Helper; 3namespace Wallabag\CoreBundle\Helper;
4 4
5use Psr\Log\LoggerInterface;
6use Symfony\Component\DomCrawler\Crawler;
7use GuzzleHttp\Client; 5use GuzzleHttp\Client;
8use GuzzleHttp\Message\Response; 6use GuzzleHttp\Message\Response;
9use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeExtensionGuesser; 7use Psr\Log\LoggerInterface;
8use Symfony\Component\DomCrawler\Crawler;
10use Symfony\Component\Finder\Finder; 9use Symfony\Component\Finder\Finder;
10use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeExtensionGuesser;
11 11
12class DownloadImages 12class DownloadImages
13{ 13{
@@ -31,17 +31,6 @@ class DownloadImages
31 } 31 }
32 32
33 /** 33 /**
34 * Setup base folder where all images are going to be saved.
35 */
36 private function setFolder()
37 {
38 // if folder doesn't exist, attempt to create one and store the folder name in property $folder
39 if (!file_exists($this->baseFolder)) {
40 mkdir($this->baseFolder, 0755, true);
41 }
42 }
43
44 /**
45 * Process the html and extract image from it, save them to local and return the updated html. 34 * Process the html and extract image from it, save them to local and return the updated html.
46 * 35 *
47 * @param int $entryId ID of the entry 36 * @param int $entryId ID of the entry
@@ -97,9 +86,9 @@ class DownloadImages
97 $relativePath = $this->getRelativePath($entryId); 86 $relativePath = $this->getRelativePath($entryId);
98 } 87 }
99 88
100 $this->logger->debug('DownloadImages: working on image: '.$imagePath); 89 $this->logger->debug('DownloadImages: working on image: ' . $imagePath);
101 90
102 $folderPath = $this->baseFolder.'/'.$relativePath; 91 $folderPath = $this->baseFolder . '/' . $relativePath;
103 92
104 // build image path 93 // build image path
105 $absolutePath = $this->getAbsoluteLink($url, $imagePath); 94 $absolutePath = $this->getAbsoluteLink($url, $imagePath);
@@ -123,7 +112,7 @@ class DownloadImages
123 } 112 }
124 113
125 $hashImage = hash('crc32', $absolutePath); 114 $hashImage = hash('crc32', $absolutePath);
126 $localPath = $folderPath.'/'.$hashImage.'.'.$ext; 115 $localPath = $folderPath . '/' . $hashImage . '.' . $ext;
127 116
128 try { 117 try {
129 $im = imagecreatefromstring($res->getBody()); 118 $im = imagecreatefromstring($res->getBody());
@@ -156,7 +145,7 @@ class DownloadImages
156 145
157 imagedestroy($im); 146 imagedestroy($im);
158 147
159 return $this->wallabagUrl.'/assets/images/'.$relativePath.'/'.$hashImage.'.'.$ext; 148 return $this->wallabagUrl . '/assets/images/' . $relativePath . '/' . $hashImage . '.' . $ext;
160 } 149 }
161 150
162 /** 151 /**
@@ -167,7 +156,7 @@ class DownloadImages
167 public function removeImages($entryId) 156 public function removeImages($entryId)
168 { 157 {
169 $relativePath = $this->getRelativePath($entryId); 158 $relativePath = $this->getRelativePath($entryId);
170 $folderPath = $this->baseFolder.'/'.$relativePath; 159 $folderPath = $this->baseFolder . '/' . $relativePath;
171 160
172 $finder = new Finder(); 161 $finder = new Finder();
173 $finder 162 $finder
@@ -183,6 +172,17 @@ class DownloadImages
183 } 172 }
184 173
185 /** 174 /**
175 * Setup base folder where all images are going to be saved.
176 */
177 private function setFolder()
178 {
179 // if folder doesn't exist, attempt to create one and store the folder name in property $folder
180 if (!file_exists($this->baseFolder)) {
181 mkdir($this->baseFolder, 0755, true);
182 }
183 }
184
185 /**
186 * Generate the folder where we are going to save images based on the entry url. 186 * Generate the folder where we are going to save images based on the entry url.
187 * 187 *
188 * @param int $entryId ID of the entry 188 * @param int $entryId ID of the entry
@@ -192,8 +192,8 @@ class DownloadImages
192 private function getRelativePath($entryId) 192 private function getRelativePath($entryId)
193 { 193 {
194 $hashId = hash('crc32', $entryId); 194 $hashId = hash('crc32', $entryId);
195 $relativePath = $hashId[0].'/'.$hashId[1].'/'.$hashId; 195 $relativePath = $hashId[0] . '/' . $hashId[1] . '/' . $hashId;
196 $folderPath = $this->baseFolder.'/'.$relativePath; 196 $folderPath = $this->baseFolder . '/' . $relativePath;
197 197
198 if (!file_exists($folderPath)) { 198 if (!file_exists($folderPath)) {
199 mkdir($folderPath, 0777, true); 199 mkdir($folderPath, 0777, true);
@@ -270,7 +270,7 @@ class DownloadImages
270 } 270 }
271 271
272 if (!in_array($ext, ['jpeg', 'jpg', 'gif', 'png'], true)) { 272 if (!in_array($ext, ['jpeg', 'jpg', 'gif', 'png'], true)) {
273 $this->logger->error('DownloadImages: Processed image with not allowed extension. Skipping: '.$imagePath); 273 $this->logger->error('DownloadImages: Processed image with not allowed extension. Skipping: ' . $imagePath);
274 274
275 return false; 275 return false;
276 } 276 }
diff --git a/src/Wallabag/CoreBundle/Helper/EntriesExport.php b/src/Wallabag/CoreBundle/Helper/EntriesExport.php
index 3d36a4c8..cd74cc4f 100644
--- a/src/Wallabag/CoreBundle/Helper/EntriesExport.php
+++ b/src/Wallabag/CoreBundle/Helper/EntriesExport.php
@@ -63,7 +63,7 @@ class EntriesExport
63 */ 63 */
64 public function updateTitle($method) 64 public function updateTitle($method)
65 { 65 {
66 $this->title = $method.' articles'; 66 $this->title = $method . ' articles';
67 67
68 if ('entry' === $method) { 68 if ('entry' === $method) {
69 $this->title = $this->entries[0]->getTitle(); 69 $this->title = $this->entries[0]->getTitle();
@@ -81,7 +81,7 @@ class EntriesExport
81 */ 81 */
82 public function exportAs($format) 82 public function exportAs($format)
83 { 83 {
84 $functionName = 'produce'.ucfirst($format); 84 $functionName = 'produce' . ucfirst($format);
85 if (method_exists($this, $functionName)) { 85 if (method_exists($this, $functionName)) {
86 return $this->$functionName(); 86 return $this->$functionName();
87 } 87 }
@@ -106,12 +106,12 @@ class EntriesExport
106 */ 106 */
107 $content_start = 107 $content_start =
108 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" 108 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
109 ."<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:epub=\"http://www.idpf.org/2007/ops\">\n" 109 . "<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:epub=\"http://www.idpf.org/2007/ops\">\n"
110 .'<head>' 110 . '<head>'
111 ."<meta http-equiv=\"Default-Style\" content=\"text/html; charset=utf-8\" />\n" 111 . "<meta http-equiv=\"Default-Style\" content=\"text/html; charset=utf-8\" />\n"
112 ."<title>wallabag articles book</title>\n" 112 . "<title>wallabag articles book</title>\n"
113 ."</head>\n" 113 . "</head>\n"
114 ."<body>\n"; 114 . "<body>\n";
115 115
116 $bookEnd = "</body>\n</html>\n"; 116 $bookEnd = "</body>\n</html>\n";
117 117
@@ -164,11 +164,11 @@ class EntriesExport
164 // in filenames, we limit to A-z/0-9 164 // in filenames, we limit to A-z/0-9
165 $filename = preg_replace('/[^A-Za-z0-9\-]/', '', $entry->getTitle()); 165 $filename = preg_replace('/[^A-Za-z0-9\-]/', '', $entry->getTitle());
166 166
167 $chapter = $content_start.$entry->getContent().$bookEnd; 167 $chapter = $content_start . $entry->getContent() . $bookEnd;
168 $book->addChapter($entry->getTitle(), htmlspecialchars($filename).'.html', $chapter, true, EPub::EXTERNAL_REF_ADD); 168 $book->addChapter($entry->getTitle(), htmlspecialchars($filename) . '.html', $chapter, true, EPub::EXTERNAL_REF_ADD);
169 } 169 }
170 170
171 $book->addChapter('Notices', 'Cover2.html', $content_start.$this->getExportInformation('PHPePub').$bookEnd); 171 $book->addChapter('Notices', 'Cover2.html', $content_start . $this->getExportInformation('PHPePub') . $bookEnd);
172 172
173 return Response::create( 173 return Response::create(
174 $book->getBook(), 174 $book->getBook(),
@@ -176,7 +176,7 @@ class EntriesExport
176 [ 176 [
177 'Content-Description' => 'File Transfer', 177 'Content-Description' => 'File Transfer',
178 'Content-type' => 'application/epub+zip', 178 'Content-type' => 'application/epub+zip',
179 'Content-Disposition' => 'attachment; filename="'.$this->title.'.epub"', 179 'Content-Disposition' => 'attachment; filename="' . $this->title . '.epub"',
180 'Content-Transfer-Encoding' => 'binary', 180 'Content-Transfer-Encoding' => 'binary',
181 ] 181 ]
182 ); 182 );
@@ -228,7 +228,7 @@ class EntriesExport
228 'Accept-Ranges' => 'bytes', 228 'Accept-Ranges' => 'bytes',
229 'Content-Description' => 'File Transfer', 229 'Content-Description' => 'File Transfer',
230 'Content-type' => 'application/x-mobipocket-ebook', 230 'Content-type' => 'application/x-mobipocket-ebook',
231 'Content-Disposition' => 'attachment; filename="'.$this->title.'.mobi"', 231 'Content-Disposition' => 'attachment; filename="' . $this->title . '.mobi"',
232 'Content-Transfer-Encoding' => 'binary', 232 'Content-Transfer-Encoding' => 'binary',
233 ] 233 ]
234 ); 234 );
@@ -256,7 +256,7 @@ class EntriesExport
256 * Front page 256 * Front page
257 */ 257 */
258 $pdf->AddPage(); 258 $pdf->AddPage();
259 $intro = '<h1>'.$this->title.'</h1>'.$this->getExportInformation('tcpdf'); 259 $intro = '<h1>' . $this->title . '</h1>' . $this->getExportInformation('tcpdf');
260 260
261 $pdf->writeHTMLCell(0, 0, '', '', $intro, 0, 1, 0, true, '', true); 261 $pdf->writeHTMLCell(0, 0, '', '', $intro, 0, 1, 0, true, '', true);
262 262
@@ -269,7 +269,7 @@ class EntriesExport
269 } 269 }
270 270
271 $pdf->AddPage(); 271 $pdf->AddPage();
272 $html = '<h1>'.$entry->getTitle().'</h1>'; 272 $html = '<h1>' . $entry->getTitle() . '</h1>';
273 $html .= $entry->getContent(); 273 $html .= $entry->getContent();
274 274
275 $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true); 275 $pdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
@@ -284,7 +284,7 @@ class EntriesExport
284 [ 284 [
285 'Content-Description' => 'File Transfer', 285 'Content-Description' => 'File Transfer',
286 'Content-type' => 'application/pdf', 286 'Content-type' => 'application/pdf',
287 'Content-Disposition' => 'attachment; filename="'.$this->title.'.pdf"', 287 'Content-Disposition' => 'attachment; filename="' . $this->title . '.pdf"',
288 'Content-Transfer-Encoding' => 'binary', 288 'Content-Transfer-Encoding' => 'binary',
289 ] 289 ]
290 ); 290 );
@@ -330,7 +330,7 @@ class EntriesExport
330 200, 330 200,
331 [ 331 [
332 'Content-type' => 'application/csv', 332 'Content-type' => 'application/csv',
333 'Content-Disposition' => 'attachment; filename="'.$this->title.'.csv"', 333 'Content-Disposition' => 'attachment; filename="' . $this->title . '.csv"',
334 'Content-Transfer-Encoding' => 'UTF-8', 334 'Content-Transfer-Encoding' => 'UTF-8',
335 ] 335 ]
336 ); 336 );
@@ -348,7 +348,7 @@ class EntriesExport
348 200, 348 200,
349 [ 349 [
350 'Content-type' => 'application/json', 350 'Content-type' => 'application/json',
351 'Content-Disposition' => 'attachment; filename="'.$this->title.'.json"', 351 'Content-Disposition' => 'attachment; filename="' . $this->title . '.json"',
352 'Content-Transfer-Encoding' => 'UTF-8', 352 'Content-Transfer-Encoding' => 'UTF-8',
353 ] 353 ]
354 ); 354 );
@@ -366,7 +366,7 @@ class EntriesExport
366 200, 366 200,
367 [ 367 [
368 'Content-type' => 'application/xml', 368 'Content-type' => 'application/xml',
369 'Content-Disposition' => 'attachment; filename="'.$this->title.'.xml"', 369 'Content-Disposition' => 'attachment; filename="' . $this->title . '.xml"',
370 'Content-Transfer-Encoding' => 'UTF-8', 370 'Content-Transfer-Encoding' => 'UTF-8',
371 ] 371 ]
372 ); 372 );
@@ -382,8 +382,8 @@ class EntriesExport
382 $content = ''; 382 $content = '';
383 $bar = str_repeat('=', 100); 383 $bar = str_repeat('=', 100);
384 foreach ($this->entries as $entry) { 384 foreach ($this->entries as $entry) {
385 $content .= "\n\n".$bar."\n\n".$entry->getTitle()."\n\n".$bar."\n\n"; 385 $content .= "\n\n" . $bar . "\n\n" . $entry->getTitle() . "\n\n" . $bar . "\n\n";
386 $content .= trim(preg_replace('/\s+/S', ' ', strip_tags($entry->getContent())))."\n\n"; 386 $content .= trim(preg_replace('/\s+/S', ' ', strip_tags($entry->getContent()))) . "\n\n";
387 } 387 }
388 388
389 return Response::create( 389 return Response::create(
@@ -391,7 +391,7 @@ class EntriesExport
391 200, 391 200,
392 [ 392 [
393 'Content-type' => 'text/plain', 393 'Content-type' => 'text/plain',
394 'Content-Disposition' => 'attachment; filename="'.$this->title.'.txt"', 394 'Content-Disposition' => 'attachment; filename="' . $this->title . '.txt"',
395 'Content-Transfer-Encoding' => 'UTF-8', 395 'Content-Transfer-Encoding' => 'UTF-8',
396 ] 396 ]
397 ); 397 );
@@ -427,7 +427,7 @@ class EntriesExport
427 $info = str_replace('%EXPORT_METHOD%', $type, $this->footerTemplate); 427 $info = str_replace('%EXPORT_METHOD%', $type, $this->footerTemplate);
428 428
429 if ('tcpdf' === $type) { 429 if ('tcpdf' === $type) {
430 return str_replace('%IMAGE%', '<img src="'.$this->logoPath.'" />', $info); 430 return str_replace('%IMAGE%', '<img src="' . $this->logoPath . '" />', $info);
431 } 431 }
432 432
433 return str_replace('%IMAGE%', '', $info); 433 return str_replace('%IMAGE%', '', $info);
diff --git a/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php b/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php
index 43f5b119..4602a684 100644
--- a/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php
+++ b/src/Wallabag/CoreBundle/Helper/HttpClientFactory.php
@@ -41,7 +41,7 @@ class HttpClientFactory
41 */ 41 */
42 public function buildHttpClient() 42 public function buildHttpClient()
43 { 43 {
44 $this->logger->log('debug', 'Restricted access config enabled?', array('enabled' => (int) $this->restrictedAccess)); 44 $this->logger->log('debug', 'Restricted access config enabled?', ['enabled' => (int) $this->restrictedAccess]);
45 45
46 if (0 === (int) $this->restrictedAccess) { 46 if (0 === (int) $this->restrictedAccess) {
47 return; 47 return;
diff --git a/src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php b/src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php
index 231a0b52..49c1ea41 100644
--- a/src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php
+++ b/src/Wallabag/CoreBundle/Helper/PreparePagerForEntries.php
@@ -4,9 +4,9 @@ namespace Wallabag\CoreBundle\Helper;
4 4
5use Pagerfanta\Adapter\AdapterInterface; 5use Pagerfanta\Adapter\AdapterInterface;
6use Pagerfanta\Pagerfanta; 6use Pagerfanta\Pagerfanta;
7use Wallabag\UserBundle\Entity\User;
8use Symfony\Component\Routing\Router; 7use Symfony\Component\Routing\Router;
9use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; 8use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
9use Wallabag\UserBundle\Entity\User;
10 10
11class PreparePagerForEntries 11class PreparePagerForEntries
12{ 12{
diff --git a/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php b/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php
index 509d0dec..63f65067 100644
--- a/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php
+++ b/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php
@@ -2,13 +2,13 @@
2 2
3namespace Wallabag\CoreBundle\Helper; 3namespace Wallabag\CoreBundle\Helper;
4 4
5use Psr\Log\LoggerInterface;
5use RulerZ\RulerZ; 6use RulerZ\RulerZ;
6use Wallabag\CoreBundle\Entity\Entry; 7use Wallabag\CoreBundle\Entity\Entry;
7use Wallabag\CoreBundle\Entity\Tag; 8use Wallabag\CoreBundle\Entity\Tag;
8use Wallabag\CoreBundle\Repository\EntryRepository; 9use Wallabag\CoreBundle\Repository\EntryRepository;
9use Wallabag\CoreBundle\Repository\TagRepository; 10use Wallabag\CoreBundle\Repository\TagRepository;
10use Wallabag\UserBundle\Entity\User; 11use Wallabag\UserBundle\Entity\User;
11use Psr\Log\LoggerInterface;
12 12
13class RuleBasedTagger 13class RuleBasedTagger
14{ 14{
diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
index 9bda4e15..a65bfe3b 100644
--- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php
+++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php
@@ -11,21 +11,6 @@ use Wallabag\CoreBundle\Entity\Tag;
11class EntryRepository extends EntityRepository 11class EntryRepository extends EntityRepository
12{ 12{
13 /** 13 /**
14 * Return a query builder to used by other getBuilderFor* method.
15 *
16 * @param int $userId
17 *
18 * @return QueryBuilder
19 */
20 private function getBuilderByUser($userId)
21 {
22 return $this->createQueryBuilder('e')
23 ->andWhere('e.user = :userId')->setParameter('userId', $userId)
24 ->orderBy('e.createdAt', 'desc')
25 ;
26 }
27
28 /**
29 * Retrieves all entries for a user. 14 * Retrieves all entries for a user.
30 * 15 *
31 * @param int $userId 16 * @param int $userId
@@ -108,7 +93,7 @@ class EntryRepository extends EntityRepository
108 93
109 // We lower() all parts here because PostgreSQL 'LIKE' verb is case-sensitive 94 // We lower() all parts here because PostgreSQL 'LIKE' verb is case-sensitive
110 $qb 95 $qb
111 ->andWhere('lower(e.content) LIKE lower(:term) OR lower(e.title) LIKE lower(:term) OR lower(e.url) LIKE lower(:term)')->setParameter('term', '%'.$term.'%') 96 ->andWhere('lower(e.content) LIKE lower(:term) OR lower(e.title) LIKE lower(:term) OR lower(e.url) LIKE lower(:term)')->setParameter('term', '%' . $term . '%')
112 ->leftJoin('e.tags', 't') 97 ->leftJoin('e.tags', 't')
113 ->groupBy('e.id'); 98 ->groupBy('e.id');
114 99
@@ -158,7 +143,7 @@ class EntryRepository extends EntityRepository
158 } 143 }
159 144
160 if (null !== $isPublic) { 145 if (null !== $isPublic) {
161 $qb->andWhere('e.uid IS '.(true === $isPublic ? 'NOT' : '').' NULL'); 146 $qb->andWhere('e.uid IS ' . (true === $isPublic ? 'NOT' : '') . ' NULL');
162 } 147 }
163 148
164 if ($since > 0) { 149 if ($since > 0) {
@@ -414,4 +399,19 @@ class EntryRepository extends EntityRepository
414 ->getQuery() 399 ->getQuery()
415 ->getResult(); 400 ->getResult();
416 } 401 }
402
403 /**
404 * Return a query builder to used by other getBuilderFor* method.
405 *
406 * @param int $userId
407 *
408 * @return QueryBuilder
409 */
410 private function getBuilderByUser($userId)
411 {
412 return $this->createQueryBuilder('e')
413 ->andWhere('e.user = :userId')->setParameter('userId', $userId)
414 ->orderBy('e.createdAt', 'desc')
415 ;
416 }
417} 417}
diff --git a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php
index a305c53f..351172c4 100644
--- a/src/Wallabag/CoreBundle/Twig/WallabagExtension.php
+++ b/src/Wallabag/CoreBundle/Twig/WallabagExtension.php
@@ -3,9 +3,9 @@
3namespace Wallabag\CoreBundle\Twig; 3namespace Wallabag\CoreBundle\Twig;
4 4
5use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; 5use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
6use Symfony\Component\Translation\TranslatorInterface;
6use Wallabag\CoreBundle\Repository\EntryRepository; 7use Wallabag\CoreBundle\Repository\EntryRepository;
7use Wallabag\CoreBundle\Repository\TagRepository; 8use Wallabag\CoreBundle\Repository\TagRepository;
8use Symfony\Component\Translation\TranslatorInterface;
9 9
10class WallabagExtension extends \Twig_Extension implements \Twig_Extension_GlobalsInterface 10class WallabagExtension extends \Twig_Extension implements \Twig_Extension_GlobalsInterface
11{ 11{
@@ -33,11 +33,11 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa
33 33
34 public function getFunctions() 34 public function getFunctions()
35 { 35 {
36 return array( 36 return [
37 new \Twig_SimpleFunction('count_entries', [$this, 'countEntries']), 37 new \Twig_SimpleFunction('count_entries', [$this, 'countEntries']),
38 new \Twig_SimpleFunction('count_tags', [$this, 'countTags']), 38 new \Twig_SimpleFunction('count_tags', [$this, 'countTags']),
39 new \Twig_SimpleFunction('display_stats', [$this, 'displayStats']), 39 new \Twig_SimpleFunction('display_stats', [$this, 'displayStats']),
40 ); 40 ];
41 } 41 }
42 42
43 public function removeWww($url) 43 public function removeWww($url)
@@ -64,19 +64,15 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa
64 case 'starred': 64 case 'starred':
65 $qb = $this->entryRepository->getBuilderForStarredByUser($user->getId()); 65 $qb = $this->entryRepository->getBuilderForStarredByUser($user->getId());
66 break; 66 break;
67
68 case 'archive': 67 case 'archive':
69 $qb = $this->entryRepository->getBuilderForArchiveByUser($user->getId()); 68 $qb = $this->entryRepository->getBuilderForArchiveByUser($user->getId());
70 break; 69 break;
71
72 case 'unread': 70 case 'unread':
73 $qb = $this->entryRepository->getBuilderForUnreadByUser($user->getId()); 71 $qb = $this->entryRepository->getBuilderForUnreadByUser($user->getId());
74 break; 72 break;
75
76 case 'all': 73 case 'all':
77 $qb = $this->entryRepository->getBuilderForAllByUser($user->getId()); 74 $qb = $this->entryRepository->getBuilderForAllByUser($user->getId());
78 break; 75 break;
79
80 default: 76 default:
81 throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type)); 77 throw new \InvalidArgumentException(sprintf('Type "%s" is not implemented.', $type));
82 } 78 }
@@ -139,7 +135,7 @@ class WallabagExtension extends \Twig_Extension implements \Twig_Extension_Globa
139 $nbDays = (int) $interval->format('%a') ?: 1; 135 $nbDays = (int) $interval->format('%a') ?: 1;
140 136
141 // force setlocale for date translation 137 // force setlocale for date translation
142 setlocale(LC_TIME, strtolower($user->getConfig()->getLanguage()).'_'.strtoupper(strtolower($user->getConfig()->getLanguage()))); 138 setlocale(LC_TIME, strtolower($user->getConfig()->getLanguage()) . '_' . strtoupper(strtolower($user->getConfig()->getLanguage())));
143 139
144 return $this->translator->trans('footer.stats', [ 140 return $this->translator->trans('footer.stats', [
145 '%user_creation%' => strftime('%e %B %Y', $user->getCreatedAt()->getTimestamp()), 141 '%user_creation%' => strftime('%e %B %Y', $user->getCreatedAt()->getTimestamp()),
diff --git a/src/Wallabag/ImportBundle/Command/ImportCommand.php b/src/Wallabag/ImportBundle/Command/ImportCommand.php
index 5f1ab0af..99056c2c 100644
--- a/src/Wallabag/ImportBundle/Command/ImportCommand.php
+++ b/src/Wallabag/ImportBundle/Command/ImportCommand.php
@@ -5,8 +5,8 @@ namespace Wallabag\ImportBundle\Command;
5use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; 5use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
6use Symfony\Component\Config\Definition\Exception\Exception; 6use Symfony\Component\Config\Definition\Exception\Exception;
7use Symfony\Component\Console\Input\InputArgument; 7use Symfony\Component\Console\Input\InputArgument;
8use Symfony\Component\Console\Input\InputOption;
9use Symfony\Component\Console\Input\InputInterface; 8use Symfony\Component\Console\Input\InputInterface;
9use Symfony\Component\Console\Input\InputOption;
10use Symfony\Component\Console\Output\OutputInterface; 10use Symfony\Component\Console\Output\OutputInterface;
11 11
12class ImportCommand extends ContainerAwareCommand 12class ImportCommand extends ContainerAwareCommand
@@ -27,7 +27,7 @@ class ImportCommand extends ContainerAwareCommand
27 27
28 protected function execute(InputInterface $input, OutputInterface $output) 28 protected function execute(InputInterface $input, OutputInterface $output)
29 { 29 {
30 $output->writeln('Start : '.(new \DateTime())->format('d-m-Y G:i:s').' ---'); 30 $output->writeln('Start : ' . (new \DateTime())->format('d-m-Y G:i:s') . ' ---');
31 31
32 if (!file_exists($input->getArgument('filepath'))) { 32 if (!file_exists($input->getArgument('filepath'))) {
33 throw new Exception(sprintf('File "%s" not found', $input->getArgument('filepath'))); 33 throw new Exception(sprintf('File "%s" not found', $input->getArgument('filepath')));
@@ -80,12 +80,12 @@ class ImportCommand extends ContainerAwareCommand
80 80
81 if (true === $res) { 81 if (true === $res) {
82 $summary = $import->getSummary(); 82 $summary = $import->getSummary();
83 $output->writeln('<info>'.$summary['imported'].' imported</info>'); 83 $output->writeln('<info>' . $summary['imported'] . ' imported</info>');
84 $output->writeln('<comment>'.$summary['skipped'].' already saved</comment>'); 84 $output->writeln('<comment>' . $summary['skipped'] . ' already saved</comment>');
85 } 85 }
86 86
87 $em->clear(); 87 $em->clear();
88 88
89 $output->writeln('End : '.(new \DateTime())->format('d-m-Y G:i:s').' ---'); 89 $output->writeln('End : ' . (new \DateTime())->format('d-m-Y G:i:s') . ' ---');
90 } 90 }
91} 91}
diff --git a/src/Wallabag/ImportBundle/Command/RedisWorkerCommand.php b/src/Wallabag/ImportBundle/Command/RedisWorkerCommand.php
index 2d06af44..d94900ad 100644
--- a/src/Wallabag/ImportBundle/Command/RedisWorkerCommand.php
+++ b/src/Wallabag/ImportBundle/Command/RedisWorkerCommand.php
@@ -2,13 +2,13 @@
2 2
3namespace Wallabag\ImportBundle\Command; 3namespace Wallabag\ImportBundle\Command;
4 4
5use Simpleue\Worker\QueueWorker;
5use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; 6use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
6use Symfony\Component\Config\Definition\Exception\Exception; 7use Symfony\Component\Config\Definition\Exception\Exception;
7use Symfony\Component\Console\Input\InputArgument; 8use Symfony\Component\Console\Input\InputArgument;
8use Symfony\Component\Console\Input\InputOption;
9use Symfony\Component\Console\Input\InputInterface; 9use Symfony\Component\Console\Input\InputInterface;
10use Symfony\Component\Console\Input\InputOption;
10use Symfony\Component\Console\Output\OutputInterface; 11use Symfony\Component\Console\Output\OutputInterface;
11use Simpleue\Worker\QueueWorker;
12 12
13class RedisWorkerCommand extends ContainerAwareCommand 13class RedisWorkerCommand extends ContainerAwareCommand
14{ 14{
@@ -24,18 +24,18 @@ class RedisWorkerCommand extends ContainerAwareCommand
24 24
25 protected function execute(InputInterface $input, OutputInterface $output) 25 protected function execute(InputInterface $input, OutputInterface $output)
26 { 26 {
27 $output->writeln('Worker started at: '.(new \DateTime())->format('d-m-Y G:i:s')); 27 $output->writeln('Worker started at: ' . (new \DateTime())->format('d-m-Y G:i:s'));
28 $output->writeln('Waiting for message ...'); 28 $output->writeln('Waiting for message ...');
29 29
30 $serviceName = $input->getArgument('serviceName'); 30 $serviceName = $input->getArgument('serviceName');
31 31
32 if (!$this->getContainer()->has('wallabag_import.queue.redis.'.$serviceName) || !$this->getContainer()->has('wallabag_import.consumer.redis.'.$serviceName)) { 32 if (!$this->getContainer()->has('wallabag_import.queue.redis.' . $serviceName) || !$this->getContainer()->has('wallabag_import.consumer.redis.' . $serviceName)) {
33 throw new Exception(sprintf('No queue or consumer found for service name: "%s"', $input->getArgument('serviceName'))); 33 throw new Exception(sprintf('No queue or consumer found for service name: "%s"', $input->getArgument('serviceName')));
34 } 34 }
35 35
36 $worker = new QueueWorker( 36 $worker = new QueueWorker(
37 $this->getContainer()->get('wallabag_import.queue.redis.'.$serviceName), 37 $this->getContainer()->get('wallabag_import.queue.redis.' . $serviceName),
38 $this->getContainer()->get('wallabag_import.consumer.redis.'.$serviceName), 38 $this->getContainer()->get('wallabag_import.consumer.redis.' . $serviceName),
39 (int) $input->getOption('maxIterations') 39 (int) $input->getOption('maxIterations')
40 ); 40 );
41 41
diff --git a/src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php b/src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php
index 992ce1ad..b035f5cc 100644
--- a/src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php
+++ b/src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php
@@ -3,14 +3,14 @@
3namespace Wallabag\ImportBundle\Consumer; 3namespace Wallabag\ImportBundle\Consumer;
4 4
5use Doctrine\ORM\EntityManager; 5use Doctrine\ORM\EntityManager;
6use Wallabag\ImportBundle\Import\AbstractImport;
7use Wallabag\UserBundle\Repository\UserRepository;
8use Wallabag\CoreBundle\Entity\Entry;
9use Wallabag\CoreBundle\Entity\Tag;
10use Psr\Log\LoggerInterface; 6use Psr\Log\LoggerInterface;
11use Psr\Log\NullLogger; 7use Psr\Log\NullLogger;
12use Symfony\Component\EventDispatcher\EventDispatcherInterface; 8use Symfony\Component\EventDispatcher\EventDispatcherInterface;
9use Wallabag\CoreBundle\Entity\Entry;
10use Wallabag\CoreBundle\Entity\Tag;
13use Wallabag\CoreBundle\Event\EntrySavedEvent; 11use Wallabag\CoreBundle\Event\EntrySavedEvent;
12use Wallabag\ImportBundle\Import\AbstractImport;
13use Wallabag\UserBundle\Repository\UserRepository;
14 14
15abstract class AbstractConsumer 15abstract class AbstractConsumer
16{ 16{
@@ -76,7 +76,7 @@ abstract class AbstractConsumer
76 return false; 76 return false;
77 } 77 }
78 78
79 $this->logger->info('Content with url imported! ('.$entry->getUrl().')'); 79 $this->logger->info('Content with url imported! (' . $entry->getUrl() . ')');
80 80
81 return true; 81 return true;
82 } 82 }
diff --git a/src/Wallabag/ImportBundle/Controller/BrowserController.php b/src/Wallabag/ImportBundle/Controller/BrowserController.php
index e119098f..0753e318 100644
--- a/src/Wallabag/ImportBundle/Controller/BrowserController.php
+++ b/src/Wallabag/ImportBundle/Controller/BrowserController.php
@@ -2,8 +2,8 @@
2 2
3namespace Wallabag\ImportBundle\Controller; 3namespace Wallabag\ImportBundle\Controller;
4 4
5use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7use Symfony\Component\HttpFoundation\Request; 7use Symfony\Component\HttpFoundation\Request;
8use Symfony\Component\HttpFoundation\Response; 8use Symfony\Component\HttpFoundation\Response;
9use Wallabag\ImportBundle\Form\Type\UploadImportType; 9use Wallabag\ImportBundle\Form\Type\UploadImportType;
@@ -11,20 +11,6 @@ use Wallabag\ImportBundle\Form\Type\UploadImportType;
11abstract class BrowserController extends Controller 11abstract class BrowserController extends Controller
12{ 12{
13 /** 13 /**
14 * Return the service to handle the import.
15 *
16 * @return \Wallabag\ImportBundle\Import\ImportInterface
17 */
18 abstract protected function getImportService();
19
20 /**
21 * Return the template used for the form.
22 *
23 * @return string
24 */
25 abstract protected function getImportTemplate();
26
27 /**
28 * @Route("/browser", name="import_browser") 14 * @Route("/browser", name="import_browser")
29 * 15 *
30 * @param Request $request 16 * @param Request $request
@@ -42,11 +28,11 @@ abstract class BrowserController extends Controller
42 if ($form->isSubmitted() && $form->isValid()) { 28 if ($form->isSubmitted() && $form->isValid()) {
43 $file = $form->get('file')->getData(); 29 $file = $form->get('file')->getData();
44 $markAsRead = $form->get('mark_as_read')->getData(); 30 $markAsRead = $form->get('mark_as_read')->getData();
45 $name = $this->getUser()->getId().'.json'; 31 $name = $this->getUser()->getId() . '.json';
46 32
47 if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) { 33 if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
48 $res = $wallabag 34 $res = $wallabag
49 ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name) 35 ->setFilepath($this->getParameter('wallabag_import.resource_dir') . '/' . $name)
50 ->setMarkAsRead($markAsRead) 36 ->setMarkAsRead($markAsRead)
51 ->import(); 37 ->import();
52 38
@@ -65,7 +51,7 @@ abstract class BrowserController extends Controller
65 ]); 51 ]);
66 } 52 }
67 53
68 unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name); 54 unlink($this->getParameter('wallabag_import.resource_dir') . '/' . $name);
69 } 55 }
70 56
71 $this->get('session')->getFlashBag()->add( 57 $this->get('session')->getFlashBag()->add(
@@ -74,12 +60,11 @@ abstract class BrowserController extends Controller
74 ); 60 );
75 61
76 return $this->redirect($this->generateUrl('homepage')); 62 return $this->redirect($this->generateUrl('homepage'));
77 } else { 63 }
78 $this->get('session')->getFlashBag()->add( 64 $this->get('session')->getFlashBag()->add(
79 'notice', 65 'notice',
80 'flashes.import.notice.failed_on_file' 66 'flashes.import.notice.failed_on_file'
81 ); 67 );
82 }
83 } 68 }
84 69
85 return $this->render($this->getImportTemplate(), [ 70 return $this->render($this->getImportTemplate(), [
@@ -87,4 +72,18 @@ abstract class BrowserController extends Controller
87 'import' => $wallabag, 72 'import' => $wallabag,
88 ]); 73 ]);
89 } 74 }
75
76 /**
77 * Return the service to handle the import.
78 *
79 * @return \Wallabag\ImportBundle\Import\ImportInterface
80 */
81 abstract protected function getImportService();
82
83 /**
84 * Return the template used for the form.
85 *
86 * @return string
87 */
88 abstract protected function getImportTemplate();
90} 89}
diff --git a/src/Wallabag/ImportBundle/Controller/ChromeController.php b/src/Wallabag/ImportBundle/Controller/ChromeController.php
index 454f3347..0cb418a1 100644
--- a/src/Wallabag/ImportBundle/Controller/ChromeController.php
+++ b/src/Wallabag/ImportBundle/Controller/ChromeController.php
@@ -8,6 +8,14 @@ use Symfony\Component\HttpFoundation\Request;
8class ChromeController extends BrowserController 8class ChromeController extends BrowserController
9{ 9{
10 /** 10 /**
11 * @Route("/chrome", name="import_chrome")
12 */
13 public function indexAction(Request $request)
14 {
15 return parent::indexAction($request);
16 }
17
18 /**
11 * {@inheritdoc} 19 * {@inheritdoc}
12 */ 20 */
13 protected function getImportService() 21 protected function getImportService()
@@ -30,12 +38,4 @@ class ChromeController extends BrowserController
30 { 38 {
31 return 'WallabagImportBundle:Chrome:index.html.twig'; 39 return 'WallabagImportBundle:Chrome:index.html.twig';
32 } 40 }
33
34 /**
35 * @Route("/chrome", name="import_chrome")
36 */
37 public function indexAction(Request $request)
38 {
39 return parent::indexAction($request);
40 }
41} 41}
diff --git a/src/Wallabag/ImportBundle/Controller/FirefoxController.php b/src/Wallabag/ImportBundle/Controller/FirefoxController.php
index c329b9c4..88697f9d 100644
--- a/src/Wallabag/ImportBundle/Controller/FirefoxController.php
+++ b/src/Wallabag/ImportBundle/Controller/FirefoxController.php
@@ -8,6 +8,14 @@ use Symfony\Component\HttpFoundation\Request;
8class FirefoxController extends BrowserController 8class FirefoxController extends BrowserController
9{ 9{
10 /** 10 /**
11 * @Route("/firefox", name="import_firefox")
12 */
13 public function indexAction(Request $request)
14 {
15 return parent::indexAction($request);
16 }
17
18 /**
11 * {@inheritdoc} 19 * {@inheritdoc}
12 */ 20 */
13 protected function getImportService() 21 protected function getImportService()
@@ -30,12 +38,4 @@ class FirefoxController extends BrowserController
30 { 38 {
31 return 'WallabagImportBundle:Firefox:index.html.twig'; 39 return 'WallabagImportBundle:Firefox:index.html.twig';
32 } 40 }
33
34 /**
35 * @Route("/firefox", name="import_firefox")
36 */
37 public function indexAction(Request $request)
38 {
39 return parent::indexAction($request);
40 }
41} 41}
diff --git a/src/Wallabag/ImportBundle/Controller/ImportController.php b/src/Wallabag/ImportBundle/Controller/ImportController.php
index 237c748e..7e4fd174 100644
--- a/src/Wallabag/ImportBundle/Controller/ImportController.php
+++ b/src/Wallabag/ImportBundle/Controller/ImportController.php
@@ -2,8 +2,8 @@
2 2
3namespace Wallabag\ImportBundle\Controller; 3namespace Wallabag\ImportBundle\Controller;
4 4
5use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7 7
8class ImportController extends Controller 8class ImportController extends Controller
9{ 9{
@@ -86,9 +86,9 @@ class ImportController extends Controller
86 private function getTotalMessageInRabbitQueue($importService) 86 private function getTotalMessageInRabbitQueue($importService)
87 { 87 {
88 $message = $this 88 $message = $this
89 ->get('old_sound_rabbit_mq.import_'.$importService.'_consumer') 89 ->get('old_sound_rabbit_mq.import_' . $importService . '_consumer')
90 ->getChannel() 90 ->getChannel()
91 ->basic_get('wallabag.import.'.$importService); 91 ->basic_get('wallabag.import.' . $importService);
92 92
93 if (null === $message) { 93 if (null === $message) {
94 return 0; 94 return 0;
diff --git a/src/Wallabag/ImportBundle/Controller/InstapaperController.php b/src/Wallabag/ImportBundle/Controller/InstapaperController.php
index 0251acb9..550679c3 100644
--- a/src/Wallabag/ImportBundle/Controller/InstapaperController.php
+++ b/src/Wallabag/ImportBundle/Controller/InstapaperController.php
@@ -2,8 +2,8 @@
2 2
3namespace Wallabag\ImportBundle\Controller; 3namespace Wallabag\ImportBundle\Controller;
4 4
5use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7use Symfony\Component\HttpFoundation\Request; 7use Symfony\Component\HttpFoundation\Request;
8use Wallabag\ImportBundle\Form\Type\UploadImportType; 8use Wallabag\ImportBundle\Form\Type\UploadImportType;
9 9
@@ -29,11 +29,11 @@ class InstapaperController extends Controller
29 if ($form->isSubmitted() && $form->isValid()) { 29 if ($form->isSubmitted() && $form->isValid()) {
30 $file = $form->get('file')->getData(); 30 $file = $form->get('file')->getData();
31 $markAsRead = $form->get('mark_as_read')->getData(); 31 $markAsRead = $form->get('mark_as_read')->getData();
32 $name = 'instapaper_'.$this->getUser()->getId().'.csv'; 32 $name = 'instapaper_' . $this->getUser()->getId() . '.csv';
33 33
34 if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) { 34 if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
35 $res = $instapaper 35 $res = $instapaper
36 ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name) 36 ->setFilepath($this->getParameter('wallabag_import.resource_dir') . '/' . $name)
37 ->setMarkAsRead($markAsRead) 37 ->setMarkAsRead($markAsRead)
38 ->import(); 38 ->import();
39 39
@@ -52,7 +52,7 @@ class InstapaperController extends Controller
52 ]); 52 ]);
53 } 53 }
54 54
55 unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name); 55 unlink($this->getParameter('wallabag_import.resource_dir') . '/' . $name);
56 } 56 }
57 57
58 $this->get('session')->getFlashBag()->add( 58 $this->get('session')->getFlashBag()->add(
@@ -61,12 +61,12 @@ class InstapaperController extends Controller
61 ); 61 );
62 62
63 return $this->redirect($this->generateUrl('homepage')); 63 return $this->redirect($this->generateUrl('homepage'));
64 } else {
65 $this->get('session')->getFlashBag()->add(
66 'notice',
67 'flashes.import.notice.failed_on_file'
68 );
69 } 64 }
65
66 $this->get('session')->getFlashBag()->add(
67 'notice',
68 'flashes.import.notice.failed_on_file'
69 );
70 } 70 }
71 71
72 return $this->render('WallabagImportBundle:Instapaper:index.html.twig', [ 72 return $this->render('WallabagImportBundle:Instapaper:index.html.twig', [
diff --git a/src/Wallabag/ImportBundle/Controller/PinboardController.php b/src/Wallabag/ImportBundle/Controller/PinboardController.php
index d0ad8aa8..0e57fd41 100644
--- a/src/Wallabag/ImportBundle/Controller/PinboardController.php
+++ b/src/Wallabag/ImportBundle/Controller/PinboardController.php
@@ -2,8 +2,8 @@
2 2
3namespace Wallabag\ImportBundle\Controller; 3namespace Wallabag\ImportBundle\Controller;
4 4
5use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7use Symfony\Component\HttpFoundation\Request; 7use Symfony\Component\HttpFoundation\Request;
8use Wallabag\ImportBundle\Form\Type\UploadImportType; 8use Wallabag\ImportBundle\Form\Type\UploadImportType;
9 9
@@ -29,11 +29,11 @@ class PinboardController extends Controller
29 if ($form->isSubmitted() && $form->isValid()) { 29 if ($form->isSubmitted() && $form->isValid()) {
30 $file = $form->get('file')->getData(); 30 $file = $form->get('file')->getData();
31 $markAsRead = $form->get('mark_as_read')->getData(); 31 $markAsRead = $form->get('mark_as_read')->getData();
32 $name = 'pinboard_'.$this->getUser()->getId().'.json'; 32 $name = 'pinboard_' . $this->getUser()->getId() . '.json';
33 33
34 if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) { 34 if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
35 $res = $pinboard 35 $res = $pinboard
36 ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name) 36 ->setFilepath($this->getParameter('wallabag_import.resource_dir') . '/' . $name)
37 ->setMarkAsRead($markAsRead) 37 ->setMarkAsRead($markAsRead)
38 ->import(); 38 ->import();
39 39
@@ -52,7 +52,7 @@ class PinboardController extends Controller
52 ]); 52 ]);
53 } 53 }
54 54
55 unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name); 55 unlink($this->getParameter('wallabag_import.resource_dir') . '/' . $name);
56 } 56 }
57 57
58 $this->get('session')->getFlashBag()->add( 58 $this->get('session')->getFlashBag()->add(
@@ -61,12 +61,12 @@ class PinboardController extends Controller
61 ); 61 );
62 62
63 return $this->redirect($this->generateUrl('homepage')); 63 return $this->redirect($this->generateUrl('homepage'));
64 } else {
65 $this->get('session')->getFlashBag()->add(
66 'notice',
67 'flashes.import.notice.failed_on_file'
68 );
69 } 64 }
65
66 $this->get('session')->getFlashBag()->add(
67 'notice',
68 'flashes.import.notice.failed_on_file'
69 );
70 } 70 }
71 71
72 return $this->render('WallabagImportBundle:Pinboard:index.html.twig', [ 72 return $this->render('WallabagImportBundle:Pinboard:index.html.twig', [
diff --git a/src/Wallabag/ImportBundle/Controller/PocketController.php b/src/Wallabag/ImportBundle/Controller/PocketController.php
index 56be5cbf..9f28819a 100644
--- a/src/Wallabag/ImportBundle/Controller/PocketController.php
+++ b/src/Wallabag/ImportBundle/Controller/PocketController.php
@@ -2,34 +2,15 @@
2 2
3namespace Wallabag\ImportBundle\Controller; 3namespace Wallabag\ImportBundle\Controller;
4 4
5use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
7use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
8use Symfony\Component\HttpFoundation\Request; 6use Symfony\Bundle\FrameworkBundle\Controller\Controller;
9use Symfony\Component\Form\Extension\Core\Type\CheckboxType; 7use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
8use Symfony\Component\HttpFoundation\Request;
9use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
10 10
11class PocketController extends Controller 11class PocketController extends Controller
12{ 12{
13 /** 13 /**
14 * Return Pocket Import Service with or without RabbitMQ enabled.
15 *
16 * @return \Wallabag\ImportBundle\Import\PocketImport
17 */
18 private function getPocketImportService()
19 {
20 $pocket = $this->get('wallabag_import.pocket.import');
21 $pocket->setUser($this->getUser());
22
23 if ($this->get('craue_config')->get('import_with_rabbitmq')) {
24 $pocket->setProducer($this->get('old_sound_rabbit_mq.import_pocket_producer'));
25 } elseif ($this->get('craue_config')->get('import_with_redis')) {
26 $pocket->setProducer($this->get('wallabag_import.producer.redis.pocket'));
27 }
28
29 return $pocket;
30 }
31
32 /**
33 * @Route("/pocket", name="import_pocket") 14 * @Route("/pocket", name="import_pocket")
34 */ 15 */
35 public function indexAction() 16 public function indexAction()
@@ -70,7 +51,7 @@ class PocketController extends Controller
70 $this->get('session')->set('mark_as_read', $request->request->get('form')['mark_as_read']); 51 $this->get('session')->set('mark_as_read', $request->request->get('form')['mark_as_read']);
71 52
72 return $this->redirect( 53 return $this->redirect(
73 'https://getpocket.com/auth/authorize?request_token='.$requestToken.'&redirect_uri='.$this->generateUrl('import_pocket_callback', [], UrlGeneratorInterface::ABSOLUTE_URL), 54 'https://getpocket.com/auth/authorize?request_token=' . $requestToken . '&redirect_uri=' . $this->generateUrl('import_pocket_callback', [], UrlGeneratorInterface::ABSOLUTE_URL),
74 301 55 301
75 ); 56 );
76 } 57 }
@@ -117,4 +98,23 @@ class PocketController extends Controller
117 98
118 return $this->redirect($this->generateUrl('homepage')); 99 return $this->redirect($this->generateUrl('homepage'));
119 } 100 }
101
102 /**
103 * Return Pocket Import Service with or without RabbitMQ enabled.
104 *
105 * @return \Wallabag\ImportBundle\Import\PocketImport
106 */
107 private function getPocketImportService()
108 {
109 $pocket = $this->get('wallabag_import.pocket.import');
110 $pocket->setUser($this->getUser());
111
112 if ($this->get('craue_config')->get('import_with_rabbitmq')) {
113 $pocket->setProducer($this->get('old_sound_rabbit_mq.import_pocket_producer'));
114 } elseif ($this->get('craue_config')->get('import_with_redis')) {
115 $pocket->setProducer($this->get('wallabag_import.producer.redis.pocket'));
116 }
117
118 return $pocket;
119 }
120} 120}
diff --git a/src/Wallabag/ImportBundle/Controller/ReadabilityController.php b/src/Wallabag/ImportBundle/Controller/ReadabilityController.php
index aa732ddd..59de24cb 100644
--- a/src/Wallabag/ImportBundle/Controller/ReadabilityController.php
+++ b/src/Wallabag/ImportBundle/Controller/ReadabilityController.php
@@ -2,8 +2,8 @@
2 2
3namespace Wallabag\ImportBundle\Controller; 3namespace Wallabag\ImportBundle\Controller;
4 4
5use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 5use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
6use Symfony\Bundle\FrameworkBundle\Controller\Controller;
7use Symfony\Component\HttpFoundation\Request; 7use Symfony\Component\HttpFoundation\Request;
8use Wallabag\ImportBundle\Form\Type\UploadImportType; 8use Wallabag\ImportBundle\Form\Type\UploadImportType;
9 9
@@ -29,11 +29,11 @@ class ReadabilityController extends Controller
29 if ($form->isSubmitted() && $form->isValid()) { 29 if ($form->isSubmitted() && $form->isValid()) {
30 $file = $form->get('file')->getData(); 30 $file = $form->get('file')->getData();
31 $markAsRead = $form->get('mark_as_read')->getData(); 31 $markAsRead = $form->get('mark_as_read')->getData();
32 $name = 'readability_'.$this->getUser()->getId().'.json'; 32 $name = 'readability_' . $this->getUser()->getId() . '.json';
33 33
34 if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) { 34 if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
35 $res = $readability 35 $res = $readability
36 ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name) 36 ->setFilepath($this->getParameter('wallabag_import.resource_dir') . '/' . $name)
37 ->setMarkAsRead($markAsRead) 37 ->setMarkAsRead($markAsRead)
38 ->import(); 38 ->import();
39 39
@@ -52,7 +52,7 @@ class ReadabilityController extends Controller
52 ]); 52 ]);
53 } 53 }
54 54
55 unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name); 55 unlink($this->getParameter('wallabag_import.resource_dir') . '/' . $name);
56 } 56 }
57 57
58 $this->get('session')->getFlashBag()->add( 58 $this->get('session')->getFlashBag()->add(
@@ -61,12 +61,12 @@ class ReadabilityController extends Controller
61 ); 61 );
62 62
63 return $this->redirect($this->generateUrl('homepage')); 63 return $this->redirect($this->generateUrl('homepage'));
64 } else {
65 $this->get('session')->getFlashBag()->add(
66 'notice',
67 'flashes.import.notice.failed_on_file'
68 );
69 } 64 }
65
66 $this->get('session')->getFlashBag()->add(
67 'notice',
68 'flashes.import.notice.failed_on_file'
69 );
70 } 70 }
71 71
72 return $this->render('WallabagImportBundle:Readability:index.html.twig', [ 72 return $this->render('WallabagImportBundle:Readability:index.html.twig', [
diff --git a/src/Wallabag/ImportBundle/Controller/WallabagController.php b/src/Wallabag/ImportBundle/Controller/WallabagController.php
index e81c1ca9..7b61805b 100644
--- a/src/Wallabag/ImportBundle/Controller/WallabagController.php
+++ b/src/Wallabag/ImportBundle/Controller/WallabagController.php
@@ -12,20 +12,6 @@ use Wallabag\ImportBundle\Form\Type\UploadImportType;
12abstract class WallabagController extends Controller 12abstract class WallabagController extends Controller
13{ 13{
14 /** 14 /**
15 * Return the service to handle the import.
16 *
17 * @return \Wallabag\ImportBundle\Import\ImportInterface
18 */
19 abstract protected function getImportService();
20
21 /**
22 * Return the template used for the form.
23 *
24 * @return string
25 */
26 abstract protected function getImportTemplate();
27
28 /**
29 * Handle import request. 15 * Handle import request.
30 * 16 *
31 * @param Request $request 17 * @param Request $request
@@ -43,11 +29,11 @@ abstract class WallabagController extends Controller
43 if ($form->isSubmitted() && $form->isValid()) { 29 if ($form->isSubmitted() && $form->isValid()) {
44 $file = $form->get('file')->getData(); 30 $file = $form->get('file')->getData();
45 $markAsRead = $form->get('mark_as_read')->getData(); 31 $markAsRead = $form->get('mark_as_read')->getData();
46 $name = $this->getUser()->getId().'.json'; 32 $name = $this->getUser()->getId() . '.json';
47 33
48 if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes')) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) { 34 if (null !== $file && in_array($file->getClientMimeType(), $this->getParameter('wallabag_import.allow_mimetypes'), true) && $file->move($this->getParameter('wallabag_import.resource_dir'), $name)) {
49 $res = $wallabag 35 $res = $wallabag
50 ->setFilepath($this->getParameter('wallabag_import.resource_dir').'/'.$name) 36 ->setFilepath($this->getParameter('wallabag_import.resource_dir') . '/' . $name)
51 ->setMarkAsRead($markAsRead) 37 ->setMarkAsRead($markAsRead)
52 ->import(); 38 ->import();
53 39
@@ -66,7 +52,7 @@ abstract class WallabagController extends Controller
66 ]); 52 ]);
67 } 53 }
68 54
69 unlink($this->getParameter('wallabag_import.resource_dir').'/'.$name); 55 unlink($this->getParameter('wallabag_import.resource_dir') . '/' . $name);
70 } 56 }
71 57
72 $this->get('session')->getFlashBag()->add( 58 $this->get('session')->getFlashBag()->add(
@@ -75,12 +61,12 @@ abstract class WallabagController extends Controller
75 ); 61 );
76 62
77 return $this->redirect($this->generateUrl('homepage')); 63 return $this->redirect($this->generateUrl('homepage'));
78 } else {
79 $this->get('session')->getFlashBag()->add(
80 'notice',
81 'flashes.import.notice.failed_on_file'
82 );
83 } 64 }
65
66 $this->get('session')->getFlashBag()->add(
67 'notice',
68 'flashes.import.notice.failed_on_file'
69 );
84 } 70 }
85 71
86 return $this->render($this->getImportTemplate(), [ 72 return $this->render($this->getImportTemplate(), [
@@ -88,4 +74,18 @@ abstract class WallabagController extends Controller
88 'import' => $wallabag, 74 'import' => $wallabag,
89 ]); 75 ]);
90 } 76 }
77
78 /**
79 * Return the service to handle the import.
80 *
81 * @return \Wallabag\ImportBundle\Import\ImportInterface
82 */
83 abstract protected function getImportService();
84
85 /**
86 * Return the template used for the form.
87 *
88 * @return string
89 */
90 abstract protected function getImportTemplate();
91} 91}
diff --git a/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php b/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php
index 312c7a35..d700d8a8 100644
--- a/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php
+++ b/src/Wallabag/ImportBundle/Controller/WallabagV1Controller.php
@@ -8,6 +8,14 @@ use Symfony\Component\HttpFoundation\Request;
8class WallabagV1Controller extends WallabagController 8class WallabagV1Controller extends WallabagController
9{ 9{
10 /** 10 /**
11 * @Route("/wallabag-v1", name="import_wallabag_v1")
12 */
13 public function indexAction(Request $request)
14 {
15 return parent::indexAction($request);
16 }
17
18 /**
11 * {@inheritdoc} 19 * {@inheritdoc}
12 */ 20 */
13 protected function getImportService() 21 protected function getImportService()
@@ -30,12 +38,4 @@ class WallabagV1Controller extends WallabagController
30 { 38 {
31 return 'WallabagImportBundle:WallabagV1:index.html.twig'; 39 return 'WallabagImportBundle:WallabagV1:index.html.twig';
32 } 40 }
33
34 /**
35 * @Route("/wallabag-v1", name="import_wallabag_v1")
36 */
37 public function indexAction(Request $request)
38 {
39 return parent::indexAction($request);
40 }
41} 41}
diff --git a/src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php b/src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php
index 45211fe6..ab26400c 100644
--- a/src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php
+++ b/src/Wallabag/ImportBundle/Controller/WallabagV2Controller.php
@@ -8,6 +8,14 @@ use Symfony\Component\HttpFoundation\Request;
8class WallabagV2Controller extends WallabagController 8class WallabagV2Controller extends WallabagController
9{ 9{
10 /** 10 /**
11 * @Route("/wallabag-v2", name="import_wallabag_v2")
12 */
13 public function indexAction(Request $request)
14 {
15 return parent::indexAction($request);
16 }
17
18 /**
11 * {@inheritdoc} 19 * {@inheritdoc}
12 */ 20 */
13 protected function getImportService() 21 protected function getImportService()
@@ -30,12 +38,4 @@ class WallabagV2Controller extends WallabagController
30 { 38 {
31 return 'WallabagImportBundle:WallabagV2:index.html.twig'; 39 return 'WallabagImportBundle:WallabagV2:index.html.twig';
32 } 40 }
33
34 /**
35 * @Route("/wallabag-v2", name="import_wallabag_v2")
36 */
37 public function indexAction(Request $request)
38 {
39 return parent::indexAction($request);
40 }
41} 41}
diff --git a/src/Wallabag/ImportBundle/DependencyInjection/WallabagImportExtension.php b/src/Wallabag/ImportBundle/DependencyInjection/WallabagImportExtension.php
index 3f23c36b..cab70297 100644
--- a/src/Wallabag/ImportBundle/DependencyInjection/WallabagImportExtension.php
+++ b/src/Wallabag/ImportBundle/DependencyInjection/WallabagImportExtension.php
@@ -2,10 +2,10 @@
2 2
3namespace Wallabag\ImportBundle\DependencyInjection; 3namespace Wallabag\ImportBundle\DependencyInjection;
4 4
5use Symfony\Component\DependencyInjection\ContainerBuilder;
6use Symfony\Component\Config\FileLocator; 5use Symfony\Component\Config\FileLocator;
7use Symfony\Component\HttpKernel\DependencyInjection\Extension; 6use Symfony\Component\DependencyInjection\ContainerBuilder;
8use Symfony\Component\DependencyInjection\Loader; 7use Symfony\Component\DependencyInjection\Loader;
8use Symfony\Component\HttpKernel\DependencyInjection\Extension;
9 9
10class WallabagImportExtension extends Extension 10class WallabagImportExtension extends Extension
11{ 11{
@@ -16,7 +16,7 @@ class WallabagImportExtension extends Extension
16 $container->setParameter('wallabag_import.allow_mimetypes', $config['allow_mimetypes']); 16 $container->setParameter('wallabag_import.allow_mimetypes', $config['allow_mimetypes']);
17 $container->setParameter('wallabag_import.resource_dir', $config['resource_dir']); 17 $container->setParameter('wallabag_import.resource_dir', $config['resource_dir']);
18 18
19 $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); 19 $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
20 $loader->load('services.yml'); 20 $loader->load('services.yml');
21 } 21 }
22 22
diff --git a/src/Wallabag/ImportBundle/Form/Type/UploadImportType.php b/src/Wallabag/ImportBundle/Form/Type/UploadImportType.php
index f50424c1..c50ef8c9 100644
--- a/src/Wallabag/ImportBundle/Form/Type/UploadImportType.php
+++ b/src/Wallabag/ImportBundle/Form/Type/UploadImportType.php
@@ -3,10 +3,10 @@
3namespace Wallabag\ImportBundle\Form\Type; 3namespace Wallabag\ImportBundle\Form\Type;
4 4
5use Symfony\Component\Form\AbstractType; 5use Symfony\Component\Form\AbstractType;
6use Symfony\Component\Form\FormBuilderInterface;
7use Symfony\Component\Form\Extension\Core\Type\SubmitType;
8use Symfony\Component\Form\Extension\Core\Type\FileType;
9use Symfony\Component\Form\Extension\Core\Type\CheckboxType; 6use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
7use Symfony\Component\Form\Extension\Core\Type\FileType;
8use Symfony\Component\Form\Extension\Core\Type\SubmitType;
9use Symfony\Component\Form\FormBuilderInterface;
10 10
11class UploadImportType extends AbstractType 11class UploadImportType extends AbstractType
12{ 12{
diff --git a/src/Wallabag/ImportBundle/Import/AbstractImport.php b/src/Wallabag/ImportBundle/Import/AbstractImport.php
index 9b624296..cb46db09 100644
--- a/src/Wallabag/ImportBundle/Import/AbstractImport.php
+++ b/src/Wallabag/ImportBundle/Import/AbstractImport.php
@@ -2,17 +2,17 @@
2 2
3namespace Wallabag\ImportBundle\Import; 3namespace Wallabag\ImportBundle\Import;
4 4
5use Doctrine\ORM\EntityManager;
6use OldSound\RabbitMqBundle\RabbitMq\ProducerInterface;
5use Psr\Log\LoggerInterface; 7use Psr\Log\LoggerInterface;
6use Psr\Log\NullLogger; 8use Psr\Log\NullLogger;
7use Doctrine\ORM\EntityManager; 9use Symfony\Component\EventDispatcher\EventDispatcherInterface;
8use Wallabag\CoreBundle\Helper\ContentProxy;
9use Wallabag\CoreBundle\Entity\Entry; 10use Wallabag\CoreBundle\Entity\Entry;
10use Wallabag\CoreBundle\Entity\Tag; 11use Wallabag\CoreBundle\Entity\Tag;
12use Wallabag\CoreBundle\Event\EntrySavedEvent;
13use Wallabag\CoreBundle\Helper\ContentProxy;
11use Wallabag\CoreBundle\Helper\TagsAssigner; 14use Wallabag\CoreBundle\Helper\TagsAssigner;
12use Wallabag\UserBundle\Entity\User; 15use Wallabag\UserBundle\Entity\User;
13use OldSound\RabbitMqBundle\RabbitMq\ProducerInterface;
14use Symfony\Component\EventDispatcher\EventDispatcherInterface;
15use Wallabag\CoreBundle\Event\EntrySavedEvent;
16 16
17abstract class AbstractImport implements ImportInterface 17abstract class AbstractImport implements ImportInterface
18{ 18{
@@ -98,6 +98,27 @@ abstract class AbstractImport implements ImportInterface
98 } 98 }
99 99
100 /** 100 /**
101 * {@inheritdoc}
102 */
103 public function getSummary()
104 {
105 return [
106 'skipped' => $this->skippedEntries,
107 'imported' => $this->importedEntries,
108 'queued' => $this->queuedEntries,
109 ];
110 }
111
112 /**
113 * Parse one entry.
114 *
115 * @param array $importedEntry
116 *
117 * @return Entry
118 */
119 abstract public function parseEntry(array $importedEntry);
120
121 /**
101 * Fetch content from the ContentProxy (using graby). 122 * Fetch content from the ContentProxy (using graby).
102 * If it fails return the given entry to be saved in all case (to avoid user to loose the content). 123 * If it fails return the given entry to be saved in all case (to avoid user to loose the content).
103 * 124 *
@@ -196,27 +217,6 @@ abstract class AbstractImport implements ImportInterface
196 } 217 }
197 218
198 /** 219 /**
199 * {@inheritdoc}
200 */
201 public function getSummary()
202 {
203 return [
204 'skipped' => $this->skippedEntries,
205 'imported' => $this->importedEntries,
206 'queued' => $this->queuedEntries,
207 ];
208 }
209
210 /**
211 * Parse one entry.
212 *
213 * @param array $importedEntry
214 *
215 * @return Entry
216 */
217 abstract public function parseEntry(array $importedEntry);
218
219 /**
220 * Set current imported entry to archived / read. 220 * Set current imported entry to archived / read.
221 * Implementation is different accross all imports. 221 * Implementation is different accross all imports.
222 * 222 *
diff --git a/src/Wallabag/ImportBundle/Import/BrowserImport.php b/src/Wallabag/ImportBundle/Import/BrowserImport.php
index 71e65e59..f1195824 100644
--- a/src/Wallabag/ImportBundle/Import/BrowserImport.php
+++ b/src/Wallabag/ImportBundle/Import/BrowserImport.php
@@ -3,8 +3,8 @@
3namespace Wallabag\ImportBundle\Import; 3namespace Wallabag\ImportBundle\Import;
4 4
5use Wallabag\CoreBundle\Entity\Entry; 5use Wallabag\CoreBundle\Entity\Entry;
6use Wallabag\UserBundle\Entity\User;
7use Wallabag\CoreBundle\Event\EntrySavedEvent; 6use Wallabag\CoreBundle\Event\EntrySavedEvent;
7use Wallabag\UserBundle\Entity\User;
8 8
9abstract class BrowserImport extends AbstractImport 9abstract class BrowserImport extends AbstractImport
10{ 10{
@@ -74,6 +74,80 @@ abstract class BrowserImport extends AbstractImport
74 } 74 }
75 75
76 /** 76 /**
77 * {@inheritdoc}
78 */
79 public function parseEntry(array $importedEntry)
80 {
81 if ((!array_key_exists('guid', $importedEntry) || (!array_key_exists('id', $importedEntry))) && is_array(reset($importedEntry))) {
82 if ($this->producer) {
83 $this->parseEntriesForProducer($importedEntry);
84
85 return;
86 }
87
88 $this->parseEntries($importedEntry);
89
90 return;
91 }
92
93 if (array_key_exists('children', $importedEntry)) {
94 if ($this->producer) {
95 $this->parseEntriesForProducer($importedEntry['children']);
96
97 return;
98 }
99
100 $this->parseEntries($importedEntry['children']);
101
102 return;
103 }
104
105 if (!array_key_exists('uri', $importedEntry) && !array_key_exists('url', $importedEntry)) {
106 return;
107 }
108
109 $url = array_key_exists('uri', $importedEntry) ? $importedEntry['uri'] : $importedEntry['url'];
110
111 $existingEntry = $this->em
112 ->getRepository('WallabagCoreBundle:Entry')
113 ->findByUrlAndUserId($url, $this->user->getId());
114
115 if (false !== $existingEntry) {
116 ++$this->skippedEntries;
117
118 return;
119 }
120
121 $data = $this->prepareEntry($importedEntry);
122
123 $entry = new Entry($this->user);
124 $entry->setUrl($data['url']);
125 $entry->setTitle($data['title']);
126
127 // update entry with content (in case fetching failed, the given entry will be return)
128 $this->fetchContent($entry, $data['url'], $data);
129
130 if (array_key_exists('tags', $data)) {
131 $this->tagsAssigner->assignTagsToEntry(
132 $entry,
133 $data['tags']
134 );
135 }
136
137 $entry->setArchived($data['is_archived']);
138
139 if (!empty($data['created_at'])) {
140 $dt = new \DateTime();
141 $entry->setCreatedAt($dt->setTimestamp($data['created_at']));
142 }
143
144 $this->em->persist($entry);
145 ++$this->importedEntries;
146
147 return $entry;
148 }
149
150 /**
77 * Parse and insert all given entries. 151 * Parse and insert all given entries.
78 * 152 *
79 * @param $entries 153 * @param $entries
@@ -152,80 +226,6 @@ abstract class BrowserImport extends AbstractImport
152 /** 226 /**
153 * {@inheritdoc} 227 * {@inheritdoc}
154 */ 228 */
155 public function parseEntry(array $importedEntry)
156 {
157 if ((!array_key_exists('guid', $importedEntry) || (!array_key_exists('id', $importedEntry))) && is_array(reset($importedEntry))) {
158 if ($this->producer) {
159 $this->parseEntriesForProducer($importedEntry);
160
161 return;
162 }
163
164 $this->parseEntries($importedEntry);
165
166 return;
167 }
168
169 if (array_key_exists('children', $importedEntry)) {
170 if ($this->producer) {
171 $this->parseEntriesForProducer($importedEntry['children']);
172
173 return;
174 }
175
176 $this->parseEntries($importedEntry['children']);
177
178 return;
179 }
180
181 if (!array_key_exists('uri', $importedEntry) && !array_key_exists('url', $importedEntry)) {
182 return;
183 }
184
185 $url = array_key_exists('uri', $importedEntry) ? $importedEntry['uri'] : $importedEntry['url'];
186
187 $existingEntry = $this->em
188 ->getRepository('WallabagCoreBundle:Entry')
189 ->findByUrlAndUserId($url, $this->user->getId());
190
191 if (false !== $existingEntry) {
192 ++$this->skippedEntries;
193
194 return;
195 }
196
197 $data = $this->prepareEntry($importedEntry);
198
199 $entry = new Entry($this->user);
200 $entry->setUrl($data['url']);
201 $entry->setTitle($data['title']);
202
203 // update entry with content (in case fetching failed, the given entry will be return)
204 $this->fetchContent($entry, $data['url'], $data);
205
206 if (array_key_exists('tags', $data)) {
207 $this->tagsAssigner->assignTagsToEntry(
208 $entry,
209 $data['tags']
210 );
211 }
212
213 $entry->setArchived($data['is_archived']);
214
215 if (!empty($data['created_at'])) {
216 $dt = new \DateTime();
217 $entry->setCreatedAt($dt->setTimestamp($data['created_at']));
218 }
219
220 $this->em->persist($entry);
221 ++$this->importedEntries;
222
223 return $entry;
224 }
225
226 /**
227 * {@inheritdoc}
228 */
229 protected function setEntryAsRead(array $importedEntry) 229 protected function setEntryAsRead(array $importedEntry)
230 { 230 {
231 $importedEntry['is_archived'] = 1; 231 $importedEntry['is_archived'] = 1;
diff --git a/src/Wallabag/ImportBundle/Import/ChromeImport.php b/src/Wallabag/ImportBundle/Import/ChromeImport.php
index 2667890f..e3ba636a 100644
--- a/src/Wallabag/ImportBundle/Import/ChromeImport.php
+++ b/src/Wallabag/ImportBundle/Import/ChromeImport.php
@@ -45,7 +45,7 @@ class ChromeImport extends BrowserImport
45 'created_at' => substr($entry['date_added'], 0, 10), 45 'created_at' => substr($entry['date_added'], 0, 10),
46 ]; 46 ];
47 47
48 if (array_key_exists('tags', $entry) && $entry['tags'] != '') { 48 if (array_key_exists('tags', $entry) && $entry['tags'] !== '') {
49 $data['tags'] = $entry['tags']; 49 $data['tags'] = $entry['tags'];
50 } 50 }
51 51
diff --git a/src/Wallabag/ImportBundle/Import/FirefoxImport.php b/src/Wallabag/ImportBundle/Import/FirefoxImport.php
index c50c69b3..c18e7e93 100644
--- a/src/Wallabag/ImportBundle/Import/FirefoxImport.php
+++ b/src/Wallabag/ImportBundle/Import/FirefoxImport.php
@@ -45,7 +45,7 @@ class FirefoxImport extends BrowserImport
45 'created_at' => substr($entry['dateAdded'], 0, 10), 45 'created_at' => substr($entry['dateAdded'], 0, 10),
46 ]; 46 ];
47 47
48 if (array_key_exists('tags', $entry) && $entry['tags'] != '') { 48 if (array_key_exists('tags', $entry) && $entry['tags'] !== '') {
49 $data['tags'] = $entry['tags']; 49 $data['tags'] = $entry['tags'];
50 } 50 }
51 51
diff --git a/src/Wallabag/ImportBundle/Import/ImportCompilerPass.php b/src/Wallabag/ImportBundle/Import/ImportCompilerPass.php
index a363a566..d7df0a83 100644
--- a/src/Wallabag/ImportBundle/Import/ImportCompilerPass.php
+++ b/src/Wallabag/ImportBundle/Import/ImportCompilerPass.php
@@ -2,8 +2,8 @@
2 2
3namespace Wallabag\ImportBundle\Import; 3namespace Wallabag\ImportBundle\Import;
4 4
5use Symfony\Component\DependencyInjection\ContainerBuilder;
6use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; 5use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
6use Symfony\Component\DependencyInjection\ContainerBuilder;
7use Symfony\Component\DependencyInjection\Reference; 7use Symfony\Component\DependencyInjection\Reference;
8 8
9class ImportCompilerPass implements CompilerPassInterface 9class ImportCompilerPass implements CompilerPassInterface
diff --git a/src/Wallabag/ImportBundle/Import/InstapaperImport.php b/src/Wallabag/ImportBundle/Import/InstapaperImport.php
index 3aa12f6f..7d70154a 100644
--- a/src/Wallabag/ImportBundle/Import/InstapaperImport.php
+++ b/src/Wallabag/ImportBundle/Import/InstapaperImport.php
@@ -72,7 +72,7 @@ class InstapaperImport extends AbstractImport
72 // BUT it can also be the status (since status = folder in Instapaper) 72 // BUT it can also be the status (since status = folder in Instapaper)
73 // and we don't want archive, unread & starred to become a tag 73 // and we don't want archive, unread & starred to become a tag
74 $tags = null; 74 $tags = null;
75 if (false === in_array($data[3], ['Archive', 'Unread', 'Starred'])) { 75 if (false === in_array($data[3], ['Archive', 'Unread', 'Starred'], true)) {
76 $tags = [$data[3]]; 76 $tags = [$data[3]];
77 } 77 }
78 78
diff --git a/src/Wallabag/ImportBundle/Import/PocketImport.php b/src/Wallabag/ImportBundle/Import/PocketImport.php
index c1d5b6da..7d38826b 100644
--- a/src/Wallabag/ImportBundle/Import/PocketImport.php
+++ b/src/Wallabag/ImportBundle/Import/PocketImport.php
@@ -8,11 +8,10 @@ use Wallabag\CoreBundle\Entity\Entry;
8 8
9class PocketImport extends AbstractImport 9class PocketImport extends AbstractImport
10{ 10{
11 const NB_ELEMENTS = 5000;
11 private $client; 12 private $client;
12 private $accessToken; 13 private $accessToken;
13 14
14 const NB_ELEMENTS = 5000;
15
16 /** 15 /**
17 * Only used for test purpose. 16 * Only used for test purpose.
18 * 17 *
@@ -176,7 +175,7 @@ class PocketImport extends AbstractImport
176 */ 175 */
177 public function parseEntry(array $importedEntry) 176 public function parseEntry(array $importedEntry)
178 { 177 {
179 $url = isset($importedEntry['resolved_url']) && $importedEntry['resolved_url'] != '' ? $importedEntry['resolved_url'] : $importedEntry['given_url']; 178 $url = isset($importedEntry['resolved_url']) && $importedEntry['resolved_url'] !== '' ? $importedEntry['resolved_url'] : $importedEntry['given_url'];
180 179
181 $existingEntry = $this->em 180 $existingEntry = $this->em
182 ->getRepository('WallabagCoreBundle:Entry') 181 ->getRepository('WallabagCoreBundle:Entry')
@@ -195,15 +194,15 @@ class PocketImport extends AbstractImport
195 $this->fetchContent($entry, $url); 194 $this->fetchContent($entry, $url);
196 195
197 // 0, 1, 2 - 1 if the item is archived - 2 if the item should be deleted 196 // 0, 1, 2 - 1 if the item is archived - 2 if the item should be deleted
198 $entry->setArchived($importedEntry['status'] == 1 || $this->markAsRead); 197 $entry->setArchived($importedEntry['status'] === 1 || $this->markAsRead);
199 198
200 // 0 or 1 - 1 If the item is starred 199 // 0 or 1 - 1 If the item is starred
201 $entry->setStarred($importedEntry['favorite'] == 1); 200 $entry->setStarred($importedEntry['favorite'] === 1);
202 201
203 $title = 'Untitled'; 202 $title = 'Untitled';
204 if (isset($importedEntry['resolved_title']) && $importedEntry['resolved_title'] != '') { 203 if (isset($importedEntry['resolved_title']) && $importedEntry['resolved_title'] !== '') {
205 $title = $importedEntry['resolved_title']; 204 $title = $importedEntry['resolved_title'];
206 } elseif (isset($importedEntry['given_title']) && $importedEntry['given_title'] != '') { 205 } elseif (isset($importedEntry['given_title']) && $importedEntry['given_title'] !== '') {
207 $title = $importedEntry['given_title']; 206 $title = $importedEntry['given_title'];
208 } 207 }
209 208
diff --git a/src/Wallabag/ImportBundle/Import/WallabagV1Import.php b/src/Wallabag/ImportBundle/Import/WallabagV1Import.php
index 1f0df646..d585d44d 100644
--- a/src/Wallabag/ImportBundle/Import/WallabagV1Import.php
+++ b/src/Wallabag/ImportBundle/Import/WallabagV1Import.php
@@ -56,12 +56,12 @@ class WallabagV1Import extends WallabagImport
56 56
57 // In case of a bad fetch in v1, replace title and content with v2 error strings 57 // In case of a bad fetch in v1, replace title and content with v2 error strings
58 // If fetching fails again, they will get this instead of the v1 strings 58 // If fetching fails again, they will get this instead of the v1 strings
59 if (in_array($entry['title'], $this->untitled)) { 59 if (in_array($entry['title'], $this->untitled, true)) {
60 $data['title'] = $this->fetchingErrorMessageTitle; 60 $data['title'] = $this->fetchingErrorMessageTitle;
61 $data['html'] = $this->fetchingErrorMessage; 61 $data['html'] = $this->fetchingErrorMessage;
62 } 62 }
63 63
64 if (array_key_exists('tags', $entry) && $entry['tags'] != '') { 64 if (array_key_exists('tags', $entry) && $entry['tags'] !== '') {
65 $data['tags'] = $entry['tags']; 65 $data['tags'] = $entry['tags'];
66 } 66 }
67 67
diff --git a/src/Wallabag/ImportBundle/Redis/Producer.php b/src/Wallabag/ImportBundle/Redis/Producer.php
index fedc3e57..c77b5174 100644
--- a/src/Wallabag/ImportBundle/Redis/Producer.php
+++ b/src/Wallabag/ImportBundle/Redis/Producer.php
@@ -29,7 +29,7 @@ class Producer implements ProducerInterface
29 * @param string $routingKey NOT USED 29 * @param string $routingKey NOT USED
30 * @param array $additionalProperties NOT USED 30 * @param array $additionalProperties NOT USED
31 */ 31 */
32 public function publish($msgBody, $routingKey = '', $additionalProperties = array()) 32 public function publish($msgBody, $routingKey = '', $additionalProperties = [])
33 { 33 {
34 $this->queue->sendJob($msgBody); 34 $this->queue->sendJob($msgBody);
35 } 35 }
diff --git a/src/Wallabag/ImportBundle/WallabagImportBundle.php b/src/Wallabag/ImportBundle/WallabagImportBundle.php
index a5ddc1b4..98c2f97b 100644
--- a/src/Wallabag/ImportBundle/WallabagImportBundle.php
+++ b/src/Wallabag/ImportBundle/WallabagImportBundle.php
@@ -2,8 +2,8 @@
2 2
3namespace Wallabag\ImportBundle; 3namespace Wallabag\ImportBundle;
4 4
5use Symfony\Component\HttpKernel\Bundle\Bundle;
6use Symfony\Component\DependencyInjection\ContainerBuilder; 5use Symfony\Component\DependencyInjection\ContainerBuilder;
6use Symfony\Component\HttpKernel\Bundle\Bundle;
7use Wallabag\ImportBundle\Import\ImportCompilerPass; 7use Wallabag\ImportBundle\Import\ImportCompilerPass;
8 8
9class WallabagImportBundle extends Bundle 9class WallabagImportBundle extends Bundle
diff --git a/src/Wallabag/UserBundle/Controller/ManageController.php b/src/Wallabag/UserBundle/Controller/ManageController.php
index 084f2c67..f3de656f 100644
--- a/src/Wallabag/UserBundle/Controller/ManageController.php
+++ b/src/Wallabag/UserBundle/Controller/ManageController.php
@@ -7,10 +7,10 @@ use FOS\UserBundle\FOSUserEvents;
7use Pagerfanta\Adapter\DoctrineORMAdapter; 7use Pagerfanta\Adapter\DoctrineORMAdapter;
8use Pagerfanta\Exception\OutOfRangeCurrentPageException; 8use Pagerfanta\Exception\OutOfRangeCurrentPageException;
9use Pagerfanta\Pagerfanta; 9use Pagerfanta\Pagerfanta;
10use Symfony\Component\HttpFoundation\Request;
11use Symfony\Bundle\FrameworkBundle\Controller\Controller;
12use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method; 10use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
13use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; 11use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
12use Symfony\Bundle\FrameworkBundle\Controller\Controller;
13use Symfony\Component\HttpFoundation\Request;
14use Wallabag\UserBundle\Entity\User; 14use Wallabag\UserBundle\Entity\User;
15use Wallabag\UserBundle\Form\SearchUserType; 15use Wallabag\UserBundle\Form\SearchUserType;
16 16
@@ -48,13 +48,13 @@ class ManageController extends Controller
48 $this->get('translator')->trans('flashes.user.notice.added', ['%username%' => $user->getUsername()]) 48 $this->get('translator')->trans('flashes.user.notice.added', ['%username%' => $user->getUsername()])
49 ); 49 );
50 50
51 return $this->redirectToRoute('user_edit', array('id' => $user->getId())); 51 return $this->redirectToRoute('user_edit', ['id' => $user->getId()]);
52 } 52 }
53 53
54 return $this->render('WallabagUserBundle:Manage:new.html.twig', array( 54 return $this->render('WallabagUserBundle:Manage:new.html.twig', [
55 'user' => $user, 55 'user' => $user,
56 'form' => $form->createView(), 56 'form' => $form->createView(),
57 )); 57 ]);
58 } 58 }
59 59
60 /** 60 /**
@@ -79,15 +79,15 @@ class ManageController extends Controller
79 $this->get('translator')->trans('flashes.user.notice.updated', ['%username%' => $user->getUsername()]) 79 $this->get('translator')->trans('flashes.user.notice.updated', ['%username%' => $user->getUsername()])
80 ); 80 );
81 81
82 return $this->redirectToRoute('user_edit', array('id' => $user->getId())); 82 return $this->redirectToRoute('user_edit', ['id' => $user->getId()]);
83 } 83 }
84 84
85 return $this->render('WallabagUserBundle:Manage:edit.html.twig', array( 85 return $this->render('WallabagUserBundle:Manage:edit.html.twig', [
86 'user' => $user, 86 'user' => $user,
87 'edit_form' => $editForm->createView(), 87 'edit_form' => $editForm->createView(),
88 'delete_form' => $deleteForm->createView(), 88 'delete_form' => $deleteForm->createView(),
89 'twofactor_auth' => $this->getParameter('twofactor_auth'), 89 'twofactor_auth' => $this->getParameter('twofactor_auth'),
90 )); 90 ]);
91 } 91 }
92 92
93 /** 93 /**
@@ -116,22 +116,6 @@ class ManageController extends Controller
116 } 116 }
117 117
118 /** 118 /**
119 * Creates a form to delete a User entity.
120 *
121 * @param User $user The User entity
122 *
123 * @return \Symfony\Component\Form\Form The form
124 */
125 private function createDeleteForm(User $user)
126 {
127 return $this->createFormBuilder()
128 ->setAction($this->generateUrl('user_delete', array('id' => $user->getId())))
129 ->setMethod('DELETE')
130 ->getForm()
131 ;
132 }
133
134 /**
135 * @param Request $request 119 * @param Request $request
136 * @param int $page 120 * @param int $page
137 * 121 *
@@ -175,4 +159,20 @@ class ManageController extends Controller
175 'users' => $pagerFanta, 159 'users' => $pagerFanta,
176 ]); 160 ]);
177 } 161 }
162
163 /**
164 * Creates a form to delete a User entity.
165 *
166 * @param User $user The User entity
167 *
168 * @return \Symfony\Component\Form\Form The form
169 */
170 private function createDeleteForm(User $user)
171 {
172 return $this->createFormBuilder()
173 ->setAction($this->generateUrl('user_delete', ['id' => $user->getId()]))
174 ->setMethod('DELETE')
175 ->getForm()
176 ;
177 }
178} 178}
diff --git a/src/Wallabag/UserBundle/DependencyInjection/WallabagUserExtension.php b/src/Wallabag/UserBundle/DependencyInjection/WallabagUserExtension.php
index 99040f69..5ca3482e 100644
--- a/src/Wallabag/UserBundle/DependencyInjection/WallabagUserExtension.php
+++ b/src/Wallabag/UserBundle/DependencyInjection/WallabagUserExtension.php
@@ -2,10 +2,10 @@
2 2
3namespace Wallabag\UserBundle\DependencyInjection; 3namespace Wallabag\UserBundle\DependencyInjection;
4 4
5use Symfony\Component\DependencyInjection\ContainerBuilder;
6use Symfony\Component\Config\FileLocator; 5use Symfony\Component\Config\FileLocator;
7use Symfony\Component\HttpKernel\DependencyInjection\Extension; 6use Symfony\Component\DependencyInjection\ContainerBuilder;
8use Symfony\Component\DependencyInjection\Loader; 7use Symfony\Component\DependencyInjection\Loader;
8use Symfony\Component\HttpKernel\DependencyInjection\Extension;
9 9
10class WallabagUserExtension extends Extension 10class WallabagUserExtension extends Extension
11{ 11{
@@ -14,7 +14,7 @@ class WallabagUserExtension extends Extension
14 $configuration = new Configuration(); 14 $configuration = new Configuration();
15 $config = $this->processConfiguration($configuration, $configs); 15 $config = $this->processConfiguration($configuration, $configs);
16 16
17 $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); 17 $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
18 $loader->load('services.yml'); 18 $loader->load('services.yml');
19 $container->setParameter('wallabag_user.registration_enabled', $config['registration_enabled']); 19 $container->setParameter('wallabag_user.registration_enabled', $config['registration_enabled']);
20 } 20 }
diff --git a/src/Wallabag/UserBundle/Entity/User.php b/src/Wallabag/UserBundle/Entity/User.php
index aba76ca7..20aca298 100644
--- a/src/Wallabag/UserBundle/Entity/User.php
+++ b/src/Wallabag/UserBundle/Entity/User.php
@@ -4,12 +4,12 @@ namespace Wallabag\UserBundle\Entity;
4 4
5use Doctrine\Common\Collections\ArrayCollection; 5use Doctrine\Common\Collections\ArrayCollection;
6use Doctrine\ORM\Mapping as ORM; 6use Doctrine\ORM\Mapping as ORM;
7use FOS\UserBundle\Model\User as BaseUser;
8use JMS\Serializer\Annotation\Accessor;
7use JMS\Serializer\Annotation\Groups; 9use JMS\Serializer\Annotation\Groups;
8use JMS\Serializer\Annotation\XmlRoot; 10use JMS\Serializer\Annotation\XmlRoot;
9use JMS\Serializer\Annotation\Accessor;
10use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface; 11use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface;
11use Scheb\TwoFactorBundle\Model\TrustedComputerInterface; 12use Scheb\TwoFactorBundle\Model\TrustedComputerInterface;
12use FOS\UserBundle\Model\User as BaseUser;
13use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; 13use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
14use Symfony\Component\Security\Core\User\UserInterface; 14use Symfony\Component\Security\Core\User\UserInterface;
15use Wallabag\ApiBundle\Entity\Client; 15use Wallabag\ApiBundle\Entity\Client;
@@ -93,36 +93,36 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf
93 protected $config; 93 protected $config;
94 94
95 /** 95 /**
96 * @ORM\Column(type="integer", nullable=true) 96 * @var ArrayCollection
97 *
98 * @ORM\OneToMany(targetEntity="Wallabag\ApiBundle\Entity\Client", mappedBy="user", cascade={"remove"})
97 */ 99 */
98 private $authCode; 100 protected $clients;
99 101
100 /** 102 /**
101 * @var bool 103 * @see getFirstClient() below
102 * 104 *
103 * @ORM\Column(type="boolean") 105 * @Groups({"user_api_with_client"})
106 * @Accessor(getter="getFirstClient")
104 */ 107 */
105 private $twoFactorAuthentication = false; 108 protected $default_client;
106 109
107 /** 110 /**
108 * @ORM\Column(type="json_array", nullable=true) 111 * @ORM\Column(type="integer", nullable=true)
109 */ 112 */
110 private $trusted; 113 private $authCode;
111 114
112 /** 115 /**
113 * @var ArrayCollection 116 * @var bool
114 * 117 *
115 * @ORM\OneToMany(targetEntity="Wallabag\ApiBundle\Entity\Client", mappedBy="user", cascade={"remove"}) 118 * @ORM\Column(type="boolean")
116 */ 119 */
117 protected $clients; 120 private $twoFactorAuthentication = false;
118 121
119 /** 122 /**
120 * @see getFirstClient() below 123 * @ORM\Column(type="json_array", nullable=true)
121 *
122 * @Groups({"user_api_with_client"})
123 * @Accessor(getter="getFirstClient")
124 */ 124 */
125 protected $default_client; 125 private $trusted;
126 126
127 public function __construct() 127 public function __construct()
128 { 128 {
@@ -137,7 +137,7 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf
137 */ 137 */
138 public function timestamps() 138 public function timestamps()
139 { 139 {
140 if (is_null($this->createdAt)) { 140 if (null === $this->createdAt) {
141 $this->createdAt = new \DateTime(); 141 $this->createdAt = new \DateTime();
142 } 142 }
143 143
diff --git a/src/Wallabag/UserBundle/EventListener/AuthenticationFailureListener.php b/src/Wallabag/UserBundle/EventListener/AuthenticationFailureListener.php
index 10f13233..18f14a3a 100644
--- a/src/Wallabag/UserBundle/EventListener/AuthenticationFailureListener.php
+++ b/src/Wallabag/UserBundle/EventListener/AuthenticationFailureListener.php
@@ -35,6 +35,6 @@ class AuthenticationFailureListener implements EventSubscriberInterface
35 { 35 {
36 $request = $this->requestStack->getMasterRequest(); 36 $request = $this->requestStack->getMasterRequest();
37 37
38 $this->logger->error('Authentication failure for user "'.$request->request->get('_username').'", from IP "'.$request->getClientIp().'", with UA: "'.$request->server->get('HTTP_USER_AGENT').'".'); 38 $this->logger->error('Authentication failure for user "' . $request->request->get('_username') . '", from IP "' . $request->getClientIp() . '", with UA: "' . $request->server->get('HTTP_USER_AGENT') . '".');
39 } 39 }
40} 40}
diff --git a/src/Wallabag/UserBundle/EventListener/PasswordResettingListener.php b/src/Wallabag/UserBundle/EventListener/PasswordResettingListener.php
index 3a7f2637..7df093f1 100644
--- a/src/Wallabag/UserBundle/EventListener/PasswordResettingListener.php
+++ b/src/Wallabag/UserBundle/EventListener/PasswordResettingListener.php
@@ -2,8 +2,8 @@
2 2
3namespace Wallabag\UserBundle\EventListener; 3namespace Wallabag\UserBundle\EventListener;
4 4
5use FOS\UserBundle\FOSUserEvents;
6use FOS\UserBundle\Event\FormEvent; 5use FOS\UserBundle\Event\FormEvent;
6use FOS\UserBundle\FOSUserEvents;
7use Symfony\Component\EventDispatcher\EventSubscriberInterface; 7use Symfony\Component\EventDispatcher\EventSubscriberInterface;
8use Symfony\Component\HttpFoundation\RedirectResponse; 8use Symfony\Component\HttpFoundation\RedirectResponse;
9use Symfony\Component\Routing\Generator\UrlGeneratorInterface; 9use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
diff --git a/src/Wallabag/UserBundle/Form/UserType.php b/src/Wallabag/UserBundle/Form/UserType.php
index d8cdbaf9..56fea640 100644
--- a/src/Wallabag/UserBundle/Form/UserType.php
+++ b/src/Wallabag/UserBundle/Form/UserType.php
@@ -3,12 +3,12 @@
3namespace Wallabag\UserBundle\Form; 3namespace Wallabag\UserBundle\Form;
4 4
5use Symfony\Component\Form\AbstractType; 5use Symfony\Component\Form\AbstractType;
6use Symfony\Component\Form\FormBuilderInterface;
7use Symfony\Component\OptionsResolver\OptionsResolver;
8use Symfony\Component\Form\Extension\Core\Type\CheckboxType; 6use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
7use Symfony\Component\Form\Extension\Core\Type\EmailType;
9use Symfony\Component\Form\Extension\Core\Type\SubmitType; 8use Symfony\Component\Form\Extension\Core\Type\SubmitType;
10use Symfony\Component\Form\Extension\Core\Type\TextType; 9use Symfony\Component\Form\Extension\Core\Type\TextType;
11use Symfony\Component\Form\Extension\Core\Type\EmailType; 10use Symfony\Component\Form\FormBuilderInterface;
11use Symfony\Component\OptionsResolver\OptionsResolver;
12 12
13class UserType extends AbstractType 13class UserType extends AbstractType
14{ 14{
@@ -50,8 +50,8 @@ class UserType extends AbstractType
50 */ 50 */
51 public function configureOptions(OptionsResolver $resolver) 51 public function configureOptions(OptionsResolver $resolver)
52 { 52 {
53 $resolver->setDefaults(array( 53 $resolver->setDefaults([
54 'data_class' => 'Wallabag\UserBundle\Entity\User', 54 'data_class' => 'Wallabag\UserBundle\Entity\User',
55 )); 55 ]);
56 } 56 }
57} 57}
diff --git a/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php b/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php
index 961208f2..aed805c9 100644
--- a/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php
+++ b/src/Wallabag/UserBundle/Mailer/AuthCodeMailer.php
@@ -2,8 +2,8 @@
2 2
3namespace Wallabag\UserBundle\Mailer; 3namespace Wallabag\UserBundle\Mailer;
4 4
5use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface;
6use Scheb\TwoFactorBundle\Mailer\AuthCodeMailerInterface; 5use Scheb\TwoFactorBundle\Mailer\AuthCodeMailerInterface;
6use Scheb\TwoFactorBundle\Model\Email\TwoFactorInterface;
7 7
8/** 8/**
9 * Custom mailer for TwoFactorBundle email. 9 * Custom mailer for TwoFactorBundle email.
diff --git a/src/Wallabag/UserBundle/Repository/UserRepository.php b/src/Wallabag/UserBundle/Repository/UserRepository.php
index 6adbe329..b1d753d2 100644
--- a/src/Wallabag/UserBundle/Repository/UserRepository.php
+++ b/src/Wallabag/UserBundle/Repository/UserRepository.php
@@ -63,6 +63,6 @@ class UserRepository extends EntityRepository
63 public function getQueryBuilderForSearch($term) 63 public function getQueryBuilderForSearch($term)
64 { 64 {
65 return $this->createQueryBuilder('u') 65 return $this->createQueryBuilder('u')
66 ->andWhere('lower(u.username) LIKE lower(:term) OR lower(u.email) LIKE lower(:term) OR lower(u.name) LIKE lower(:term)')->setParameter('term', '%'.$term.'%'); 66 ->andWhere('lower(u.username) LIKE lower(:term) OR lower(u.email) LIKE lower(:term) OR lower(u.name) LIKE lower(:term)')->setParameter('term', '%' . $term . '%');
67 } 67 }
68} 68}
diff --git a/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php b/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php
index 3c94382c..96474468 100644
--- a/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php
+++ b/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php
@@ -49,12 +49,12 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
49 $this->logInAs('admin'); 49 $this->logInAs('admin');
50 } 50 }
51 51
52 $this->client->request('GET', $prefixUrl.'/'.$entry->getId().'.json'); 52 $this->client->request('GET', $prefixUrl . '/' . $entry->getId() . '.json');
53 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 53 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
54 54
55 $content = json_decode($this->client->getResponse()->getContent(), true); 55 $content = json_decode($this->client->getResponse()->getContent(), true);
56 $this->assertGreaterThanOrEqual(1, $content['total']); 56 $this->assertGreaterThanOrEqual(1, $content['total']);
57 $this->assertEquals($annotation->getText(), $content['rows'][0]['text']); 57 $this->assertSame($annotation->getText(), $content['rows'][0]['text']);
58 58
59 // we need to re-fetch the annotation becase after the flush, it has been "detached" from the entity manager 59 // we need to re-fetch the annotation becase after the flush, it has been "detached" from the entity manager
60 $annotation = $em->getRepository('WallabagAnnotationBundle:Annotation')->findAnnotationById($annotation->getId()); 60 $annotation = $em->getRepository('WallabagAnnotationBundle:Annotation')->findAnnotationById($annotation->getId());
@@ -88,16 +88,16 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
88 ['start' => '', 'startOffset' => 24, 'end' => '', 'endOffset' => 31], 88 ['start' => '', 'startOffset' => 24, 'end' => '', 'endOffset' => 31],
89 ], 89 ],
90 ]); 90 ]);
91 $this->client->request('POST', $prefixUrl.'/'.$entry->getId().'.json', [], [], $headers, $content); 91 $this->client->request('POST', $prefixUrl . '/' . $entry->getId() . '.json', [], [], $headers, $content);
92 92
93 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 93 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
94 94
95 $content = json_decode($this->client->getResponse()->getContent(), true); 95 $content = json_decode($this->client->getResponse()->getContent(), true);
96 96
97 $this->assertEquals('Big boss', $content['user']); 97 $this->assertSame('Big boss', $content['user']);
98 $this->assertEquals('v1.0', $content['annotator_schema_version']); 98 $this->assertSame('v1.0', $content['annotator_schema_version']);
99 $this->assertEquals('my annotation', $content['text']); 99 $this->assertSame('my annotation', $content['text']);
100 $this->assertEquals('my quote', $content['quote']); 100 $this->assertSame('my quote', $content['quote']);
101 101
102 /** @var Annotation $annotation */ 102 /** @var Annotation $annotation */
103 $annotation = $this->client->getContainer() 103 $annotation = $this->client->getContainer()
@@ -105,7 +105,7 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
105 ->getRepository('WallabagAnnotationBundle:Annotation') 105 ->getRepository('WallabagAnnotationBundle:Annotation')
106 ->findLastAnnotationByPageId($entry->getId(), 1); 106 ->findLastAnnotationByPageId($entry->getId(), 1);
107 107
108 $this->assertEquals('my annotation', $annotation->getText()); 108 $this->assertSame('my annotation', $annotation->getText());
109 } 109 }
110 110
111 /** 111 /**
@@ -133,9 +133,9 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
133 ['start' => '', 'startOffset' => 24, 'end' => '', 'endOffset' => 31], 133 ['start' => '', 'startOffset' => 24, 'end' => '', 'endOffset' => 31],
134 ], 134 ],
135 ]); 135 ]);
136 $this->client->request('POST', $prefixUrl.'/'.$entry->getId().'.json', [], [], $headers, $content); 136 $this->client->request('POST', $prefixUrl . '/' . $entry->getId() . '.json', [], [], $headers, $content);
137 137
138 $this->assertEquals(400, $this->client->getResponse()->getStatusCode()); 138 $this->assertSame(400, $this->client->getResponse()->getStatusCode());
139 } 139 }
140 140
141 /** 141 /**
@@ -166,21 +166,21 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
166 $content = json_encode([ 166 $content = json_encode([
167 'text' => 'a modified annotation', 167 'text' => 'a modified annotation',
168 ]); 168 ]);
169 $this->client->request('PUT', $prefixUrl.'/'.$annotation->getId().'.json', [], [], $headers, $content); 169 $this->client->request('PUT', $prefixUrl . '/' . $annotation->getId() . '.json', [], [], $headers, $content);
170 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 170 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
171 171
172 $content = json_decode($this->client->getResponse()->getContent(), true); 172 $content = json_decode($this->client->getResponse()->getContent(), true);
173 173
174 $this->assertEquals('Big boss', $content['user']); 174 $this->assertSame('Big boss', $content['user']);
175 $this->assertEquals('v1.0', $content['annotator_schema_version']); 175 $this->assertSame('v1.0', $content['annotator_schema_version']);
176 $this->assertEquals('a modified annotation', $content['text']); 176 $this->assertSame('a modified annotation', $content['text']);
177 $this->assertEquals('my quote', $content['quote']); 177 $this->assertSame('my quote', $content['quote']);
178 178
179 /** @var Annotation $annotationUpdated */ 179 /** @var Annotation $annotationUpdated */
180 $annotationUpdated = $em 180 $annotationUpdated = $em
181 ->getRepository('WallabagAnnotationBundle:Annotation') 181 ->getRepository('WallabagAnnotationBundle:Annotation')
182 ->findOneById($annotation->getId()); 182 ->findOneById($annotation->getId());
183 $this->assertEquals('a modified annotation', $annotationUpdated->getText()); 183 $this->assertSame('a modified annotation', $annotationUpdated->getText());
184 184
185 $em->remove($annotationUpdated); 185 $em->remove($annotationUpdated);
186 $em->flush(); 186 $em->flush();
@@ -218,12 +218,12 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase
218 $content = json_encode([ 218 $content = json_encode([
219 'text' => 'a modified annotation', 219 'text' => 'a modified annotation',
220 ]); 220 ]);
221 $this->client->request('DELETE', $prefixUrl.'/'.$annotation->getId().'.json', [], [], $headers, $content); 221 $this->client->request('DELETE', $prefixUrl . '/' . $annotation->getId() . '.json', [], [], $headers, $content);
222 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 222 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
223 223
224 $content = json_decode($this->client->getResponse()->getContent(), true); 224 $content = json_decode($this->client->getResponse()->getContent(), true);
225 225
226 $this->assertEquals('This is my annotation /o/', $content['text']); 226 $this->assertSame('This is my annotation /o/', $content['text']);
227 227
228 $annotationDeleted = $em 228 $annotationDeleted = $em
229 ->getRepository('WallabagAnnotationBundle:Annotation') 229 ->getRepository('WallabagAnnotationBundle:Annotation')
diff --git a/tests/Wallabag/AnnotationBundle/WallabagAnnotationTestCase.php b/tests/Wallabag/AnnotationBundle/WallabagAnnotationTestCase.php
index ef3f1324..105e8add 100644
--- a/tests/Wallabag/AnnotationBundle/WallabagAnnotationTestCase.php
+++ b/tests/Wallabag/AnnotationBundle/WallabagAnnotationTestCase.php
@@ -52,7 +52,7 @@ abstract class WallabagAnnotationTestCase extends WebTestCase
52 $loginManager->logInUser($firewallName, $this->user); 52 $loginManager->logInUser($firewallName, $this->user);
53 53
54 // save the login token into the session and put it in a cookie 54 // save the login token into the session and put it in a cookie
55 $container->get('session')->set('_security_'.$firewallName, serialize($container->get('security.token_storage')->getToken())); 55 $container->get('session')->set('_security_' . $firewallName, serialize($container->get('security.token_storage')->getToken()));
56 $container->get('session')->save(); 56 $container->get('session')->save();
57 57
58 $session = $container->get('session'); 58 $session = $container->get('session');
diff --git a/tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php b/tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php
index 53aed12b..2caeccf5 100644
--- a/tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php
+++ b/tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php
@@ -15,7 +15,7 @@ class DeveloperControllerTest extends WallabagCoreTestCase
15 $nbClients = $em->getRepository('WallabagApiBundle:Client')->findAll(); 15 $nbClients = $em->getRepository('WallabagApiBundle:Client')->findAll();
16 16
17 $crawler = $client->request('GET', '/developer/client/create'); 17 $crawler = $client->request('GET', '/developer/client/create');
18 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 18 $this->assertSame(200, $client->getResponse()->getStatusCode());
19 19
20 $form = $crawler->filter('button[type=submit]')->form(); 20 $form = $crawler->filter('button[type=submit]')->form();
21 21
@@ -25,7 +25,7 @@ class DeveloperControllerTest extends WallabagCoreTestCase
25 25
26 $crawler = $client->submit($form, $data); 26 $crawler = $client->submit($form, $data);
27 27
28 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 28 $this->assertSame(200, $client->getResponse()->getStatusCode());
29 29
30 $newNbClients = $em->getRepository('WallabagApiBundle:Client')->findAll(); 30 $newNbClients = $em->getRepository('WallabagApiBundle:Client')->findAll();
31 $this->assertGreaterThan(count($nbClients), count($newNbClients)); 31 $this->assertGreaterThan(count($nbClients), count($newNbClients));
@@ -47,7 +47,7 @@ class DeveloperControllerTest extends WallabagCoreTestCase
47 'password' => 'mypassword', 47 'password' => 'mypassword',
48 ]); 48 ]);
49 49
50 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 50 $this->assertSame(200, $client->getResponse()->getStatusCode());
51 51
52 $data = json_decode($client->getResponse()->getContent(), true); 52 $data = json_decode($client->getResponse()->getContent(), true);
53 $this->assertArrayHasKey('access_token', $data); 53 $this->assertArrayHasKey('access_token', $data);
@@ -67,7 +67,7 @@ class DeveloperControllerTest extends WallabagCoreTestCase
67 'client_secret' => $apiClient->getSecret(), 67 'client_secret' => $apiClient->getSecret(),
68 ]); 68 ]);
69 69
70 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 70 $this->assertSame(200, $client->getResponse()->getStatusCode());
71 71
72 $data = json_decode($client->getResponse()->getContent(), true); 72 $data = json_decode($client->getResponse()->getContent(), true);
73 $this->assertArrayHasKey('access_token', $data); 73 $this->assertArrayHasKey('access_token', $data);
@@ -84,8 +84,8 @@ class DeveloperControllerTest extends WallabagCoreTestCase
84 $nbClients = $em->getRepository('WallabagApiBundle:Client')->findAll(); 84 $nbClients = $em->getRepository('WallabagApiBundle:Client')->findAll();
85 85
86 $crawler = $client->request('GET', '/developer'); 86 $crawler = $client->request('GET', '/developer');
87 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 87 $this->assertSame(200, $client->getResponse()->getStatusCode());
88 $this->assertEquals(count($nbClients), $crawler->filter('ul[class=collapsible] li')->count()); 88 $this->assertSame(count($nbClients), $crawler->filter('ul[class=collapsible] li')->count());
89 } 89 }
90 90
91 public function testDeveloperHowto() 91 public function testDeveloperHowto()
@@ -94,7 +94,7 @@ class DeveloperControllerTest extends WallabagCoreTestCase
94 $client = $this->getClient(); 94 $client = $this->getClient();
95 95
96 $crawler = $client->request('GET', '/developer/howto/first-app'); 96 $crawler = $client->request('GET', '/developer/howto/first-app');
97 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 97 $this->assertSame(200, $client->getResponse()->getStatusCode());
98 } 98 }
99 99
100 public function testRemoveClient() 100 public function testRemoveClient()
@@ -109,8 +109,8 @@ class DeveloperControllerTest extends WallabagCoreTestCase
109 $this->assertContains('no_client', $client->getResponse()->getContent()); 109 $this->assertContains('no_client', $client->getResponse()->getContent());
110 110
111 $this->logInAs('bob'); 111 $this->logInAs('bob');
112 $client->request('GET', '/developer/client/delete/'.$adminApiClient->getId()); 112 $client->request('GET', '/developer/client/delete/' . $adminApiClient->getId());
113 $this->assertEquals(403, $client->getResponse()->getStatusCode()); 113 $this->assertSame(403, $client->getResponse()->getStatusCode());
114 114
115 // Try to remove the admin's client with the good user 115 // Try to remove the admin's client with the good user
116 $this->logInAs('admin'); 116 $this->logInAs('admin');
@@ -123,7 +123,7 @@ class DeveloperControllerTest extends WallabagCoreTestCase
123 ; 123 ;
124 124
125 $client->click($link); 125 $client->click($link);
126 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 126 $this->assertSame(302, $client->getResponse()->getStatusCode());
127 127
128 $this->assertNull( 128 $this->assertNull(
129 $em->getRepository('WallabagApiBundle:Client')->find($adminApiClient->getId()), 129 $em->getRepository('WallabagApiBundle:Client')->find($adminApiClient->getId()),
@@ -133,8 +133,8 @@ class DeveloperControllerTest extends WallabagCoreTestCase
133 133
134 /** 134 /**
135 * @param string $username 135 * @param string $username
136 * @param array $grantTypes
136 * 137 *
137 * @param array $grantTypes
138 * @return Client 138 * @return Client
139 */ 139 */
140 private function createApiClientForUser($username, $grantTypes = ['password']) 140 private function createApiClientForUser($username, $grantTypes = ['password'])
@@ -142,7 +142,7 @@ class DeveloperControllerTest extends WallabagCoreTestCase
142 $client = $this->getClient(); 142 $client = $this->getClient();
143 $em = $client->getContainer()->get('doctrine.orm.entity_manager'); 143 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
144 $userManager = $client->getContainer()->get('fos_user.user_manager'); 144 $userManager = $client->getContainer()->get('fos_user.user_manager');
145 $user = $userManager->findUserBy(array('username' => $username)); 145 $user = $userManager->findUserBy(['username' => $username]);
146 $apiClient = new Client($user); 146 $apiClient = new Client($user);
147 $apiClient->setName('My app'); 147 $apiClient->setName('My app');
148 $apiClient->setAllowedGrantTypes($grantTypes); 148 $apiClient->setAllowedGrantTypes($grantTypes);
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
index c0391d87..2a333a0d 100644
--- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
+++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
@@ -21,19 +21,19 @@ class EntryRestControllerTest extends WallabagApiTestCase
21 $this->markTestSkipped('No content found in db.'); 21 $this->markTestSkipped('No content found in db.');
22 } 22 }
23 23
24 $this->client->request('GET', '/api/entries/'.$entry->getId().'.json'); 24 $this->client->request('GET', '/api/entries/' . $entry->getId() . '.json');
25 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 25 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
26 26
27 $content = json_decode($this->client->getResponse()->getContent(), true); 27 $content = json_decode($this->client->getResponse()->getContent(), true);
28 28
29 $this->assertEquals($entry->getTitle(), $content['title']); 29 $this->assertSame($entry->getTitle(), $content['title']);
30 $this->assertEquals($entry->getUrl(), $content['url']); 30 $this->assertSame($entry->getUrl(), $content['url']);
31 $this->assertCount(count($entry->getTags()), $content['tags']); 31 $this->assertCount(count($entry->getTags()), $content['tags']);
32 $this->assertEquals($entry->getUserName(), $content['user_name']); 32 $this->assertSame($entry->getUserName(), $content['user_name']);
33 $this->assertEquals($entry->getUserEmail(), $content['user_email']); 33 $this->assertSame($entry->getUserEmail(), $content['user_email']);
34 $this->assertEquals($entry->getUserId(), $content['user_id']); 34 $this->assertSame($entry->getUserId(), $content['user_id']);
35 35
36 $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); 36 $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
37 } 37 }
38 38
39 public function testExportEntry() 39 public function testExportEntry()
@@ -47,39 +47,39 @@ class EntryRestControllerTest extends WallabagApiTestCase
47 $this->markTestSkipped('No content found in db.'); 47 $this->markTestSkipped('No content found in db.');
48 } 48 }
49 49
50 $this->client->request('GET', '/api/entries/'.$entry->getId().'/export.epub'); 50 $this->client->request('GET', '/api/entries/' . $entry->getId() . '/export.epub');
51 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 51 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
52 52
53 // epub format got the content type in the content 53 // epub format got the content type in the content
54 $this->assertContains('application/epub', $this->client->getResponse()->getContent()); 54 $this->assertContains('application/epub', $this->client->getResponse()->getContent());
55 $this->assertEquals('application/epub+zip', $this->client->getResponse()->headers->get('Content-Type')); 55 $this->assertSame('application/epub+zip', $this->client->getResponse()->headers->get('Content-Type'));
56 56
57 // re-auth client for mobi 57 // re-auth client for mobi
58 $client = $this->createAuthorizedClient(); 58 $client = $this->createAuthorizedClient();
59 $client->request('GET', '/api/entries/'.$entry->getId().'/export.mobi'); 59 $client->request('GET', '/api/entries/' . $entry->getId() . '/export.mobi');
60 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 60 $this->assertSame(200, $client->getResponse()->getStatusCode());
61 61
62 $this->assertEquals('application/x-mobipocket-ebook', $client->getResponse()->headers->get('Content-Type')); 62 $this->assertSame('application/x-mobipocket-ebook', $client->getResponse()->headers->get('Content-Type'));
63 63
64 // re-auth client for pdf 64 // re-auth client for pdf
65 $client = $this->createAuthorizedClient(); 65 $client = $this->createAuthorizedClient();
66 $client->request('GET', '/api/entries/'.$entry->getId().'/export.pdf'); 66 $client->request('GET', '/api/entries/' . $entry->getId() . '/export.pdf');
67 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 67 $this->assertSame(200, $client->getResponse()->getStatusCode());
68 68
69 $this->assertContains('PDF-', $client->getResponse()->getContent()); 69 $this->assertContains('PDF-', $client->getResponse()->getContent());
70 $this->assertEquals('application/pdf', $client->getResponse()->headers->get('Content-Type')); 70 $this->assertSame('application/pdf', $client->getResponse()->headers->get('Content-Type'));
71 71
72 // re-auth client for pdf 72 // re-auth client for pdf
73 $client = $this->createAuthorizedClient(); 73 $client = $this->createAuthorizedClient();
74 $client->request('GET', '/api/entries/'.$entry->getId().'/export.txt'); 74 $client->request('GET', '/api/entries/' . $entry->getId() . '/export.txt');
75 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 75 $this->assertSame(200, $client->getResponse()->getStatusCode());
76 76
77 $this->assertContains('text/plain', $client->getResponse()->headers->get('Content-Type')); 77 $this->assertContains('text/plain', $client->getResponse()->headers->get('Content-Type'));
78 78
79 // re-auth client for pdf 79 // re-auth client for pdf
80 $client = $this->createAuthorizedClient(); 80 $client = $this->createAuthorizedClient();
81 $client->request('GET', '/api/entries/'.$entry->getId().'/export.csv'); 81 $client->request('GET', '/api/entries/' . $entry->getId() . '/export.csv');
82 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 82 $this->assertSame(200, $client->getResponse()->getStatusCode());
83 83
84 $this->assertContains('application/csv', $client->getResponse()->headers->get('Content-Type')); 84 $this->assertContains('application/csv', $client->getResponse()->headers->get('Content-Type'));
85 } 85 }
@@ -95,26 +95,26 @@ class EntryRestControllerTest extends WallabagApiTestCase
95 $this->markTestSkipped('No content found in db.'); 95 $this->markTestSkipped('No content found in db.');
96 } 96 }
97 97
98 $this->client->request('GET', '/api/entries/'.$entry->getId().'.json'); 98 $this->client->request('GET', '/api/entries/' . $entry->getId() . '.json');
99 99
100 $this->assertEquals(403, $this->client->getResponse()->getStatusCode()); 100 $this->assertSame(403, $this->client->getResponse()->getStatusCode());
101 } 101 }
102 102
103 public function testGetEntries() 103 public function testGetEntries()
104 { 104 {
105 $this->client->request('GET', '/api/entries'); 105 $this->client->request('GET', '/api/entries');
106 106
107 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 107 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
108 108
109 $content = json_decode($this->client->getResponse()->getContent(), true); 109 $content = json_decode($this->client->getResponse()->getContent(), true);
110 110
111 $this->assertGreaterThanOrEqual(1, count($content)); 111 $this->assertGreaterThanOrEqual(1, count($content));
112 $this->assertNotEmpty($content['_embedded']['items']); 112 $this->assertNotEmpty($content['_embedded']['items']);
113 $this->assertGreaterThanOrEqual(1, $content['total']); 113 $this->assertGreaterThanOrEqual(1, $content['total']);
114 $this->assertEquals(1, $content['page']); 114 $this->assertSame(1, $content['page']);
115 $this->assertGreaterThanOrEqual(1, $content['pages']); 115 $this->assertGreaterThanOrEqual(1, $content['pages']);
116 116
117 $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); 117 $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
118 } 118 }
119 119
120 public function testGetEntriesWithFullOptions() 120 public function testGetEntriesWithFullOptions()
@@ -131,15 +131,15 @@ class EntryRestControllerTest extends WallabagApiTestCase
131 'public' => 0, 131 'public' => 0,
132 ]); 132 ]);
133 133
134 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 134 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
135 135
136 $content = json_decode($this->client->getResponse()->getContent(), true); 136 $content = json_decode($this->client->getResponse()->getContent(), true);
137 137
138 $this->assertGreaterThanOrEqual(1, count($content)); 138 $this->assertGreaterThanOrEqual(1, count($content));
139 $this->assertArrayHasKey('items', $content['_embedded']); 139 $this->assertArrayHasKey('items', $content['_embedded']);
140 $this->assertGreaterThanOrEqual(0, $content['total']); 140 $this->assertGreaterThanOrEqual(0, $content['total']);
141 $this->assertEquals(1, $content['page']); 141 $this->assertSame(1, $content['page']);
142 $this->assertEquals(2, $content['limit']); 142 $this->assertSame(2, $content['limit']);
143 $this->assertGreaterThanOrEqual(1, $content['pages']); 143 $this->assertGreaterThanOrEqual(1, $content['pages']);
144 144
145 $this->assertArrayHasKey('_links', $content); 145 $this->assertArrayHasKey('_links', $content);
@@ -158,7 +158,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
158 $this->assertContains('public=0', $content['_links'][$link]['href']); 158 $this->assertContains('public=0', $content['_links'][$link]['href']);
159 } 159 }
160 160
161 $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); 161 $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
162 } 162 }
163 163
164 public function testGetEntriesPublicOnly() 164 public function testGetEntriesPublicOnly()
@@ -183,15 +183,15 @@ class EntryRestControllerTest extends WallabagApiTestCase
183 'public' => 1, 183 'public' => 1,
184 ]); 184 ]);
185 185
186 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 186 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
187 187
188 $content = json_decode($this->client->getResponse()->getContent(), true); 188 $content = json_decode($this->client->getResponse()->getContent(), true);
189 189
190 $this->assertGreaterThanOrEqual(1, count($content)); 190 $this->assertGreaterThanOrEqual(1, count($content));
191 $this->assertArrayHasKey('items', $content['_embedded']); 191 $this->assertArrayHasKey('items', $content['_embedded']);
192 $this->assertGreaterThanOrEqual(1, $content['total']); 192 $this->assertGreaterThanOrEqual(1, $content['total']);
193 $this->assertEquals(1, $content['page']); 193 $this->assertSame(1, $content['page']);
194 $this->assertEquals(30, $content['limit']); 194 $this->assertSame(30, $content['limit']);
195 $this->assertGreaterThanOrEqual(1, $content['pages']); 195 $this->assertGreaterThanOrEqual(1, $content['pages']);
196 196
197 $this->assertArrayHasKey('_links', $content); 197 $this->assertArrayHasKey('_links', $content);
@@ -204,7 +204,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
204 $this->assertContains('public=1', $content['_links'][$link]['href']); 204 $this->assertContains('public=1', $content['_links'][$link]['href']);
205 } 205 }
206 206
207 $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); 207 $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
208 } 208 }
209 209
210 public function testGetEntriesOnPageTwo() 210 public function testGetEntriesOnPageTwo()
@@ -214,27 +214,27 @@ class EntryRestControllerTest extends WallabagApiTestCase
214 'perPage' => 2, 214 'perPage' => 2,
215 ]); 215 ]);
216 216
217 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 217 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
218 218
219 $content = json_decode($this->client->getResponse()->getContent(), true); 219 $content = json_decode($this->client->getResponse()->getContent(), true);
220 220
221 $this->assertGreaterThanOrEqual(0, $content['total']); 221 $this->assertGreaterThanOrEqual(0, $content['total']);
222 $this->assertEquals(2, $content['page']); 222 $this->assertSame(2, $content['page']);
223 $this->assertEquals(2, $content['limit']); 223 $this->assertSame(2, $content['limit']);
224 } 224 }
225 225
226 public function testGetStarredEntries() 226 public function testGetStarredEntries()
227 { 227 {
228 $this->client->request('GET', '/api/entries', ['starred' => 1, 'sort' => 'updated']); 228 $this->client->request('GET', '/api/entries', ['starred' => 1, 'sort' => 'updated']);
229 229
230 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 230 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
231 231
232 $content = json_decode($this->client->getResponse()->getContent(), true); 232 $content = json_decode($this->client->getResponse()->getContent(), true);
233 233
234 $this->assertGreaterThanOrEqual(1, count($content)); 234 $this->assertGreaterThanOrEqual(1, count($content));
235 $this->assertNotEmpty($content['_embedded']['items']); 235 $this->assertNotEmpty($content['_embedded']['items']);
236 $this->assertGreaterThanOrEqual(1, $content['total']); 236 $this->assertGreaterThanOrEqual(1, $content['total']);
237 $this->assertEquals(1, $content['page']); 237 $this->assertSame(1, $content['page']);
238 $this->assertGreaterThanOrEqual(1, $content['pages']); 238 $this->assertGreaterThanOrEqual(1, $content['pages']);
239 239
240 $this->assertArrayHasKey('_links', $content); 240 $this->assertArrayHasKey('_links', $content);
@@ -248,21 +248,21 @@ class EntryRestControllerTest extends WallabagApiTestCase
248 $this->assertContains('sort=updated', $content['_links'][$link]['href']); 248 $this->assertContains('sort=updated', $content['_links'][$link]['href']);
249 } 249 }
250 250
251 $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); 251 $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
252 } 252 }
253 253
254 public function testGetArchiveEntries() 254 public function testGetArchiveEntries()
255 { 255 {
256 $this->client->request('GET', '/api/entries', ['archive' => 1]); 256 $this->client->request('GET', '/api/entries', ['archive' => 1]);
257 257
258 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 258 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
259 259
260 $content = json_decode($this->client->getResponse()->getContent(), true); 260 $content = json_decode($this->client->getResponse()->getContent(), true);
261 261
262 $this->assertGreaterThanOrEqual(1, count($content)); 262 $this->assertGreaterThanOrEqual(1, count($content));
263 $this->assertNotEmpty($content['_embedded']['items']); 263 $this->assertNotEmpty($content['_embedded']['items']);
264 $this->assertGreaterThanOrEqual(1, $content['total']); 264 $this->assertGreaterThanOrEqual(1, $content['total']);
265 $this->assertEquals(1, $content['page']); 265 $this->assertSame(1, $content['page']);
266 $this->assertGreaterThanOrEqual(1, $content['pages']); 266 $this->assertGreaterThanOrEqual(1, $content['pages']);
267 267
268 $this->assertArrayHasKey('_links', $content); 268 $this->assertArrayHasKey('_links', $content);
@@ -275,21 +275,21 @@ class EntryRestControllerTest extends WallabagApiTestCase
275 $this->assertContains('archive=1', $content['_links'][$link]['href']); 275 $this->assertContains('archive=1', $content['_links'][$link]['href']);
276 } 276 }
277 277
278 $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); 278 $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
279 } 279 }
280 280
281 public function testGetTaggedEntries() 281 public function testGetTaggedEntries()
282 { 282 {
283 $this->client->request('GET', '/api/entries', ['tags' => 'foo,bar']); 283 $this->client->request('GET', '/api/entries', ['tags' => 'foo,bar']);
284 284
285 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 285 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
286 286
287 $content = json_decode($this->client->getResponse()->getContent(), true); 287 $content = json_decode($this->client->getResponse()->getContent(), true);
288 288
289 $this->assertGreaterThanOrEqual(1, count($content)); 289 $this->assertGreaterThanOrEqual(1, count($content));
290 $this->assertNotEmpty($content['_embedded']['items']); 290 $this->assertNotEmpty($content['_embedded']['items']);
291 $this->assertGreaterThanOrEqual(1, $content['total']); 291 $this->assertGreaterThanOrEqual(1, $content['total']);
292 $this->assertEquals(1, $content['page']); 292 $this->assertSame(1, $content['page']);
293 $this->assertGreaterThanOrEqual(1, $content['pages']); 293 $this->assertGreaterThanOrEqual(1, $content['pages']);
294 294
295 $this->assertArrayHasKey('_links', $content); 295 $this->assertArrayHasKey('_links', $content);
@@ -299,24 +299,24 @@ class EntryRestControllerTest extends WallabagApiTestCase
299 299
300 foreach (['self', 'first', 'last'] as $link) { 300 foreach (['self', 'first', 'last'] as $link) {
301 $this->assertArrayHasKey('href', $content['_links'][$link]); 301 $this->assertArrayHasKey('href', $content['_links'][$link]);
302 $this->assertContains('tags='.urlencode('foo,bar'), $content['_links'][$link]['href']); 302 $this->assertContains('tags=' . urlencode('foo,bar'), $content['_links'][$link]['href']);
303 } 303 }
304 304
305 $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); 305 $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
306 } 306 }
307 307
308 public function testGetDatedEntries() 308 public function testGetDatedEntries()
309 { 309 {
310 $this->client->request('GET', '/api/entries', ['since' => 1443274283]); 310 $this->client->request('GET', '/api/entries', ['since' => 1443274283]);
311 311
312 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 312 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
313 313
314 $content = json_decode($this->client->getResponse()->getContent(), true); 314 $content = json_decode($this->client->getResponse()->getContent(), true);
315 315
316 $this->assertGreaterThanOrEqual(1, count($content)); 316 $this->assertGreaterThanOrEqual(1, count($content));
317 $this->assertNotEmpty($content['_embedded']['items']); 317 $this->assertNotEmpty($content['_embedded']['items']);
318 $this->assertGreaterThanOrEqual(1, $content['total']); 318 $this->assertGreaterThanOrEqual(1, $content['total']);
319 $this->assertEquals(1, $content['page']); 319 $this->assertSame(1, $content['page']);
320 $this->assertGreaterThanOrEqual(1, $content['pages']); 320 $this->assertGreaterThanOrEqual(1, $content['pages']);
321 321
322 $this->assertArrayHasKey('_links', $content); 322 $this->assertArrayHasKey('_links', $content);
@@ -329,7 +329,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
329 $this->assertContains('since=1443274283', $content['_links'][$link]['href']); 329 $this->assertContains('since=1443274283', $content['_links'][$link]['href']);
330 } 330 }
331 331
332 $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); 332 $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
333 } 333 }
334 334
335 public function testGetDatedSupEntries() 335 public function testGetDatedSupEntries()
@@ -337,15 +337,15 @@ class EntryRestControllerTest extends WallabagApiTestCase
337 $future = new \DateTime(date('Y-m-d H:i:s')); 337 $future = new \DateTime(date('Y-m-d H:i:s'));
338 $this->client->request('GET', '/api/entries', ['since' => $future->getTimestamp() + 1000]); 338 $this->client->request('GET', '/api/entries', ['since' => $future->getTimestamp() + 1000]);
339 339
340 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 340 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
341 341
342 $content = json_decode($this->client->getResponse()->getContent(), true); 342 $content = json_decode($this->client->getResponse()->getContent(), true);
343 343
344 $this->assertGreaterThanOrEqual(1, count($content)); 344 $this->assertGreaterThanOrEqual(1, count($content));
345 $this->assertEmpty($content['_embedded']['items']); 345 $this->assertEmpty($content['_embedded']['items']);
346 $this->assertEquals(0, $content['total']); 346 $this->assertSame(0, $content['total']);
347 $this->assertEquals(1, $content['page']); 347 $this->assertSame(1, $content['page']);
348 $this->assertEquals(1, $content['pages']); 348 $this->assertSame(1, $content['pages']);
349 349
350 $this->assertArrayHasKey('_links', $content); 350 $this->assertArrayHasKey('_links', $content);
351 $this->assertArrayHasKey('self', $content['_links']); 351 $this->assertArrayHasKey('self', $content['_links']);
@@ -354,10 +354,10 @@ class EntryRestControllerTest extends WallabagApiTestCase
354 354
355 foreach (['self', 'first', 'last'] as $link) { 355 foreach (['self', 'first', 'last'] as $link) {
356 $this->assertArrayHasKey('href', $content['_links'][$link]); 356 $this->assertArrayHasKey('href', $content['_links'][$link]);
357 $this->assertContains('since='.($future->getTimestamp() + 1000), $content['_links'][$link]['href']); 357 $this->assertContains('since=' . ($future->getTimestamp() + 1000), $content['_links'][$link]['href']);
358 } 358 }
359 359
360 $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); 360 $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
361 } 361 }
362 362
363 public function testDeleteEntry() 363 public function testDeleteEntry()
@@ -371,19 +371,19 @@ class EntryRestControllerTest extends WallabagApiTestCase
371 $this->markTestSkipped('No content found in db.'); 371 $this->markTestSkipped('No content found in db.');
372 } 372 }
373 373
374 $this->client->request('DELETE', '/api/entries/'.$entry->getId().'.json'); 374 $this->client->request('DELETE', '/api/entries/' . $entry->getId() . '.json');
375 375
376 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 376 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
377 377
378 $content = json_decode($this->client->getResponse()->getContent(), true); 378 $content = json_decode($this->client->getResponse()->getContent(), true);
379 379
380 $this->assertEquals($entry->getTitle(), $content['title']); 380 $this->assertSame($entry->getTitle(), $content['title']);
381 $this->assertEquals($entry->getUrl(), $content['url']); 381 $this->assertSame($entry->getUrl(), $content['url']);
382 382
383 // We'll try to delete this entry again 383 // We'll try to delete this entry again
384 $this->client->request('DELETE', '/api/entries/'.$entry->getId().'.json'); 384 $this->client->request('DELETE', '/api/entries/' . $entry->getId() . '.json');
385 385
386 $this->assertEquals(404, $this->client->getResponse()->getStatusCode()); 386 $this->assertSame(404, $this->client->getResponse()->getStatusCode());
387 } 387 }
388 388
389 public function testPostEntry() 389 public function testPostEntry()
@@ -399,16 +399,16 @@ class EntryRestControllerTest extends WallabagApiTestCase
399 'public' => 1, 399 'public' => 1,
400 ]); 400 ]);
401 401
402 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 402 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
403 403
404 $content = json_decode($this->client->getResponse()->getContent(), true); 404 $content = json_decode($this->client->getResponse()->getContent(), true);
405 405
406 $this->assertGreaterThan(0, $content['id']); 406 $this->assertGreaterThan(0, $content['id']);
407 $this->assertEquals('http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html', $content['url']); 407 $this->assertSame('http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html', $content['url']);
408 $this->assertEquals(false, $content['is_archived']); 408 $this->assertSame(false, $content['is_archived']);
409 $this->assertEquals(false, $content['is_starred']); 409 $this->assertSame(false, $content['is_starred']);
410 $this->assertEquals('New title for my article', $content['title']); 410 $this->assertSame('New title for my article', $content['title']);
411 $this->assertEquals(1, $content['user_id']); 411 $this->assertSame(1, $content['user_id']);
412 $this->assertCount(2, $content['tags']); 412 $this->assertCount(2, $content['tags']);
413 $this->assertSame('my content', $content['content']); 413 $this->assertSame('my content', $content['content']);
414 $this->assertSame('de', $content['language']); 414 $this->assertSame('de', $content['language']);
@@ -427,14 +427,14 @@ class EntryRestControllerTest extends WallabagApiTestCase
427 'tags' => 'google, apple', 427 'tags' => 'google, apple',
428 ]); 428 ]);
429 429
430 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 430 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
431 431
432 $content = json_decode($this->client->getResponse()->getContent(), true); 432 $content = json_decode($this->client->getResponse()->getContent(), true);
433 433
434 $this->assertGreaterThan(0, $content['id']); 434 $this->assertGreaterThan(0, $content['id']);
435 $this->assertEquals('http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html', $content['url']); 435 $this->assertSame('http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html', $content['url']);
436 $this->assertEquals(true, $content['is_archived']); 436 $this->assertSame(true, $content['is_archived']);
437 $this->assertEquals(false, $content['is_starred']); 437 $this->assertSame(false, $content['is_starred']);
438 $this->assertCount(3, $content['tags']); 438 $this->assertCount(3, $content['tags']);
439 } 439 }
440 440
@@ -456,10 +456,10 @@ class EntryRestControllerTest extends WallabagApiTestCase
456 'url' => 'http://www.example.com/', 456 'url' => 'http://www.example.com/',
457 ]); 457 ]);
458 458
459 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 459 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
460 $content = json_decode($this->client->getResponse()->getContent(), true); 460 $content = json_decode($this->client->getResponse()->getContent(), true);
461 $this->assertGreaterThan(0, $content['id']); 461 $this->assertGreaterThan(0, $content['id']);
462 $this->assertEquals('http://www.example.com/', $content['url']); 462 $this->assertSame('http://www.example.com/', $content['url']);
463 } finally { 463 } finally {
464 // Remove the created entry to avoid side effects on other tests 464 // Remove the created entry to avoid side effects on other tests
465 if (isset($content['id'])) { 465 if (isset($content['id'])) {
@@ -479,15 +479,15 @@ class EntryRestControllerTest extends WallabagApiTestCase
479 'starred' => '1', 479 'starred' => '1',
480 ]); 480 ]);
481 481
482 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 482 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
483 483
484 $content = json_decode($this->client->getResponse()->getContent(), true); 484 $content = json_decode($this->client->getResponse()->getContent(), true);
485 485
486 $this->assertGreaterThan(0, $content['id']); 486 $this->assertGreaterThan(0, $content['id']);
487 $this->assertEquals('http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html', $content['url']); 487 $this->assertSame('http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html', $content['url']);
488 $this->assertEquals(true, $content['is_archived']); 488 $this->assertSame(true, $content['is_archived']);
489 $this->assertEquals(true, $content['is_starred']); 489 $this->assertSame(true, $content['is_starred']);
490 $this->assertEquals(1, $content['user_id']); 490 $this->assertSame(1, $content['user_id']);
491 } 491 }
492 492
493 public function testPostArchivedAndStarredEntryWithoutQuotes() 493 public function testPostArchivedAndStarredEntryWithoutQuotes()
@@ -498,14 +498,14 @@ class EntryRestControllerTest extends WallabagApiTestCase
498 'starred' => 1, 498 'starred' => 1,
499 ]); 499 ]);
500 500
501 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 501 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
502 502
503 $content = json_decode($this->client->getResponse()->getContent(), true); 503 $content = json_decode($this->client->getResponse()->getContent(), true);
504 504
505 $this->assertGreaterThan(0, $content['id']); 505 $this->assertGreaterThan(0, $content['id']);
506 $this->assertEquals('http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html', $content['url']); 506 $this->assertSame('http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html', $content['url']);
507 $this->assertEquals(false, $content['is_archived']); 507 $this->assertSame(false, $content['is_archived']);
508 $this->assertEquals(true, $content['is_starred']); 508 $this->assertSame(true, $content['is_starred']);
509 } 509 }
510 510
511 public function testPatchEntry() 511 public function testPatchEntry()
@@ -522,9 +522,9 @@ class EntryRestControllerTest extends WallabagApiTestCase
522 // hydrate the tags relations 522 // hydrate the tags relations
523 $nbTags = count($entry->getTags()); 523 $nbTags = count($entry->getTags());
524 524
525 $this->client->request('PATCH', '/api/entries/'.$entry->getId().'.json', [ 525 $this->client->request('PATCH', '/api/entries/' . $entry->getId() . '.json', [
526 'title' => 'New awesome title', 526 'title' => 'New awesome title',
527 'tags' => 'new tag '.uniqid(), 527 'tags' => 'new tag ' . uniqid(),
528 'starred' => '1', 528 'starred' => '1',
529 'archive' => '0', 529 'archive' => '0',
530 'language' => 'de_AT', 530 'language' => 'de_AT',
@@ -534,20 +534,20 @@ class EntryRestControllerTest extends WallabagApiTestCase
534 'public' => 0, 534 'public' => 0,
535 ]); 535 ]);
536 536
537 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 537 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
538 538
539 $content = json_decode($this->client->getResponse()->getContent(), true); 539 $content = json_decode($this->client->getResponse()->getContent(), true);
540 540
541 $this->assertEquals($entry->getId(), $content['id']); 541 $this->assertSame($entry->getId(), $content['id']);
542 $this->assertEquals($entry->getUrl(), $content['url']); 542 $this->assertSame($entry->getUrl(), $content['url']);
543 $this->assertEquals('New awesome title', $content['title']); 543 $this->assertSame('New awesome title', $content['title']);
544 $this->assertGreaterThan($nbTags, count($content['tags'])); 544 $this->assertGreaterThan($nbTags, count($content['tags']));
545 $this->assertEquals(1, $content['user_id']); 545 $this->assertSame(1, $content['user_id']);
546 $this->assertEquals('de_AT', $content['language']); 546 $this->assertSame('de_AT', $content['language']);
547 $this->assertEquals('http://preview.io/picture.jpg', $content['preview_picture']); 547 $this->assertSame('http://preview.io/picture.jpg', $content['preview_picture']);
548 $this->assertContains('sponge', $content['published_by']); 548 $this->assertContains('sponge', $content['published_by']);
549 $this->assertContains('bob', $content['published_by']); 549 $this->assertContains('bob', $content['published_by']);
550 $this->assertEquals('awesome', $content['content']); 550 $this->assertSame('awesome', $content['content']);
551 $this->assertFalse($content['is_public'], 'Entry is no more shared'); 551 $this->assertFalse($content['is_public'], 'Entry is no more shared');
552 } 552 }
553 553
@@ -565,23 +565,23 @@ class EntryRestControllerTest extends WallabagApiTestCase
565 // hydrate the tags relations 565 // hydrate the tags relations
566 $nbTags = count($entry->getTags()); 566 $nbTags = count($entry->getTags());
567 567
568 $this->client->request('PATCH', '/api/entries/'.$entry->getId().'.json', [ 568 $this->client->request('PATCH', '/api/entries/' . $entry->getId() . '.json', [
569 'title' => 'New awesome title', 569 'title' => 'New awesome title',
570 'tags' => 'new tag '.uniqid(), 570 'tags' => 'new tag ' . uniqid(),
571 'starred' => 1, 571 'starred' => 1,
572 'archive' => 0, 572 'archive' => 0,
573 'authors' => ['bob', 'sponge'], 573 'authors' => ['bob', 'sponge'],
574 ]); 574 ]);
575 575
576 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 576 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
577 577
578 $content = json_decode($this->client->getResponse()->getContent(), true); 578 $content = json_decode($this->client->getResponse()->getContent(), true);
579 579
580 $this->assertEquals($entry->getId(), $content['id']); 580 $this->assertSame($entry->getId(), $content['id']);
581 $this->assertEquals($entry->getUrl(), $content['url']); 581 $this->assertSame($entry->getUrl(), $content['url']);
582 $this->assertEquals('New awesome title', $content['title']); 582 $this->assertSame('New awesome title', $content['title']);
583 $this->assertGreaterThan($nbTags, count($content['tags'])); 583 $this->assertGreaterThan($nbTags, count($content['tags']));
584 $this->assertTrue(empty($content['published_by']), 'Authors were not saved because of an array instead of a string'); 584 $this->assertEmpty($content['published_by'], 'Authors were not saved because of an array instead of a string');
585 } 585 }
586 586
587 public function testGetTagsEntry() 587 public function testGetTagsEntry()
@@ -602,9 +602,9 @@ class EntryRestControllerTest extends WallabagApiTestCase
602 $tags[] = ['id' => $tag->getId(), 'label' => $tag->getLabel(), 'slug' => $tag->getSlug()]; 602 $tags[] = ['id' => $tag->getId(), 'label' => $tag->getLabel(), 'slug' => $tag->getSlug()];
603 } 603 }
604 604
605 $this->client->request('GET', '/api/entries/'.$entry->getId().'/tags'); 605 $this->client->request('GET', '/api/entries/' . $entry->getId() . '/tags');
606 606
607 $this->assertEquals(json_encode($tags, JSON_HEX_QUOT), $this->client->getResponse()->getContent()); 607 $this->assertSame(json_encode($tags, JSON_HEX_QUOT), $this->client->getResponse()->getContent());
608 } 608 }
609 609
610 public function testPostTagsOnEntry() 610 public function testPostTagsOnEntry()
@@ -622,14 +622,14 @@ class EntryRestControllerTest extends WallabagApiTestCase
622 622
623 $newTags = 'tag1,tag2,tag3'; 623 $newTags = 'tag1,tag2,tag3';
624 624
625 $this->client->request('POST', '/api/entries/'.$entry->getId().'/tags', ['tags' => $newTags]); 625 $this->client->request('POST', '/api/entries/' . $entry->getId() . '/tags', ['tags' => $newTags]);
626 626
627 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 627 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
628 628
629 $content = json_decode($this->client->getResponse()->getContent(), true); 629 $content = json_decode($this->client->getResponse()->getContent(), true);
630 630
631 $this->assertArrayHasKey('tags', $content); 631 $this->assertArrayHasKey('tags', $content);
632 $this->assertEquals($nbTags + 3, count($content['tags'])); 632 $this->assertSame($nbTags + 3, count($content['tags']));
633 633
634 $entryDB = $this->client->getContainer() 634 $entryDB = $this->client->getContainer()
635 ->get('doctrine.orm.entity_manager') 635 ->get('doctrine.orm.entity_manager')
@@ -662,14 +662,14 @@ class EntryRestControllerTest extends WallabagApiTestCase
662 $nbTags = count($entry->getTags()); 662 $nbTags = count($entry->getTags());
663 $tag = $entry->getTags()[0]; 663 $tag = $entry->getTags()[0];
664 664
665 $this->client->request('DELETE', '/api/entries/'.$entry->getId().'/tags/'.$tag->getId().'.json'); 665 $this->client->request('DELETE', '/api/entries/' . $entry->getId() . '/tags/' . $tag->getId() . '.json');
666 666
667 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 667 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
668 668
669 $content = json_decode($this->client->getResponse()->getContent(), true); 669 $content = json_decode($this->client->getResponse()->getContent(), true);
670 670
671 $this->assertArrayHasKey('tags', $content); 671 $this->assertArrayHasKey('tags', $content);
672 $this->assertEquals($nbTags - 1, count($content['tags'])); 672 $this->assertSame($nbTags - 1, count($content['tags']));
673 } 673 }
674 674
675 public function testSaveIsArchivedAfterPost() 675 public function testSaveIsArchivedAfterPost()
@@ -687,11 +687,11 @@ class EntryRestControllerTest extends WallabagApiTestCase
687 'url' => $entry->getUrl(), 687 'url' => $entry->getUrl(),
688 ]); 688 ]);
689 689
690 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 690 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
691 691
692 $content = json_decode($this->client->getResponse()->getContent(), true); 692 $content = json_decode($this->client->getResponse()->getContent(), true);
693 693
694 $this->assertEquals(true, $content['is_archived']); 694 $this->assertSame(true, $content['is_archived']);
695 } 695 }
696 696
697 public function testSaveIsStarredAfterPost() 697 public function testSaveIsStarredAfterPost()
@@ -709,11 +709,11 @@ class EntryRestControllerTest extends WallabagApiTestCase
709 'url' => $entry->getUrl(), 709 'url' => $entry->getUrl(),
710 ]); 710 ]);
711 711
712 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 712 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
713 713
714 $content = json_decode($this->client->getResponse()->getContent(), true); 714 $content = json_decode($this->client->getResponse()->getContent(), true);
715 715
716 $this->assertEquals(true, $content['is_starred']); 716 $this->assertSame(true, $content['is_starred']);
717 } 717 }
718 718
719 public function testSaveIsArchivedAfterPatch() 719 public function testSaveIsArchivedAfterPatch()
@@ -727,15 +727,15 @@ class EntryRestControllerTest extends WallabagApiTestCase
727 $this->markTestSkipped('No content found in db.'); 727 $this->markTestSkipped('No content found in db.');
728 } 728 }
729 729
730 $this->client->request('PATCH', '/api/entries/'.$entry->getId().'.json', [ 730 $this->client->request('PATCH', '/api/entries/' . $entry->getId() . '.json', [
731 'title' => $entry->getTitle().'++', 731 'title' => $entry->getTitle() . '++',
732 ]); 732 ]);
733 733
734 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 734 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
735 735
736 $content = json_decode($this->client->getResponse()->getContent(), true); 736 $content = json_decode($this->client->getResponse()->getContent(), true);
737 737
738 $this->assertEquals(true, $content['is_archived']); 738 $this->assertSame(true, $content['is_archived']);
739 } 739 }
740 740
741 public function testSaveIsStarredAfterPatch() 741 public function testSaveIsStarredAfterPatch()
@@ -748,15 +748,15 @@ class EntryRestControllerTest extends WallabagApiTestCase
748 if (!$entry) { 748 if (!$entry) {
749 $this->markTestSkipped('No content found in db.'); 749 $this->markTestSkipped('No content found in db.');
750 } 750 }
751 $this->client->request('PATCH', '/api/entries/'.$entry->getId().'.json', [ 751 $this->client->request('PATCH', '/api/entries/' . $entry->getId() . '.json', [
752 'title' => $entry->getTitle().'++', 752 'title' => $entry->getTitle() . '++',
753 ]); 753 ]);
754 754
755 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 755 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
756 756
757 $content = json_decode($this->client->getResponse()->getContent(), true); 757 $content = json_decode($this->client->getResponse()->getContent(), true);
758 758
759 $this->assertEquals(true, $content['is_starred']); 759 $this->assertSame(true, $content['is_starred']);
760 } 760 }
761 761
762 public function dataForEntriesExistWithUrl() 762 public function dataForEntriesExistWithUrl()
@@ -780,7 +780,7 @@ class EntryRestControllerTest extends WallabagApiTestCase
780 { 780 {
781 $this->client->request('GET', $url); 781 $this->client->request('GET', $url);
782 782
783 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 783 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
784 784
785 $content = json_decode($this->client->getResponse()->getContent(), true); 785 $content = json_decode($this->client->getResponse()->getContent(), true);
786 786
@@ -791,9 +791,9 @@ class EntryRestControllerTest extends WallabagApiTestCase
791 { 791 {
792 $url1 = 'http://0.0.0.0/entry2'; 792 $url1 = 'http://0.0.0.0/entry2';
793 $url2 = 'http://0.0.0.0/entry10'; 793 $url2 = 'http://0.0.0.0/entry10';
794 $this->client->request('GET', '/api/entries/exists?urls[]='.$url1.'&urls[]='.$url2.'&return_id=1'); 794 $this->client->request('GET', '/api/entries/exists?urls[]=' . $url1 . '&urls[]=' . $url2 . '&return_id=1');
795 795
796 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 796 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
797 797
798 $content = json_decode($this->client->getResponse()->getContent(), true); 798 $content = json_decode($this->client->getResponse()->getContent(), true);
799 799
@@ -807,9 +807,9 @@ class EntryRestControllerTest extends WallabagApiTestCase
807 { 807 {
808 $url1 = 'http://0.0.0.0/entry2'; 808 $url1 = 'http://0.0.0.0/entry2';
809 $url2 = 'http://0.0.0.0/entry10'; 809 $url2 = 'http://0.0.0.0/entry10';
810 $this->client->request('GET', '/api/entries/exists?urls[]='.$url1.'&urls[]='.$url2); 810 $this->client->request('GET', '/api/entries/exists?urls[]=' . $url1 . '&urls[]=' . $url2);
811 811
812 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 812 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
813 813
814 $content = json_decode($this->client->getResponse()->getContent(), true); 814 $content = json_decode($this->client->getResponse()->getContent(), true);
815 815
@@ -823,18 +823,18 @@ class EntryRestControllerTest extends WallabagApiTestCase
823 { 823 {
824 $this->client->request('GET', '/api/entries/exists?url=http://google.com/entry2'); 824 $this->client->request('GET', '/api/entries/exists?url=http://google.com/entry2');
825 825
826 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 826 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
827 827
828 $content = json_decode($this->client->getResponse()->getContent(), true); 828 $content = json_decode($this->client->getResponse()->getContent(), true);
829 829
830 $this->assertEquals(false, $content['exists']); 830 $this->assertSame(false, $content['exists']);
831 } 831 }
832 832
833 public function testGetEntriesExistsWithNoUrl() 833 public function testGetEntriesExistsWithNoUrl()
834 { 834 {
835 $this->client->request('GET', '/api/entries/exists?url='); 835 $this->client->request('GET', '/api/entries/exists?url=');
836 836
837 $this->assertEquals(403, $this->client->getResponse()->getStatusCode()); 837 $this->assertSame(403, $this->client->getResponse()->getStatusCode());
838 } 838 }
839 839
840 public function testReloadEntryErrorWhileFetching() 840 public function testReloadEntryErrorWhileFetching()
@@ -847,8 +847,8 @@ class EntryRestControllerTest extends WallabagApiTestCase
847 $this->markTestSkipped('No content found in db.'); 847 $this->markTestSkipped('No content found in db.');
848 } 848 }
849 849
850 $this->client->request('PATCH', '/api/entries/'.$entry->getId().'/reload.json'); 850 $this->client->request('PATCH', '/api/entries/' . $entry->getId() . '/reload.json');
851 $this->assertEquals(304, $this->client->getResponse()->getStatusCode()); 851 $this->assertSame(304, $this->client->getResponse()->getStatusCode());
852 } 852 }
853 853
854 public function testReloadEntry() 854 public function testReloadEntry()
@@ -863,14 +863,14 @@ class EntryRestControllerTest extends WallabagApiTestCase
863 863
864 $this->setUp(); 864 $this->setUp();
865 865
866 $this->client->request('PATCH', '/api/entries/'.$json['id'].'/reload.json'); 866 $this->client->request('PATCH', '/api/entries/' . $json['id'] . '/reload.json');
867 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 867 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
868 868
869 $content = json_decode($this->client->getResponse()->getContent(), true); 869 $content = json_decode($this->client->getResponse()->getContent(), true);
870 870
871 $this->assertNotEmpty($content['title']); 871 $this->assertNotEmpty($content['title']);
872 872
873 $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); 873 $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
874 } 874 }
875 875
876 public function testPostEntriesTagsListAction() 876 public function testPostEntriesTagsListAction()
@@ -890,14 +890,14 @@ class EntryRestControllerTest extends WallabagApiTestCase
890 ], 890 ],
891 ]; 891 ];
892 892
893 $this->client->request('POST', '/api/entries/tags/lists?list='.json_encode($list)); 893 $this->client->request('POST', '/api/entries/tags/lists?list=' . json_encode($list));
894 894
895 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 895 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
896 896
897 $content = json_decode($this->client->getResponse()->getContent(), true); 897 $content = json_decode($this->client->getResponse()->getContent(), true);
898 898
899 $this->assertInternalType('int', $content[0]['entry']); 899 $this->assertInternalType('int', $content[0]['entry']);
900 $this->assertEquals('http://0.0.0.0/entry4', $content[0]['url']); 900 $this->assertSame('http://0.0.0.0/entry4', $content[0]['url']);
901 901
902 $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager') 902 $entry = $this->client->getContainer()->get('doctrine.orm.entity_manager')
903 ->getRepository('WallabagCoreBundle:Entry') 903 ->getRepository('WallabagCoreBundle:Entry')
@@ -926,8 +926,8 @@ class EntryRestControllerTest extends WallabagApiTestCase
926 ], 926 ],
927 ]; 927 ];
928 928
929 $this->client->request('DELETE', '/api/entries/tags/list?list='.json_encode($list)); 929 $this->client->request('DELETE', '/api/entries/tags/list?list=' . json_encode($list));
930 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 930 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
931 931
932 $entry = $em->getRepository('WallabagCoreBundle:Entry')->find($entry->getId()); 932 $entry = $em->getRepository('WallabagCoreBundle:Entry')->find($entry->getId());
933 $this->assertCount(0, $entry->getTags()); 933 $this->assertCount(0, $entry->getTags());
@@ -940,17 +940,17 @@ class EntryRestControllerTest extends WallabagApiTestCase
940 'http://0.0.0.0/entry2', 940 'http://0.0.0.0/entry2',
941 ]; 941 ];
942 942
943 $this->client->request('POST', '/api/entries/lists?urls='.json_encode($list)); 943 $this->client->request('POST', '/api/entries/lists?urls=' . json_encode($list));
944 944
945 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 945 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
946 946
947 $content = json_decode($this->client->getResponse()->getContent(), true); 947 $content = json_decode($this->client->getResponse()->getContent(), true);
948 948
949 $this->assertInternalType('int', $content[0]['entry']); 949 $this->assertInternalType('int', $content[0]['entry']);
950 $this->assertEquals('http://www.lemonde.fr/musiques/article/2017/04/23/loin-de-la-politique-le-printemps-de-bourges-retombe-en-enfance_5115862_1654986.html', $content[0]['url']); 950 $this->assertSame('http://www.lemonde.fr/musiques/article/2017/04/23/loin-de-la-politique-le-printemps-de-bourges-retombe-en-enfance_5115862_1654986.html', $content[0]['url']);
951 951
952 $this->assertInternalType('int', $content[1]['entry']); 952 $this->assertInternalType('int', $content[1]['entry']);
953 $this->assertEquals('http://0.0.0.0/entry2', $content[1]['url']); 953 $this->assertSame('http://0.0.0.0/entry2', $content[1]['url']);
954 } 954 }
955 955
956 public function testDeleteEntriesListAction() 956 public function testDeleteEntriesListAction()
@@ -965,17 +965,17 @@ class EntryRestControllerTest extends WallabagApiTestCase
965 'http://0.0.0.0/test-entry-not-exist', 965 'http://0.0.0.0/test-entry-not-exist',
966 ]; 966 ];
967 967
968 $this->client->request('DELETE', '/api/entries/list?urls='.json_encode($list)); 968 $this->client->request('DELETE', '/api/entries/list?urls=' . json_encode($list));
969 969
970 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 970 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
971 971
972 $content = json_decode($this->client->getResponse()->getContent(), true); 972 $content = json_decode($this->client->getResponse()->getContent(), true);
973 973
974 $this->assertTrue($content[0]['entry']); 974 $this->assertTrue($content[0]['entry']);
975 $this->assertEquals('http://0.0.0.0/test-entry1', $content[0]['url']); 975 $this->assertSame('http://0.0.0.0/test-entry1', $content[0]['url']);
976 976
977 $this->assertFalse($content[1]['entry']); 977 $this->assertFalse($content[1]['entry']);
978 $this->assertEquals('http://0.0.0.0/test-entry-not-exist', $content[1]['url']); 978 $this->assertSame('http://0.0.0.0/test-entry-not-exist', $content[1]['url']);
979 } 979 }
980 980
981 public function testLimitBulkAction() 981 public function testLimitBulkAction()
@@ -994,9 +994,9 @@ class EntryRestControllerTest extends WallabagApiTestCase
994 'http://0.0.0.0/entry1', 994 'http://0.0.0.0/entry1',
995 ]; 995 ];
996 996
997 $this->client->request('POST', '/api/entries/lists?urls='.json_encode($list)); 997 $this->client->request('POST', '/api/entries/lists?urls=' . json_encode($list));
998 998
999 $this->assertEquals(400, $this->client->getResponse()->getStatusCode()); 999 $this->assertSame(400, $this->client->getResponse()->getStatusCode());
1000 $this->assertContains('API limit reached', $this->client->getResponse()->getContent()); 1000 $this->assertContains('API limit reached', $this->client->getResponse()->getContent());
1001 } 1001 }
1002} 1002}
diff --git a/tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php
index 7f69bd67..430e548d 100644
--- a/tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php
+++ b/tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php
@@ -11,7 +11,7 @@ class TagRestControllerTest extends WallabagApiTestCase
11 { 11 {
12 $this->client->request('GET', '/api/tags.json'); 12 $this->client->request('GET', '/api/tags.json');
13 13
14 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 14 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
15 15
16 $content = json_decode($this->client->getResponse()->getContent(), true); 16 $content = json_decode($this->client->getResponse()->getContent(), true);
17 17
@@ -33,15 +33,15 @@ class TagRestControllerTest extends WallabagApiTestCase
33 $em->flush(); 33 $em->flush();
34 $em->clear(); 34 $em->clear();
35 35
36 $this->client->request('DELETE', '/api/tags/'.$tag->getId().'.json'); 36 $this->client->request('DELETE', '/api/tags/' . $tag->getId() . '.json');
37 37
38 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 38 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
39 39
40 $content = json_decode($this->client->getResponse()->getContent(), true); 40 $content = json_decode($this->client->getResponse()->getContent(), true);
41 41
42 $this->assertArrayHasKey('label', $content); 42 $this->assertArrayHasKey('label', $content);
43 $this->assertEquals($tag->getLabel(), $content['label']); 43 $this->assertSame($tag->getLabel(), $content['label']);
44 $this->assertEquals($tag->getSlug(), $content['slug']); 44 $this->assertSame($tag->getSlug(), $content['slug']);
45 45
46 $entries = $em->getRepository('WallabagCoreBundle:Entry') 46 $entries = $em->getRepository('WallabagCoreBundle:Entry')
47 ->findAllByTagId($this->user->getId(), $tag->getId()); 47 ->findAllByTagId($this->user->getId(), $tag->getId());
@@ -50,7 +50,7 @@ class TagRestControllerTest extends WallabagApiTestCase
50 50
51 $tag = $em->getRepository('WallabagCoreBundle:Tag')->findOneByLabel($tagLabel); 51 $tag = $em->getRepository('WallabagCoreBundle:Tag')->findOneByLabel($tagLabel);
52 52
53 $this->assertNull($tag, $tagLabel.' was removed because it begun an orphan tag'); 53 $this->assertNull($tag, $tagLabel . ' was removed because it begun an orphan tag');
54 } 54 }
55 55
56 public function dataForDeletingTagByLabel() 56 public function dataForDeletingTagByLabel()
@@ -84,18 +84,18 @@ class TagRestControllerTest extends WallabagApiTestCase
84 $em->flush(); 84 $em->flush();
85 85
86 if ($useQueryString) { 86 if ($useQueryString) {
87 $this->client->request('DELETE', '/api/tag/label.json?tag='.$tag->getLabel()); 87 $this->client->request('DELETE', '/api/tag/label.json?tag=' . $tag->getLabel());
88 } else { 88 } else {
89 $this->client->request('DELETE', '/api/tag/label.json', ['tag' => $tag->getLabel()]); 89 $this->client->request('DELETE', '/api/tag/label.json', ['tag' => $tag->getLabel()]);
90 } 90 }
91 91
92 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 92 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
93 93
94 $content = json_decode($this->client->getResponse()->getContent(), true); 94 $content = json_decode($this->client->getResponse()->getContent(), true);
95 95
96 $this->assertArrayHasKey('label', $content); 96 $this->assertArrayHasKey('label', $content);
97 $this->assertEquals($tag->getLabel(), $content['label']); 97 $this->assertSame($tag->getLabel(), $content['label']);
98 $this->assertEquals($tag->getSlug(), $content['slug']); 98 $this->assertSame($tag->getSlug(), $content['slug']);
99 99
100 $entries = $this->client->getContainer() 100 $entries = $this->client->getContainer()
101 ->get('doctrine.orm.entity_manager') 101 ->get('doctrine.orm.entity_manager')
@@ -109,7 +109,7 @@ class TagRestControllerTest extends WallabagApiTestCase
109 { 109 {
110 $this->client->request('DELETE', '/api/tag/label.json', ['tag' => 'does not exist']); 110 $this->client->request('DELETE', '/api/tag/label.json', ['tag' => 'does not exist']);
111 111
112 $this->assertEquals(404, $this->client->getResponse()->getStatusCode()); 112 $this->assertSame(404, $this->client->getResponse()->getStatusCode());
113 } 113 }
114 114
115 /** 115 /**
@@ -140,24 +140,24 @@ class TagRestControllerTest extends WallabagApiTestCase
140 $em->flush(); 140 $em->flush();
141 141
142 if ($useQueryString) { 142 if ($useQueryString) {
143 $this->client->request('DELETE', '/api/tags/label.json?tags='.$tag->getLabel().','.$tag2->getLabel()); 143 $this->client->request('DELETE', '/api/tags/label.json?tags=' . $tag->getLabel() . ',' . $tag2->getLabel());
144 } else { 144 } else {
145 $this->client->request('DELETE', '/api/tags/label.json', ['tags' => $tag->getLabel().','.$tag2->getLabel()]); 145 $this->client->request('DELETE', '/api/tags/label.json', ['tags' => $tag->getLabel() . ',' . $tag2->getLabel()]);
146 } 146 }
147 147
148 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 148 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
149 149
150 $content = json_decode($this->client->getResponse()->getContent(), true); 150 $content = json_decode($this->client->getResponse()->getContent(), true);
151 151
152 $this->assertCount(2, $content); 152 $this->assertCount(2, $content);
153 153
154 $this->assertArrayHasKey('label', $content[0]); 154 $this->assertArrayHasKey('label', $content[0]);
155 $this->assertEquals($tag->getLabel(), $content[0]['label']); 155 $this->assertSame($tag->getLabel(), $content[0]['label']);
156 $this->assertEquals($tag->getSlug(), $content[0]['slug']); 156 $this->assertSame($tag->getSlug(), $content[0]['slug']);
157 157
158 $this->assertArrayHasKey('label', $content[1]); 158 $this->assertArrayHasKey('label', $content[1]);
159 $this->assertEquals($tag2->getLabel(), $content[1]['label']); 159 $this->assertSame($tag2->getLabel(), $content[1]['label']);
160 $this->assertEquals($tag2->getSlug(), $content[1]['slug']); 160 $this->assertSame($tag2->getSlug(), $content[1]['slug']);
161 161
162 $entries = $this->client->getContainer() 162 $entries = $this->client->getContainer()
163 ->get('doctrine.orm.entity_manager') 163 ->get('doctrine.orm.entity_manager')
@@ -178,6 +178,6 @@ class TagRestControllerTest extends WallabagApiTestCase
178 { 178 {
179 $this->client->request('DELETE', '/api/tags/label.json', ['tags' => 'does not exist']); 179 $this->client->request('DELETE', '/api/tags/label.json', ['tags' => 'does not exist']);
180 180
181 $this->assertEquals(404, $this->client->getResponse()->getStatusCode()); 181 $this->assertSame(404, $this->client->getResponse()->getStatusCode());
182 } 182 }
183} 183}
diff --git a/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php
index 4e65f130..51fac2bd 100644
--- a/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php
+++ b/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php
@@ -9,7 +9,7 @@ class UserRestControllerTest extends WallabagApiTestCase
9 public function testGetUser() 9 public function testGetUser()
10 { 10 {
11 $this->client->request('GET', '/api/user.json'); 11 $this->client->request('GET', '/api/user.json');
12 $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); 12 $this->assertSame(200, $this->client->getResponse()->getStatusCode());
13 13
14 $content = json_decode($this->client->getResponse()->getContent(), true); 14 $content = json_decode($this->client->getResponse()->getContent(), true);
15 15
@@ -20,27 +20,27 @@ class UserRestControllerTest extends WallabagApiTestCase
20 $this->assertArrayHasKey('created_at', $content); 20 $this->assertArrayHasKey('created_at', $content);
21 $this->assertArrayHasKey('updated_at', $content); 21 $this->assertArrayHasKey('updated_at', $content);
22 22
23 $this->assertEquals('bigboss@wallabag.org', $content['email']); 23 $this->assertSame('bigboss@wallabag.org', $content['email']);
24 $this->assertEquals('Big boss', $content['name']); 24 $this->assertSame('Big boss', $content['name']);
25 $this->assertEquals('admin', $content['username']); 25 $this->assertSame('admin', $content['username']);
26 26
27 $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); 27 $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
28 } 28 }
29 29
30 public function testGetUserWithoutAuthentication() 30 public function testGetUserWithoutAuthentication()
31 { 31 {
32 $client = static::createClient(); 32 $client = static::createClient();
33 $client->request('GET', '/api/user.json'); 33 $client->request('GET', '/api/user.json');
34 $this->assertEquals(401, $client->getResponse()->getStatusCode()); 34 $this->assertSame(401, $client->getResponse()->getStatusCode());
35 35
36 $content = json_decode($client->getResponse()->getContent(), true); 36 $content = json_decode($client->getResponse()->getContent(), true);
37 37
38 $this->assertArrayHasKey('error', $content); 38 $this->assertArrayHasKey('error', $content);
39 $this->assertArrayHasKey('error_description', $content); 39 $this->assertArrayHasKey('error_description', $content);
40 40
41 $this->assertEquals('access_denied', $content['error']); 41 $this->assertSame('access_denied', $content['error']);
42 42
43 $this->assertEquals('application/json', $client->getResponse()->headers->get('Content-Type')); 43 $this->assertSame('application/json', $client->getResponse()->headers->get('Content-Type'));
44 } 44 }
45 45
46 public function testCreateNewUser() 46 public function testCreateNewUser()
@@ -52,7 +52,7 @@ class UserRestControllerTest extends WallabagApiTestCase
52 'email' => 'wallabag@google.com', 52 'email' => 'wallabag@google.com',
53 ]); 53 ]);
54 54
55 $this->assertEquals(201, $this->client->getResponse()->getStatusCode()); 55 $this->assertSame(201, $this->client->getResponse()->getStatusCode());
56 56
57 $content = json_decode($this->client->getResponse()->getContent(), true); 57 $content = json_decode($this->client->getResponse()->getContent(), true);
58 58
@@ -63,15 +63,15 @@ class UserRestControllerTest extends WallabagApiTestCase
63 $this->assertArrayHasKey('updated_at', $content); 63 $this->assertArrayHasKey('updated_at', $content);
64 $this->assertArrayHasKey('default_client', $content); 64 $this->assertArrayHasKey('default_client', $content);
65 65
66 $this->assertEquals('wallabag@google.com', $content['email']); 66 $this->assertSame('wallabag@google.com', $content['email']);
67 $this->assertEquals('google', $content['username']); 67 $this->assertSame('google', $content['username']);
68 68
69 $this->assertArrayHasKey('client_secret', $content['default_client']); 69 $this->assertArrayHasKey('client_secret', $content['default_client']);
70 $this->assertArrayHasKey('client_id', $content['default_client']); 70 $this->assertArrayHasKey('client_id', $content['default_client']);
71 71
72 $this->assertEquals('Default client', $content['default_client']['name']); 72 $this->assertSame('Default client', $content['default_client']['name']);
73 73
74 $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); 74 $this->assertSame('application/json', $this->client->getResponse()->headers->get('Content-Type'));
75 75
76 $this->client->getContainer()->get('craue_config')->set('api_user_registration', 0); 76 $this->client->getContainer()->get('craue_config')->set('api_user_registration', 0);
77 } 77 }
@@ -88,7 +88,7 @@ class UserRestControllerTest extends WallabagApiTestCase
88 'client_name' => 'My client name !!', 88 'client_name' => 'My client name !!',
89 ]); 89 ]);
90 90
91 $this->assertEquals(201, $client->getResponse()->getStatusCode()); 91 $this->assertSame(201, $client->getResponse()->getStatusCode());
92 92
93 $content = json_decode($client->getResponse()->getContent(), true); 93 $content = json_decode($client->getResponse()->getContent(), true);
94 94
@@ -99,15 +99,15 @@ class UserRestControllerTest extends WallabagApiTestCase
99 $this->assertArrayHasKey('updated_at', $content); 99 $this->assertArrayHasKey('updated_at', $content);
100 $this->assertArrayHasKey('default_client', $content); 100 $this->assertArrayHasKey('default_client', $content);
101 101
102 $this->assertEquals('wallabag@google.com', $content['email']); 102 $this->assertSame('wallabag@google.com', $content['email']);
103 $this->assertEquals('google', $content['username']); 103 $this->assertSame('google', $content['username']);
104 104
105 $this->assertArrayHasKey('client_secret', $content['default_client']); 105 $this->assertArrayHasKey('client_secret', $content['default_client']);
106 $this->assertArrayHasKey('client_id', $content['default_client']); 106 $this->assertArrayHasKey('client_id', $content['default_client']);
107 107
108 $this->assertEquals('My client name !!', $content['default_client']['name']); 108 $this->assertSame('My client name !!', $content['default_client']['name']);
109 109
110 $this->assertEquals('application/json', $client->getResponse()->headers->get('Content-Type')); 110 $this->assertSame('application/json', $client->getResponse()->headers->get('Content-Type'));
111 111
112 $client->getContainer()->get('craue_config')->set('api_user_registration', 0); 112 $client->getContainer()->get('craue_config')->set('api_user_registration', 0);
113 } 113 }
@@ -122,7 +122,7 @@ class UserRestControllerTest extends WallabagApiTestCase
122 'email' => 'bigboss@wallabag.org', 122 'email' => 'bigboss@wallabag.org',
123 ]); 123 ]);
124 124
125 $this->assertEquals(400, $client->getResponse()->getStatusCode()); 125 $this->assertSame(400, $client->getResponse()->getStatusCode());
126 126
127 $content = json_decode($client->getResponse()->getContent(), true); 127 $content = json_decode($client->getResponse()->getContent(), true);
128 128
@@ -133,10 +133,10 @@ class UserRestControllerTest extends WallabagApiTestCase
133 // $this->assertEquals('fos_user.username.already_used', $content['error']['username'][0]); 133 // $this->assertEquals('fos_user.username.already_used', $content['error']['username'][0]);
134 // $this->assertEquals('fos_user.email.already_used', $content['error']['email'][0]); 134 // $this->assertEquals('fos_user.email.already_used', $content['error']['email'][0]);
135 // This shouldn't be translated ... 135 // This shouldn't be translated ...
136 $this->assertEquals('This value is already used.', $content['error']['username'][0]); 136 $this->assertSame('This value is already used.', $content['error']['username'][0]);
137 $this->assertEquals('This value is already used.', $content['error']['email'][0]); 137 $this->assertSame('This value is already used.', $content['error']['email'][0]);
138 138
139 $this->assertEquals('application/json', $client->getResponse()->headers->get('Content-Type')); 139 $this->assertSame('application/json', $client->getResponse()->headers->get('Content-Type'));
140 140
141 $client->getContainer()->get('craue_config')->set('api_user_registration', 0); 141 $client->getContainer()->get('craue_config')->set('api_user_registration', 0);
142 } 142 }
@@ -151,16 +151,16 @@ class UserRestControllerTest extends WallabagApiTestCase
151 'email' => 'facebook@wallabag.org', 151 'email' => 'facebook@wallabag.org',
152 ]); 152 ]);
153 153
154 $this->assertEquals(400, $client->getResponse()->getStatusCode()); 154 $this->assertSame(400, $client->getResponse()->getStatusCode());
155 155
156 $content = json_decode($client->getResponse()->getContent(), true); 156 $content = json_decode($client->getResponse()->getContent(), true);
157 157
158 $this->assertArrayHasKey('error', $content); 158 $this->assertArrayHasKey('error', $content);
159 $this->assertArrayHasKey('password', $content['error']); 159 $this->assertArrayHasKey('password', $content['error']);
160 160
161 $this->assertEquals('validator.password_too_short', $content['error']['password'][0]); 161 $this->assertSame('validator.password_too_short', $content['error']['password'][0]);
162 162
163 $this->assertEquals('application/json', $client->getResponse()->headers->get('Content-Type')); 163 $this->assertSame('application/json', $client->getResponse()->headers->get('Content-Type'));
164 164
165 $client->getContainer()->get('craue_config')->set('api_user_registration', 0); 165 $client->getContainer()->get('craue_config')->set('api_user_registration', 0);
166 } 166 }
@@ -174,12 +174,12 @@ class UserRestControllerTest extends WallabagApiTestCase
174 'email' => 'facebook@wallabag.org', 174 'email' => 'facebook@wallabag.org',
175 ]); 175 ]);
176 176
177 $this->assertEquals(403, $client->getResponse()->getStatusCode()); 177 $this->assertSame(403, $client->getResponse()->getStatusCode());
178 178
179 $content = json_decode($client->getResponse()->getContent(), true); 179 $content = json_decode($client->getResponse()->getContent(), true);
180 180
181 $this->assertArrayHasKey('error', $content); 181 $this->assertArrayHasKey('error', $content);
182 182
183 $this->assertEquals('application/json', $client->getResponse()->headers->get('Content-Type')); 183 $this->assertSame('application/json', $client->getResponse()->headers->get('Content-Type'));
184 } 184 }
185} 185}
diff --git a/tests/Wallabag/ApiBundle/Controller/WallabagRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/WallabagRestControllerTest.php
index df638e8f..ac4d6cdc 100644
--- a/tests/Wallabag/ApiBundle/Controller/WallabagRestControllerTest.php
+++ b/tests/Wallabag/ApiBundle/Controller/WallabagRestControllerTest.php
@@ -12,10 +12,10 @@ class WallabagRestControllerTest extends WallabagApiTestCase
12 $client = static::createClient(); 12 $client = static::createClient();
13 $client->request('GET', '/api/version'); 13 $client->request('GET', '/api/version');
14 14
15 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 15 $this->assertSame(200, $client->getResponse()->getStatusCode());
16 16
17 $content = json_decode($client->getResponse()->getContent(), true); 17 $content = json_decode($client->getResponse()->getContent(), true);
18 18
19 $this->assertEquals($client->getContainer()->getParameter('wallabag_core.version'), $content); 19 $this->assertSame($client->getContainer()->getParameter('wallabag_core.version'), $content);
20 } 20 }
21} 21}
diff --git a/tests/Wallabag/ApiBundle/WallabagApiTestCase.php b/tests/Wallabag/ApiBundle/WallabagApiTestCase.php
index 8709da70..8a188e1c 100644
--- a/tests/Wallabag/ApiBundle/WallabagApiTestCase.php
+++ b/tests/Wallabag/ApiBundle/WallabagApiTestCase.php
@@ -40,7 +40,7 @@ abstract class WallabagApiTestCase extends WebTestCase
40 $loginManager->logInUser($firewallName, $this->user); 40 $loginManager->logInUser($firewallName, $this->user);
41 41
42 // save the login token into the session and put it in a cookie 42 // save the login token into the session and put it in a cookie
43 $container->get('session')->set('_security_'.$firewallName, serialize($container->get('security.token_storage')->getToken())); 43 $container->get('session')->set('_security_' . $firewallName, serialize($container->get('security.token_storage')->getToken()));
44 $container->get('session')->save(); 44 $container->get('session')->save();
45 45
46 $session = $container->get('session'); 46 $session = $container->get('session');
diff --git a/tests/Wallabag/CoreBundle/Command/CleanDuplicatesCommandTest.php b/tests/Wallabag/CoreBundle/Command/CleanDuplicatesCommandTest.php
index e6e57f30..38e8dd07 100644
--- a/tests/Wallabag/CoreBundle/Command/CleanDuplicatesCommandTest.php
+++ b/tests/Wallabag/CoreBundle/Command/CleanDuplicatesCommandTest.php
@@ -4,8 +4,8 @@ namespace Tests\Wallabag\CoreBundle\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\CoreBundle\Command\CleanDuplicatesCommand;
8use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; 7use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
8use Wallabag\CoreBundle\Command\CleanDuplicatesCommand;
9use Wallabag\CoreBundle\Entity\Entry; 9use Wallabag\CoreBundle\Entity\Entry;
10 10
11class CleanDuplicatesCommandTest extends WallabagCoreTestCase 11class CleanDuplicatesCommandTest extends WallabagCoreTestCase
diff --git a/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php b/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php
index 2eebf39b..25de2730 100644
--- a/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php
+++ b/tests/Wallabag/CoreBundle/Command/ExportCommandTest.php
@@ -4,8 +4,8 @@ namespace Tests\Wallabag\CoreBundle\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\CoreBundle\Command\ExportCommand;
8use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; 7use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
8use Wallabag\CoreBundle\Command\ExportCommand;
9 9
10class ExportCommandTest extends WallabagCoreTestCase 10class ExportCommandTest extends WallabagCoreTestCase
11{ 11{
diff --git a/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php b/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php
index 94fc0b94..f684a206 100644
--- a/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php
+++ b/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php
@@ -11,9 +11,9 @@ use Symfony\Bundle\FrameworkBundle\Console\Application;
11use Symfony\Component\Console\Input\ArrayInput; 11use Symfony\Component\Console\Input\ArrayInput;
12use Symfony\Component\Console\Output\NullOutput; 12use Symfony\Component\Console\Output\NullOutput;
13use Symfony\Component\Console\Tester\CommandTester; 13use Symfony\Component\Console\Tester\CommandTester;
14use Wallabag\CoreBundle\Command\InstallCommand;
15use Tests\Wallabag\CoreBundle\Mock\InstallCommandMock; 14use Tests\Wallabag\CoreBundle\Mock\InstallCommandMock;
16use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; 15use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
16use Wallabag\CoreBundle\Command\InstallCommand;
17 17
18class InstallCommandTest extends WallabagCoreTestCase 18class InstallCommandTest extends WallabagCoreTestCase
19{ 19{
@@ -86,9 +86,9 @@ class InstallCommandTest extends WallabagCoreTestCase
86 $tester->setInputs([ 86 $tester->setInputs([
87 'y', // dropping database 87 'y', // dropping database
88 'y', // create super admin 88 'y', // create super admin
89 'username_'.uniqid('', true), // username 89 'username_' . uniqid('', true), // username
90 'password_'.uniqid('', true), // password 90 'password_' . uniqid('', true), // password
91 'email_'.uniqid('', true).'@wallabag.it', // email 91 'email_' . uniqid('', true) . '@wallabag.it', // email
92 ]); 92 ]);
93 $tester->execute([ 93 $tester->execute([
94 'command' => $command->getName(), 94 'command' => $command->getName(),
@@ -111,9 +111,9 @@ class InstallCommandTest extends WallabagCoreTestCase
111 $tester = new CommandTester($command); 111 $tester = new CommandTester($command);
112 $tester->setInputs([ 112 $tester->setInputs([
113 'y', // create super admin 113 'y', // create super admin
114 'username_'.uniqid('', true), // username 114 'username_' . uniqid('', true), // username
115 'password_'.uniqid('', true), // password 115 'password_' . uniqid('', true), // password
116 'email_'.uniqid('', true).'@wallabag.it', // email 116 'email_' . uniqid('', true) . '@wallabag.it', // email
117 ]); 117 ]);
118 $tester->execute([ 118 $tester->execute([
119 'command' => $command->getName(), 119 'command' => $command->getName(),
@@ -159,9 +159,9 @@ class InstallCommandTest extends WallabagCoreTestCase
159 $tester = new CommandTester($command); 159 $tester = new CommandTester($command);
160 $tester->setInputs([ 160 $tester->setInputs([
161 'y', // create super admin 161 'y', // create super admin
162 'username_'.uniqid('', true), // username 162 'username_' . uniqid('', true), // username
163 'password_'.uniqid('', true), // password 163 'password_' . uniqid('', true), // password
164 'email_'.uniqid('', true).'@wallabag.it', // email 164 'email_' . uniqid('', true) . '@wallabag.it', // email
165 ]); 165 ]);
166 $tester->execute([ 166 $tester->execute([
167 'command' => $command->getName(), 167 'command' => $command->getName(),
diff --git a/tests/Wallabag/CoreBundle/Command/TagAllCommandTest.php b/tests/Wallabag/CoreBundle/Command/TagAllCommandTest.php
index 4cde3679..96d0e91f 100644
--- a/tests/Wallabag/CoreBundle/Command/TagAllCommandTest.php
+++ b/tests/Wallabag/CoreBundle/Command/TagAllCommandTest.php
@@ -4,8 +4,8 @@ namespace Tests\Wallabag\CoreBundle\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\CoreBundle\Command\TagAllCommand;
8use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; 7use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
8use Wallabag\CoreBundle\Command\TagAllCommand;
9 9
10class TagAllCommandTest extends WallabagCoreTestCase 10class TagAllCommandTest extends WallabagCoreTestCase
11{ 11{
diff --git a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
index 5bc815ee..e4bf0998 100644
--- a/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/ConfigControllerTest.php
@@ -3,11 +3,11 @@
3namespace tests\Wallabag\CoreBundle\Controller; 3namespace tests\Wallabag\CoreBundle\Controller;
4 4
5use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; 5use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
6use Wallabag\AnnotationBundle\Entity\Annotation;
6use Wallabag\CoreBundle\Entity\Config; 7use Wallabag\CoreBundle\Entity\Config;
7use Wallabag\UserBundle\Entity\User;
8use Wallabag\CoreBundle\Entity\Entry; 8use Wallabag\CoreBundle\Entity\Entry;
9use Wallabag\CoreBundle\Entity\Tag; 9use Wallabag\CoreBundle\Entity\Tag;
10use Wallabag\AnnotationBundle\Entity\Annotation; 10use Wallabag\UserBundle\Entity\User;
11 11
12class ConfigControllerTest extends WallabagCoreTestCase 12class ConfigControllerTest extends WallabagCoreTestCase
13{ 13{
@@ -17,7 +17,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
17 17
18 $client->request('GET', '/new'); 18 $client->request('GET', '/new');
19 19
20 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 20 $this->assertSame(302, $client->getResponse()->getStatusCode());
21 $this->assertContains('login', $client->getResponse()->headers->get('location')); 21 $this->assertContains('login', $client->getResponse()->headers->get('location'));
22 } 22 }
23 23
@@ -28,7 +28,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
28 28
29 $crawler = $client->request('GET', '/config'); 29 $crawler = $client->request('GET', '/config');
30 30
31 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 31 $this->assertSame(200, $client->getResponse()->getStatusCode());
32 32
33 $this->assertCount(1, $crawler->filter('button[id=config_save]')); 33 $this->assertCount(1, $crawler->filter('button[id=config_save]'));
34 $this->assertCount(1, $crawler->filter('button[id=change_passwd_save]')); 34 $this->assertCount(1, $crawler->filter('button[id=change_passwd_save]'));
@@ -43,7 +43,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
43 43
44 $crawler = $client->request('GET', '/config'); 44 $crawler = $client->request('GET', '/config');
45 45
46 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 46 $this->assertSame(200, $client->getResponse()->getStatusCode());
47 47
48 $form = $crawler->filter('button[id=config_save]')->form(); 48 $form = $crawler->filter('button[id=config_save]')->form();
49 49
@@ -57,7 +57,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
57 57
58 $client->submit($form, $data); 58 $client->submit($form, $data);
59 59
60 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 60 $this->assertSame(302, $client->getResponse()->getStatusCode());
61 61
62 $crawler = $client->followRedirect(); 62 $crawler = $client->followRedirect();
63 63
@@ -131,13 +131,13 @@ class ConfigControllerTest extends WallabagCoreTestCase
131 131
132 $crawler = $client->request('GET', '/config'); 132 $crawler = $client->request('GET', '/config');
133 133
134 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 134 $this->assertSame(200, $client->getResponse()->getStatusCode());
135 135
136 $form = $crawler->filter('button[id=config_save]')->form(); 136 $form = $crawler->filter('button[id=config_save]')->form();
137 137
138 $crawler = $client->submit($form, $data); 138 $crawler = $client->submit($form, $data);
139 139
140 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 140 $this->assertSame(200, $client->getResponse()->getStatusCode());
141 141
142 $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(['_text'])); 142 $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(['_text']));
143 $this->assertContains('This value should not be blank', $alert[0]); 143 $this->assertContains('This value should not be blank', $alert[0]);
@@ -191,13 +191,13 @@ class ConfigControllerTest extends WallabagCoreTestCase
191 191
192 $crawler = $client->request('GET', '/config'); 192 $crawler = $client->request('GET', '/config');
193 193
194 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 194 $this->assertSame(200, $client->getResponse()->getStatusCode());
195 195
196 $form = $crawler->filter('button[id=change_passwd_save]')->form(); 196 $form = $crawler->filter('button[id=change_passwd_save]')->form();
197 197
198 $crawler = $client->submit($form, $data); 198 $crawler = $client->submit($form, $data);
199 199
200 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 200 $this->assertSame(200, $client->getResponse()->getStatusCode());
201 201
202 $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(['_text'])); 202 $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(['_text']));
203 $this->assertContains($expectedMessage, $alert[0]); 203 $this->assertContains($expectedMessage, $alert[0]);
@@ -210,7 +210,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
210 210
211 $crawler = $client->request('GET', '/config'); 211 $crawler = $client->request('GET', '/config');
212 212
213 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 213 $this->assertSame(200, $client->getResponse()->getStatusCode());
214 214
215 $form = $crawler->filter('button[id=change_passwd_save]')->form(); 215 $form = $crawler->filter('button[id=change_passwd_save]')->form();
216 216
@@ -222,7 +222,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
222 222
223 $client->submit($form, $data); 223 $client->submit($form, $data);
224 224
225 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 225 $this->assertSame(302, $client->getResponse()->getStatusCode());
226 226
227 $crawler = $client->followRedirect(); 227 $crawler = $client->followRedirect();
228 228
@@ -259,13 +259,13 @@ class ConfigControllerTest extends WallabagCoreTestCase
259 259
260 $crawler = $client->request('GET', '/config'); 260 $crawler = $client->request('GET', '/config');
261 261
262 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 262 $this->assertSame(200, $client->getResponse()->getStatusCode());
263 263
264 $form = $crawler->filter('button[id=update_user_save]')->form(); 264 $form = $crawler->filter('button[id=update_user_save]')->form();
265 265
266 $crawler = $client->submit($form, $data); 266 $crawler = $client->submit($form, $data);
267 267
268 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 268 $this->assertSame(200, $client->getResponse()->getStatusCode());
269 269
270 $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(['_text'])); 270 $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(['_text']));
271 $this->assertContains($expectedMessage, $alert[0]); 271 $this->assertContains($expectedMessage, $alert[0]);
@@ -278,7 +278,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
278 278
279 $crawler = $client->request('GET', '/config'); 279 $crawler = $client->request('GET', '/config');
280 280
281 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 281 $this->assertSame(200, $client->getResponse()->getStatusCode());
282 282
283 $form = $crawler->filter('button[id=update_user_save]')->form(); 283 $form = $crawler->filter('button[id=update_user_save]')->form();
284 284
@@ -289,7 +289,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
289 289
290 $client->submit($form, $data); 290 $client->submit($form, $data);
291 291
292 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 292 $this->assertSame(302, $client->getResponse()->getStatusCode());
293 293
294 $crawler = $client->followRedirect(); 294 $crawler = $client->followRedirect();
295 295
@@ -319,13 +319,13 @@ class ConfigControllerTest extends WallabagCoreTestCase
319 319
320 $crawler = $client->request('GET', '/config'); 320 $crawler = $client->request('GET', '/config');
321 321
322 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 322 $this->assertSame(200, $client->getResponse()->getStatusCode());
323 323
324 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); 324 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
325 $this->assertContains('config.form_rss.no_token', $body[0]); 325 $this->assertContains('config.form_rss.no_token', $body[0]);
326 326
327 $client->request('GET', '/generate-token'); 327 $client->request('GET', '/generate-token');
328 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 328 $this->assertSame(302, $client->getResponse()->getStatusCode());
329 329
330 $crawler = $client->followRedirect(); 330 $crawler = $client->followRedirect();
331 331
@@ -346,7 +346,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
346 ['HTTP_X-Requested-With' => 'XMLHttpRequest'] 346 ['HTTP_X-Requested-With' => 'XMLHttpRequest']
347 ); 347 );
348 348
349 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 349 $this->assertSame(200, $client->getResponse()->getStatusCode());
350 $content = json_decode($client->getResponse()->getContent(), true); 350 $content = json_decode($client->getResponse()->getContent(), true);
351 $this->assertArrayHasKey('token', $content); 351 $this->assertArrayHasKey('token', $content);
352 } 352 }
@@ -358,7 +358,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
358 358
359 $crawler = $client->request('GET', '/config'); 359 $crawler = $client->request('GET', '/config');
360 360
361 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 361 $this->assertSame(200, $client->getResponse()->getStatusCode());
362 362
363 $form = $crawler->filter('button[id=rss_config_save]')->form(); 363 $form = $crawler->filter('button[id=rss_config_save]')->form();
364 364
@@ -368,7 +368,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
368 368
369 $client->submit($form, $data); 369 $client->submit($form, $data);
370 370
371 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 371 $this->assertSame(302, $client->getResponse()->getStatusCode());
372 372
373 $crawler = $client->followRedirect(); 373 $crawler = $client->followRedirect();
374 374
@@ -403,13 +403,13 @@ class ConfigControllerTest extends WallabagCoreTestCase
403 403
404 $crawler = $client->request('GET', '/config'); 404 $crawler = $client->request('GET', '/config');
405 405
406 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 406 $this->assertSame(200, $client->getResponse()->getStatusCode());
407 407
408 $form = $crawler->filter('button[id=rss_config_save]')->form(); 408 $form = $crawler->filter('button[id=rss_config_save]')->form();
409 409
410 $crawler = $client->submit($form, $data); 410 $crawler = $client->submit($form, $data);
411 411
412 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 412 $this->assertSame(200, $client->getResponse()->getStatusCode());
413 413
414 $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(['_text'])); 414 $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(['_text']));
415 $this->assertContains($expectedMessage, $alert[0]); 415 $this->assertContains($expectedMessage, $alert[0]);
@@ -423,7 +423,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
423 423
424 $crawler = $client->request('GET', '/config'); 424 $crawler = $client->request('GET', '/config');
425 425
426 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 426 $this->assertSame(200, $client->getResponse()->getStatusCode());
427 427
428 $form = $crawler->filter('button[id=tagging_rule_save]')->form(); 428 $form = $crawler->filter('button[id=tagging_rule_save]')->form();
429 429
@@ -434,7 +434,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
434 434
435 $client->submit($form, $data); 435 $client->submit($form, $data);
436 436
437 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 437 $this->assertSame(302, $client->getResponse()->getStatusCode());
438 438
439 $crawler = $client->followRedirect(); 439 $crawler = $client->followRedirect();
440 440
@@ -443,7 +443,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
443 $editLink = $crawler->filter('.mode_edit')->last()->link(); 443 $editLink = $crawler->filter('.mode_edit')->last()->link();
444 444
445 $crawler = $client->click($editLink); 445 $crawler = $client->click($editLink);
446 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 446 $this->assertSame(302, $client->getResponse()->getStatusCode());
447 $this->assertContains('?tagging-rule=', $client->getResponse()->headers->get('location')); 447 $this->assertContains('?tagging-rule=', $client->getResponse()->headers->get('location'));
448 448
449 $crawler = $client->followRedirect(); 449 $crawler = $client->followRedirect();
@@ -457,7 +457,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
457 457
458 $client->submit($form, $data); 458 $client->submit($form, $data);
459 459
460 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 460 $this->assertSame(302, $client->getResponse()->getStatusCode());
461 461
462 $crawler = $client->followRedirect(); 462 $crawler = $client->followRedirect();
463 463
@@ -468,7 +468,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
468 $deleteLink = $crawler->filter('.delete')->last()->link(); 468 $deleteLink = $crawler->filter('.delete')->last()->link();
469 469
470 $crawler = $client->click($deleteLink); 470 $crawler = $client->click($deleteLink);
471 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 471 $this->assertSame(302, $client->getResponse()->getStatusCode());
472 472
473 $crawler = $client->followRedirect(); 473 $crawler = $client->followRedirect();
474 $this->assertContains('flashes.config.notice.tagging_rules_deleted', $crawler->filter('body')->extract(['_text'])[0]); 474 $this->assertContains('flashes.config.notice.tagging_rules_deleted', $crawler->filter('body')->extract(['_text'])[0]);
@@ -510,13 +510,13 @@ class ConfigControllerTest extends WallabagCoreTestCase
510 510
511 $crawler = $client->request('GET', '/config'); 511 $crawler = $client->request('GET', '/config');
512 512
513 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 513 $this->assertSame(200, $client->getResponse()->getStatusCode());
514 514
515 $form = $crawler->filter('button[id=tagging_rule_save]')->form(); 515 $form = $crawler->filter('button[id=tagging_rule_save]')->form();
516 516
517 $crawler = $client->submit($form, $data); 517 $crawler = $client->submit($form, $data);
518 518
519 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 519 $this->assertSame(200, $client->getResponse()->getStatusCode());
520 520
521 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); 521 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
522 522
@@ -532,7 +532,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
532 532
533 $crawler = $client->request('GET', '/config'); 533 $crawler = $client->request('GET', '/config');
534 534
535 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 535 $this->assertSame(200, $client->getResponse()->getStatusCode());
536 536
537 $form = $crawler->filter('button[id=tagging_rule_save]')->form(); 537 $form = $crawler->filter('button[id=tagging_rule_save]')->form();
538 538
@@ -541,7 +541,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
541 'tagging_rule[tags]' => 'cool tag', 541 'tagging_rule[tags]' => 'cool tag',
542 ]); 542 ]);
543 543
544 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 544 $this->assertSame(200, $client->getResponse()->getStatusCode());
545 545
546 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); 546 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
547 547
@@ -557,9 +557,9 @@ class ConfigControllerTest extends WallabagCoreTestCase
557 ->getRepository('WallabagCoreBundle:TaggingRule') 557 ->getRepository('WallabagCoreBundle:TaggingRule')
558 ->findAll()[0]; 558 ->findAll()[0];
559 559
560 $crawler = $client->request('GET', '/tagging-rule/edit/'.$rule->getId()); 560 $crawler = $client->request('GET', '/tagging-rule/edit/' . $rule->getId());
561 561
562 $this->assertEquals(403, $client->getResponse()->getStatusCode()); 562 $this->assertSame(403, $client->getResponse()->getStatusCode());
563 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); 563 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
564 $this->assertContains('You can not access this tagging rule', $body[0]); 564 $this->assertContains('You can not access this tagging rule', $body[0]);
565 } 565 }
@@ -573,9 +573,9 @@ class ConfigControllerTest extends WallabagCoreTestCase
573 ->getRepository('WallabagCoreBundle:TaggingRule') 573 ->getRepository('WallabagCoreBundle:TaggingRule')
574 ->findAll()[0]; 574 ->findAll()[0];
575 575
576 $crawler = $client->request('GET', '/tagging-rule/edit/'.$rule->getId()); 576 $crawler = $client->request('GET', '/tagging-rule/edit/' . $rule->getId());
577 577
578 $this->assertEquals(403, $client->getResponse()->getStatusCode()); 578 $this->assertSame(403, $client->getResponse()->getStatusCode());
579 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); 579 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
580 $this->assertContains('You can not access this tagging rule', $body[0]); 580 $this->assertContains('You can not access this tagging rule', $body[0]);
581 } 581 }
@@ -591,7 +591,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
591 591
592 $crawler = $client->request('GET', '/config'); 592 $crawler = $client->request('GET', '/config');
593 593
594 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 594 $this->assertSame(200, $client->getResponse()->getStatusCode());
595 595
596 $form = $crawler->filter('button[id=change_passwd_save]')->form(); 596 $form = $crawler->filter('button[id=change_passwd_save]')->form();
597 597
@@ -603,7 +603,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
603 603
604 $client->submit($form, $data); 604 $client->submit($form, $data);
605 605
606 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 606 $this->assertSame(302, $client->getResponse()->getStatusCode());
607 $this->assertContains('flashes.config.notice.password_not_updated_demo', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]); 607 $this->assertContains('flashes.config.notice.password_not_updated_demo', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]);
608 608
609 $config->set('demo_mode_enabled', 0); 609 $config->set('demo_mode_enabled', 0);
@@ -642,7 +642,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
642 $this->assertNotContains('config.form_user.delete.button', $body[0]); 642 $this->assertNotContains('config.form_user.delete.button', $body[0]);
643 643
644 $client->request('GET', '/account/delete'); 644 $client->request('GET', '/account/delete');
645 $this->assertEquals(403, $client->getResponse()->getStatusCode()); 645 $this->assertSame(403, $client->getResponse()->getStatusCode());
646 646
647 $user = $em 647 $user = $em
648 ->getRepository('WallabagUserBundle:User') 648 ->getRepository('WallabagUserBundle:User')
@@ -692,7 +692,7 @@ class ConfigControllerTest extends WallabagCoreTestCase
692 // that this entry is also deleted 692 // that this entry is also deleted
693 $crawler = $client->request('GET', '/new'); 693 $crawler = $client->request('GET', '/new');
694 694
695 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 695 $this->assertSame(200, $client->getResponse()->getStatusCode());
696 696
697 $form = $crawler->filter('form[name=entry]')->form(); 697 $form = $crawler->filter('form[name=entry]')->form();
698 $data = [ 698 $data = [
@@ -700,14 +700,14 @@ class ConfigControllerTest extends WallabagCoreTestCase
700 ]; 700 ];
701 701
702 $client->submit($form, $data); 702 $client->submit($form, $data);
703 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 703 $this->assertSame(302, $client->getResponse()->getStatusCode());
704 704
705 $crawler = $client->request('GET', '/config'); 705 $crawler = $client->request('GET', '/config');
706 706
707 $deleteLink = $crawler->filter('.delete-account')->last()->link(); 707 $deleteLink = $crawler->filter('.delete-account')->last()->link();
708 708
709 $client->click($deleteLink); 709 $client->click($deleteLink);
710 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 710 $this->assertSame(302, $client->getResponse()->getStatusCode());
711 711
712 $em = $client->getContainer()->get('doctrine.orm.entity_manager'); 712 $em = $client->getContainer()->get('doctrine.orm.entity_manager');
713 $user = $em 713 $user = $em
@@ -767,11 +767,11 @@ class ConfigControllerTest extends WallabagCoreTestCase
767 // reset annotations 767 // reset annotations
768 $crawler = $client->request('GET', '/config#set3'); 768 $crawler = $client->request('GET', '/config#set3');
769 769
770 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 770 $this->assertSame(200, $client->getResponse()->getStatusCode());
771 771
772 $crawler = $client->click($crawler->selectLink('config.reset.annotations')->link()); 772 $crawler = $client->click($crawler->selectLink('config.reset.annotations')->link());
773 773
774 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 774 $this->assertSame(302, $client->getResponse()->getStatusCode());
775 $this->assertContains('flashes.config.notice.annotations_reset', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]); 775 $this->assertContains('flashes.config.notice.annotations_reset', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]);
776 776
777 $annotationsReset = $em 777 $annotationsReset = $em
@@ -783,34 +783,34 @@ class ConfigControllerTest extends WallabagCoreTestCase
783 // reset tags 783 // reset tags
784 $crawler = $client->request('GET', '/config#set3'); 784 $crawler = $client->request('GET', '/config#set3');
785 785
786 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 786 $this->assertSame(200, $client->getResponse()->getStatusCode());
787 787
788 $crawler = $client->click($crawler->selectLink('config.reset.tags')->link()); 788 $crawler = $client->click($crawler->selectLink('config.reset.tags')->link());
789 789
790 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 790 $this->assertSame(302, $client->getResponse()->getStatusCode());
791 $this->assertContains('flashes.config.notice.tags_reset', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]); 791 $this->assertContains('flashes.config.notice.tags_reset', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]);
792 792
793 $tagReset = $em 793 $tagReset = $em
794 ->getRepository('WallabagCoreBundle:Tag') 794 ->getRepository('WallabagCoreBundle:Tag')
795 ->countAllTags($user->getId()); 795 ->countAllTags($user->getId());
796 796
797 $this->assertEquals(0, $tagReset, 'Tags were reset'); 797 $this->assertSame(0, $tagReset, 'Tags were reset');
798 798
799 // reset entries 799 // reset entries
800 $crawler = $client->request('GET', '/config#set3'); 800 $crawler = $client->request('GET', '/config#set3');
801 801
802 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 802 $this->assertSame(200, $client->getResponse()->getStatusCode());
803 803
804 $crawler = $client->click($crawler->selectLink('config.reset.entries')->link()); 804 $crawler = $client->click($crawler->selectLink('config.reset.entries')->link());
805 805
806 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 806 $this->assertSame(302, $client->getResponse()->getStatusCode());
807 $this->assertContains('flashes.config.notice.entries_reset', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]); 807 $this->assertContains('flashes.config.notice.entries_reset', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]);
808 808
809 $entryReset = $em 809 $entryReset = $em
810 ->getRepository('WallabagCoreBundle:Entry') 810 ->getRepository('WallabagCoreBundle:Entry')
811 ->countAllEntriesByUser($user->getId()); 811 ->countAllEntriesByUser($user->getId());
812 812
813 $this->assertEquals(0, $entryReset, 'Entries were reset'); 813 $this->assertSame(0, $entryReset, 'Entries were reset');
814 } 814 }
815 815
816 public function testResetArchivedEntries() 816 public function testResetArchivedEntries()
@@ -863,24 +863,24 @@ class ConfigControllerTest extends WallabagCoreTestCase
863 863
864 $crawler = $client->request('GET', '/config#set3'); 864 $crawler = $client->request('GET', '/config#set3');
865 865
866 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 866 $this->assertSame(200, $client->getResponse()->getStatusCode());
867 867
868 $crawler = $client->click($crawler->selectLink('config.reset.archived')->link()); 868 $crawler = $client->click($crawler->selectLink('config.reset.archived')->link());
869 869
870 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 870 $this->assertSame(302, $client->getResponse()->getStatusCode());
871 $this->assertContains('flashes.config.notice.archived_reset', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]); 871 $this->assertContains('flashes.config.notice.archived_reset', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]);
872 872
873 $entryReset = $em 873 $entryReset = $em
874 ->getRepository('WallabagCoreBundle:Entry') 874 ->getRepository('WallabagCoreBundle:Entry')
875 ->countAllEntriesByUser($user->getId()); 875 ->countAllEntriesByUser($user->getId());
876 876
877 $this->assertEquals(1, $entryReset, 'Entries were reset'); 877 $this->assertSame(1, $entryReset, 'Entries were reset');
878 878
879 $tagReset = $em 879 $tagReset = $em
880 ->getRepository('WallabagCoreBundle:Tag') 880 ->getRepository('WallabagCoreBundle:Tag')
881 ->countAllTags($user->getId()); 881 ->countAllTags($user->getId());
882 882
883 $this->assertEquals(1, $tagReset, 'Tags were reset'); 883 $this->assertSame(1, $tagReset, 'Tags were reset');
884 884
885 $annotationsReset = $em 885 $annotationsReset = $em
886 ->getRepository('WallabagAnnotationBundle:Annotation') 886 ->getRepository('WallabagAnnotationBundle:Annotation')
@@ -920,24 +920,24 @@ class ConfigControllerTest extends WallabagCoreTestCase
920 920
921 $crawler = $client->request('GET', '/config#set3'); 921 $crawler = $client->request('GET', '/config#set3');
922 922
923 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 923 $this->assertSame(200, $client->getResponse()->getStatusCode());
924 924
925 $crawler = $client->click($crawler->selectLink('config.reset.entries')->link()); 925 $crawler = $client->click($crawler->selectLink('config.reset.entries')->link());
926 926
927 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 927 $this->assertSame(302, $client->getResponse()->getStatusCode());
928 $this->assertContains('flashes.config.notice.entries_reset', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]); 928 $this->assertContains('flashes.config.notice.entries_reset', $client->getContainer()->get('session')->getFlashBag()->get('notice')[0]);
929 929
930 $entryReset = $em 930 $entryReset = $em
931 ->getRepository('WallabagCoreBundle:Entry') 931 ->getRepository('WallabagCoreBundle:Entry')
932 ->countAllEntriesByUser($user->getId()); 932 ->countAllEntriesByUser($user->getId());
933 933
934 $this->assertEquals(0, $entryReset, 'Entries were reset'); 934 $this->assertSame(0, $entryReset, 'Entries were reset');
935 935
936 $tagReset = $em 936 $tagReset = $em
937 ->getRepository('WallabagCoreBundle:Tag') 937 ->getRepository('WallabagCoreBundle:Tag')
938 ->countAllTags($user->getId()); 938 ->countAllTags($user->getId());
939 939
940 $this->assertEquals(0, $tagReset, 'Tags were reset'); 940 $this->assertSame(0, $tagReset, 'Tags were reset');
941 941
942 $annotationsReset = $em 942 $annotationsReset = $em
943 ->getRepository('WallabagAnnotationBundle:Annotation') 943 ->getRepository('WallabagAnnotationBundle:Annotation')
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
index 7cf28bfe..b528bcdb 100644
--- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
@@ -33,7 +33,7 @@ class EntryControllerTest extends WallabagCoreTestCase
33 33
34 $client->request('GET', '/new'); 34 $client->request('GET', '/new');
35 35
36 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 36 $this->assertSame(302, $client->getResponse()->getStatusCode());
37 $this->assertContains('login', $client->getResponse()->headers->get('location')); 37 $this->assertContains('login', $client->getResponse()->headers->get('location'));
38 } 38 }
39 39
@@ -45,14 +45,14 @@ class EntryControllerTest extends WallabagCoreTestCase
45 $client->request('GET', '/unread/list'); 45 $client->request('GET', '/unread/list');
46 $crawler = $client->followRedirect(); 46 $crawler = $client->followRedirect();
47 47
48 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 48 $this->assertSame(200, $client->getResponse()->getStatusCode());
49 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); 49 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
50 $this->assertContains('quickstart.intro.title', $body[0]); 50 $this->assertContains('quickstart.intro.title', $body[0]);
51 51
52 // Test if quickstart is disabled when user has 1 entry 52 // Test if quickstart is disabled when user has 1 entry
53 $crawler = $client->request('GET', '/new'); 53 $crawler = $client->request('GET', '/new');
54 54
55 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 55 $this->assertSame(200, $client->getResponse()->getStatusCode());
56 56
57 $form = $crawler->filter('form[name=entry]')->form(); 57 $form = $crawler->filter('form[name=entry]')->form();
58 58
@@ -61,7 +61,7 @@ class EntryControllerTest extends WallabagCoreTestCase
61 ]; 61 ];
62 62
63 $client->submit($form, $data); 63 $client->submit($form, $data);
64 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 64 $this->assertSame(302, $client->getResponse()->getStatusCode());
65 $client->followRedirect(); 65 $client->followRedirect();
66 66
67 $crawler = $client->request('GET', '/unread/list'); 67 $crawler = $client->request('GET', '/unread/list');
@@ -77,7 +77,7 @@ class EntryControllerTest extends WallabagCoreTestCase
77 77
78 $crawler = $client->request('GET', '/new'); 78 $crawler = $client->request('GET', '/new');
79 79
80 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 80 $this->assertSame(200, $client->getResponse()->getStatusCode());
81 81
82 $this->assertCount(1, $crawler->filter('input[type=url]')); 82 $this->assertCount(1, $crawler->filter('input[type=url]'));
83 $this->assertCount(1, $crawler->filter('form[name=entry]')); 83 $this->assertCount(1, $crawler->filter('form[name=entry]'));
@@ -95,7 +95,7 @@ class EntryControllerTest extends WallabagCoreTestCase
95 95
96 // Good URL 96 // Good URL
97 $client->request('GET', '/bookmarklet', ['url' => $this->url]); 97 $client->request('GET', '/bookmarklet', ['url' => $this->url]);
98 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 98 $this->assertSame(302, $client->getResponse()->getStatusCode());
99 $client->followRedirect(); 99 $client->followRedirect();
100 $crawler = $client->request('GET', '/'); 100 $crawler = $client->request('GET', '/');
101 $this->assertCount(5, $crawler->filter('div[class=entry]')); 101 $this->assertCount(5, $crawler->filter('div[class=entry]'));
@@ -116,15 +116,15 @@ class EntryControllerTest extends WallabagCoreTestCase
116 116
117 $crawler = $client->request('GET', '/new'); 117 $crawler = $client->request('GET', '/new');
118 118
119 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 119 $this->assertSame(200, $client->getResponse()->getStatusCode());
120 120
121 $form = $crawler->filter('form[name=entry]')->form(); 121 $form = $crawler->filter('form[name=entry]')->form();
122 122
123 $crawler = $client->submit($form); 123 $crawler = $client->submit($form);
124 124
125 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 125 $this->assertSame(200, $client->getResponse()->getStatusCode());
126 $this->assertCount(1, $alert = $crawler->filter('form ul li')->extract(['_text'])); 126 $this->assertCount(1, $alert = $crawler->filter('form ul li')->extract(['_text']));
127 $this->assertEquals('This value should not be blank.', $alert[0]); 127 $this->assertSame('This value should not be blank.', $alert[0]);
128 } 128 }
129 129
130 /** 130 /**
@@ -137,7 +137,7 @@ class EntryControllerTest extends WallabagCoreTestCase
137 137
138 $crawler = $client->request('GET', '/new'); 138 $crawler = $client->request('GET', '/new');
139 139
140 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 140 $this->assertSame(200, $client->getResponse()->getStatusCode());
141 141
142 $form = $crawler->filter('form[name=entry]')->form(); 142 $form = $crawler->filter('form[name=entry]')->form();
143 143
@@ -147,7 +147,7 @@ class EntryControllerTest 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 $content = $client->getContainer() 152 $content = $client->getContainer()
153 ->get('doctrine.orm.entity_manager') 153 ->get('doctrine.orm.entity_manager')
@@ -157,11 +157,11 @@ class EntryControllerTest extends WallabagCoreTestCase
157 $author = $content->getPublishedBy(); 157 $author = $content->getPublishedBy();
158 158
159 $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content); 159 $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content);
160 $this->assertEquals($this->url, $content->getUrl()); 160 $this->assertSame($this->url, $content->getUrl());
161 $this->assertContains('Google', $content->getTitle()); 161 $this->assertContains('Google', $content->getTitle());
162 $this->assertEquals('fr', $content->getLanguage()); 162 $this->assertSame('fr', $content->getLanguage());
163 $this->assertEquals('2015-03-28 15:37:39', $content->getPublishedAt()->format('Y-m-d H:i:s')); 163 $this->assertSame('2015-03-28 15:37:39', $content->getPublishedAt()->format('Y-m-d H:i:s'));
164 $this->assertEquals('Morgane Tual', $author[0]); 164 $this->assertSame('Morgane Tual', $author[0]);
165 $this->assertArrayHasKey('x-varnish1', $content->getHeaders()); 165 $this->assertArrayHasKey('x-varnish1', $content->getHeaders());
166 } 166 }
167 167
@@ -173,7 +173,7 @@ class EntryControllerTest extends WallabagCoreTestCase
173 173
174 $crawler = $client->request('GET', '/new'); 174 $crawler = $client->request('GET', '/new');
175 175
176 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 176 $this->assertSame(200, $client->getResponse()->getStatusCode());
177 177
178 $form = $crawler->filter('form[name=entry]')->form(); 178 $form = $crawler->filter('form[name=entry]')->form();
179 179
@@ -183,7 +183,7 @@ class EntryControllerTest extends WallabagCoreTestCase
183 183
184 $client->submit($form, $data); 184 $client->submit($form, $data);
185 185
186 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 186 $this->assertSame(302, $client->getResponse()->getStatusCode());
187 187
188 $content = $client->getContainer() 188 $content = $client->getContainer()
189 ->get('doctrine.orm.entity_manager') 189 ->get('doctrine.orm.entity_manager')
@@ -191,10 +191,10 @@ class EntryControllerTest extends WallabagCoreTestCase
191 ->findByUrlAndUserId($url, $this->getLoggedInUserId()); 191 ->findByUrlAndUserId($url, $this->getLoggedInUserId());
192 192
193 $authors = $content->getPublishedBy(); 193 $authors = $content->getPublishedBy();
194 $this->assertEquals('2017-04-05 19:26:13', $content->getPublishedAt()->format('Y-m-d H:i:s')); 194 $this->assertSame('2017-04-05 19:26:13', $content->getPublishedAt()->format('Y-m-d H:i:s'));
195 $this->assertEquals('fr', $content->getLanguage()); 195 $this->assertSame('fr', $content->getLanguage());
196 $this->assertEquals('Raphaël Balenieri, correspondant à Pékin', $authors[0]); 196 $this->assertSame('Raphaël Balenieri, correspondant à Pékin', $authors[0]);
197 $this->assertEquals('Frédéric Autran, correspondant à New York', $authors[1]); 197 $this->assertSame('Frédéric Autran, correspondant à New York', $authors[1]);
198 } 198 }
199 199
200 public function testPostNewOkUrlExist() 200 public function testPostNewOkUrlExist()
@@ -210,7 +210,7 @@ class EntryControllerTest extends WallabagCoreTestCase
210 210
211 $crawler = $client->request('GET', '/new'); 211 $crawler = $client->request('GET', '/new');
212 212
213 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 213 $this->assertSame(200, $client->getResponse()->getStatusCode());
214 214
215 $form = $crawler->filter('form[name=entry]')->form(); 215 $form = $crawler->filter('form[name=entry]')->form();
216 216
@@ -220,7 +220,7 @@ class EntryControllerTest extends WallabagCoreTestCase
220 220
221 $client->submit($form, $data); 221 $client->submit($form, $data);
222 222
223 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 223 $this->assertSame(302, $client->getResponse()->getStatusCode());
224 $this->assertContains('/view/', $client->getResponse()->getTargetUrl()); 224 $this->assertContains('/view/', $client->getResponse()->getTargetUrl());
225 } 225 }
226 226
@@ -233,7 +233,7 @@ class EntryControllerTest extends WallabagCoreTestCase
233 233
234 $crawler = $client->request('GET', '/new'); 234 $crawler = $client->request('GET', '/new');
235 235
236 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 236 $this->assertSame(200, $client->getResponse()->getStatusCode());
237 237
238 $form = $crawler->filter('form[name=entry]')->form(); 238 $form = $crawler->filter('form[name=entry]')->form();
239 239
@@ -245,7 +245,7 @@ class EntryControllerTest extends WallabagCoreTestCase
245 245
246 $crawler = $client->request('GET', '/new'); 246 $crawler = $client->request('GET', '/new');
247 247
248 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 248 $this->assertSame(200, $client->getResponse()->getStatusCode());
249 249
250 $form = $crawler->filter('form[name=entry]')->form(); 250 $form = $crawler->filter('form[name=entry]')->form();
251 251
@@ -255,7 +255,7 @@ class EntryControllerTest extends WallabagCoreTestCase
255 255
256 $client->submit($form, $data); 256 $client->submit($form, $data);
257 257
258 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 258 $this->assertSame(302, $client->getResponse()->getStatusCode());
259 $this->assertContains('/view/', $client->getResponse()->getTargetUrl()); 259 $this->assertContains('/view/', $client->getResponse()->getTargetUrl());
260 } 260 }
261 261
@@ -269,7 +269,7 @@ class EntryControllerTest extends WallabagCoreTestCase
269 269
270 $crawler = $client->request('GET', '/new'); 270 $crawler = $client->request('GET', '/new');
271 271
272 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 272 $this->assertSame(200, $client->getResponse()->getStatusCode());
273 273
274 $form = $crawler->filter('form[name=entry]')->form(); 274 $form = $crawler->filter('form[name=entry]')->form();
275 275
@@ -279,7 +279,7 @@ class EntryControllerTest extends WallabagCoreTestCase
279 279
280 $client->submit($form, $data); 280 $client->submit($form, $data);
281 281
282 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 282 $this->assertSame(302, $client->getResponse()->getStatusCode());
283 $this->assertContains('/', $client->getResponse()->getTargetUrl()); 283 $this->assertContains('/', $client->getResponse()->getTargetUrl());
284 284
285 $em = $client->getContainer() 285 $em = $client->getContainer()
@@ -291,7 +291,7 @@ class EntryControllerTest extends WallabagCoreTestCase
291 291
292 $this->assertCount(2, $tags); 292 $this->assertCount(2, $tags);
293 $this->assertContains('wallabag', $tags); 293 $this->assertContains('wallabag', $tags);
294 $this->assertEquals('en', $entry->getLanguage()); 294 $this->assertSame('en', $entry->getLanguage());
295 295
296 $em->remove($entry); 296 $em->remove($entry);
297 $em->flush(); 297 $em->flush();
@@ -300,7 +300,7 @@ class EntryControllerTest extends WallabagCoreTestCase
300 // related https://github.com/wallabag/wallabag/issues/2121 300 // related https://github.com/wallabag/wallabag/issues/2121
301 $crawler = $client->request('GET', '/new'); 301 $crawler = $client->request('GET', '/new');
302 302
303 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 303 $this->assertSame(200, $client->getResponse()->getStatusCode());
304 304
305 $form = $crawler->filter('form[name=entry]')->form(); 305 $form = $crawler->filter('form[name=entry]')->form();
306 306
@@ -310,7 +310,7 @@ class EntryControllerTest extends WallabagCoreTestCase
310 310
311 $client->submit($form, $data); 311 $client->submit($form, $data);
312 312
313 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 313 $this->assertSame(302, $client->getResponse()->getStatusCode());
314 $this->assertContains('/', $client->getResponse()->getTargetUrl()); 314 $this->assertContains('/', $client->getResponse()->getTargetUrl());
315 315
316 $entry = $em 316 $entry = $em
@@ -333,7 +333,7 @@ class EntryControllerTest extends WallabagCoreTestCase
333 333
334 $client->request('GET', '/archive/list'); 334 $client->request('GET', '/archive/list');
335 335
336 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 336 $this->assertSame(200, $client->getResponse()->getStatusCode());
337 } 337 }
338 338
339 public function testUntagged() 339 public function testUntagged()
@@ -343,7 +343,7 @@ class EntryControllerTest extends WallabagCoreTestCase
343 343
344 $client->request('GET', '/untagged/list'); 344 $client->request('GET', '/untagged/list');
345 345
346 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 346 $this->assertSame(200, $client->getResponse()->getStatusCode());
347 } 347 }
348 348
349 public function testStarred() 349 public function testStarred()
@@ -353,7 +353,7 @@ class EntryControllerTest extends WallabagCoreTestCase
353 353
354 $client->request('GET', '/starred/list'); 354 $client->request('GET', '/starred/list');
355 355
356 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 356 $this->assertSame(200, $client->getResponse()->getStatusCode());
357 } 357 }
358 358
359 public function testRangeException() 359 public function testRangeException()
@@ -363,8 +363,8 @@ class EntryControllerTest extends WallabagCoreTestCase
363 363
364 $client->request('GET', '/all/list/900'); 364 $client->request('GET', '/all/list/900');
365 365
366 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 366 $this->assertSame(302, $client->getResponse()->getStatusCode());
367 $this->assertEquals('/all/list', $client->getResponse()->getTargetUrl()); 367 $this->assertSame('/all/list', $client->getResponse()->getTargetUrl());
368 } 368 }
369 369
370 public function testView() 370 public function testView()
@@ -379,9 +379,9 @@ class EntryControllerTest extends WallabagCoreTestCase
379 $this->getEntityManager()->persist($entry); 379 $this->getEntityManager()->persist($entry);
380 $this->getEntityManager()->flush(); 380 $this->getEntityManager()->flush();
381 381
382 $crawler = $client->request('GET', '/view/'.$entry->getId()); 382 $crawler = $client->request('GET', '/view/' . $entry->getId());
383 383
384 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 384 $this->assertSame(200, $client->getResponse()->getStatusCode());
385 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text'])); 385 $this->assertGreaterThan(1, $body = $crawler->filter('body')->extract(['_text']));
386 $this->assertContains($entry->getTitle(), $body[0]); 386 $this->assertContains($entry->getTitle(), $body[0]);
387 } 387 }
@@ -402,9 +402,9 @@ class EntryControllerTest extends WallabagCoreTestCase
402 $this->getEntityManager()->flush(); 402 $this->getEntityManager()->flush();
403 $this->getEntityManager()->clear(); 403 $this->getEntityManager()->clear();
404 404
405 $client->request('GET', '/reload/'.$entry->getId()); 405 $client->request('GET', '/reload/' . $entry->getId());
406 406
407 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 407 $this->assertSame(302, $client->getResponse()->getStatusCode());
408 408
409 $entry = $this->getEntityManager() 409 $entry = $this->getEntityManager()
410 ->getRepository('WallabagCoreBundle:Entry') 410 ->getRepository('WallabagCoreBundle:Entry')
@@ -423,9 +423,9 @@ class EntryControllerTest extends WallabagCoreTestCase
423 $this->getEntityManager()->persist($entry); 423 $this->getEntityManager()->persist($entry);
424 $this->getEntityManager()->flush(); 424 $this->getEntityManager()->flush();
425 425
426 $client->request('GET', '/reload/'.$entry->getId()); 426 $client->request('GET', '/reload/' . $entry->getId());
427 427
428 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 428 $this->assertSame(302, $client->getResponse()->getStatusCode());
429 429
430 // force EntityManager to clear previous entity 430 // force EntityManager to clear previous entity
431 // otherwise, retrieve the same entity will retrieve change from the previous request :0 431 // otherwise, retrieve the same entity will retrieve change from the previous request :0
@@ -434,7 +434,7 @@ class EntryControllerTest extends WallabagCoreTestCase
434 ->getRepository('WallabagCoreBundle:Entry') 434 ->getRepository('WallabagCoreBundle:Entry')
435 ->find($entry->getId()); 435 ->find($entry->getId());
436 436
437 $this->assertNotEquals($client->getContainer()->getParameter('wallabag_core.fetching_error_message'), $newContent->getContent()); 437 $this->assertNotSame($client->getContainer()->getParameter('wallabag_core.fetching_error_message'), $newContent->getContent());
438 } 438 }
439 439
440 public function testEdit() 440 public function testEdit()
@@ -447,9 +447,9 @@ class EntryControllerTest extends WallabagCoreTestCase
447 $this->getEntityManager()->persist($entry); 447 $this->getEntityManager()->persist($entry);
448 $this->getEntityManager()->flush(); 448 $this->getEntityManager()->flush();
449 449
450 $crawler = $client->request('GET', '/edit/'.$entry->getId()); 450 $crawler = $client->request('GET', '/edit/' . $entry->getId());
451 451
452 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 452 $this->assertSame(200, $client->getResponse()->getStatusCode());
453 453
454 $this->assertCount(1, $crawler->filter('input[id=entry_title]')); 454 $this->assertCount(1, $crawler->filter('input[id=entry_title]'));
455 $this->assertCount(1, $crawler->filter('button[id=entry_save]')); 455 $this->assertCount(1, $crawler->filter('button[id=entry_save]'));
@@ -465,9 +465,9 @@ class EntryControllerTest extends WallabagCoreTestCase
465 $this->getEntityManager()->persist($entry); 465 $this->getEntityManager()->persist($entry);
466 $this->getEntityManager()->flush(); 466 $this->getEntityManager()->flush();
467 467
468 $crawler = $client->request('GET', '/edit/'.$entry->getId()); 468 $crawler = $client->request('GET', '/edit/' . $entry->getId());
469 469
470 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 470 $this->assertSame(200, $client->getResponse()->getStatusCode());
471 471
472 $form = $crawler->filter('button[type=submit]')->form(); 472 $form = $crawler->filter('button[type=submit]')->form();
473 473
@@ -477,7 +477,7 @@ class EntryControllerTest extends WallabagCoreTestCase
477 477
478 $client->submit($form, $data); 478 $client->submit($form, $data);
479 479
480 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 480 $this->assertSame(302, $client->getResponse()->getStatusCode());
481 481
482 $crawler = $client->followRedirect(); 482 $crawler = $client->followRedirect();
483 483
@@ -496,16 +496,16 @@ class EntryControllerTest extends WallabagCoreTestCase
496 $this->getEntityManager()->flush(); 496 $this->getEntityManager()->flush();
497 $this->getEntityManager()->clear(); 497 $this->getEntityManager()->clear();
498 498
499 $client->request('GET', '/archive/'.$entry->getId()); 499 $client->request('GET', '/archive/' . $entry->getId());
500 500
501 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 501 $this->assertSame(302, $client->getResponse()->getStatusCode());
502 502
503 $res = $client->getContainer() 503 $res = $client->getContainer()
504 ->get('doctrine.orm.entity_manager') 504 ->get('doctrine.orm.entity_manager')
505 ->getRepository('WallabagCoreBundle:Entry') 505 ->getRepository('WallabagCoreBundle:Entry')
506 ->find($entry->getId()); 506 ->find($entry->getId());
507 507
508 $this->assertEquals($res->isArchived(), true); 508 $this->assertSame($res->isArchived(), true);
509 } 509 }
510 510
511 public function testToggleStar() 511 public function testToggleStar()
@@ -519,16 +519,16 @@ class EntryControllerTest extends WallabagCoreTestCase
519 $this->getEntityManager()->flush(); 519 $this->getEntityManager()->flush();
520 $this->getEntityManager()->clear(); 520 $this->getEntityManager()->clear();
521 521
522 $client->request('GET', '/star/'.$entry->getId()); 522 $client->request('GET', '/star/' . $entry->getId());
523 523
524 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 524 $this->assertSame(302, $client->getResponse()->getStatusCode());
525 525
526 $res = $client->getContainer() 526 $res = $client->getContainer()
527 ->get('doctrine.orm.entity_manager') 527 ->get('doctrine.orm.entity_manager')
528 ->getRepository('WallabagCoreBundle:Entry') 528 ->getRepository('WallabagCoreBundle:Entry')
529 ->findOneById($entry->getId()); 529 ->findOneById($entry->getId());
530 530
531 $this->assertEquals($res->isStarred(), true); 531 $this->assertSame($res->isStarred(), true);
532 } 532 }
533 533
534 public function testDelete() 534 public function testDelete()
@@ -541,13 +541,13 @@ class EntryControllerTest extends WallabagCoreTestCase
541 $this->getEntityManager()->persist($entry); 541 $this->getEntityManager()->persist($entry);
542 $this->getEntityManager()->flush(); 542 $this->getEntityManager()->flush();
543 543
544 $client->request('GET', '/delete/'.$entry->getId()); 544 $client->request('GET', '/delete/' . $entry->getId());
545 545
546 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 546 $this->assertSame(302, $client->getResponse()->getStatusCode());
547 547
548 $client->request('GET', '/delete/'.$entry->getId()); 548 $client->request('GET', '/delete/' . $entry->getId());
549 549
550 $this->assertEquals(404, $client->getResponse()->getStatusCode()); 550 $this->assertSame(404, $client->getResponse()->getStatusCode());
551 } 551 }
552 552
553 /** 553 /**
@@ -583,14 +583,14 @@ class EntryControllerTest extends WallabagCoreTestCase
583 $em->persist($content); 583 $em->persist($content);
584 $em->flush(); 584 $em->flush();
585 585
586 $client->request('GET', '/view/'.$content->getId()); 586 $client->request('GET', '/view/' . $content->getId());
587 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 587 $this->assertSame(200, $client->getResponse()->getStatusCode());
588 588
589 $client->request('GET', '/delete/'.$content->getId()); 589 $client->request('GET', '/delete/' . $content->getId());
590 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 590 $this->assertSame(302, $client->getResponse()->getStatusCode());
591 591
592 $client->followRedirect(); 592 $client->followRedirect();
593 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 593 $this->assertSame(200, $client->getResponse()->getStatusCode());
594 } 594 }
595 595
596 public function testViewOtherUserEntry() 596 public function testViewOtherUserEntry()
@@ -603,9 +603,9 @@ class EntryControllerTest extends WallabagCoreTestCase
603 ->getRepository('WallabagCoreBundle:Entry') 603 ->getRepository('WallabagCoreBundle:Entry')
604 ->findOneByUsernameAndNotArchived('bob'); 604 ->findOneByUsernameAndNotArchived('bob');
605 605
606 $client->request('GET', '/view/'.$content->getId()); 606 $client->request('GET', '/view/' . $content->getId());
607 607
608 $this->assertEquals(403, $client->getResponse()->getStatusCode()); 608 $this->assertSame(403, $client->getResponse()->getStatusCode());
609 } 609 }
610 610
611 public function testFilterOnReadingTime() 611 public function testFilterOnReadingTime()
@@ -793,7 +793,7 @@ class EntryControllerTest extends WallabagCoreTestCase
793 793
794 $parameters = '?entry_filter%5BreadingTime%5D%5Bleft_number%5D=&entry_filter%5BreadingTime%5D%5Bright_number%5D='; 794 $parameters = '?entry_filter%5BreadingTime%5D%5Bleft_number%5D=&entry_filter%5BreadingTime%5D%5Bright_number%5D=';
795 795
796 $client->request('GET', 'unread/list'.$parameters); 796 $client->request('GET', 'unread/list' . $parameters);
797 797
798 $this->assertContains($parameters, $client->getResponse()->getContent()); 798 $this->assertContains($parameters, $client->getResponse()->getContent());
799 799
@@ -934,16 +934,16 @@ class EntryControllerTest extends WallabagCoreTestCase
934 $this->getEntityManager()->clear(); 934 $this->getEntityManager()->clear();
935 935
936 // no uid 936 // no uid
937 $client->request('GET', '/share/'.$content->getUid()); 937 $client->request('GET', '/share/' . $content->getUid());
938 $this->assertEquals(404, $client->getResponse()->getStatusCode()); 938 $this->assertSame(404, $client->getResponse()->getStatusCode());
939 939
940 // generating the uid 940 // generating the uid
941 $client->request('GET', '/share/'.$content->getId()); 941 $client->request('GET', '/share/' . $content->getId());
942 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 942 $this->assertSame(302, $client->getResponse()->getStatusCode());
943 943
944 // follow link with uid 944 // follow link with uid
945 $crawler = $client->followRedirect(); 945 $crawler = $client->followRedirect();
946 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 946 $this->assertSame(200, $client->getResponse()->getStatusCode());
947 $this->assertContains('max-age=25200', $client->getResponse()->headers->get('cache-control')); 947 $this->assertContains('max-age=25200', $client->getResponse()->headers->get('cache-control'));
948 $this->assertContains('public', $client->getResponse()->headers->get('cache-control')); 948 $this->assertContains('public', $client->getResponse()->headers->get('cache-control'));
949 $this->assertContains('s-maxage=25200', $client->getResponse()->headers->get('cache-control')); 949 $this->assertContains('s-maxage=25200', $client->getResponse()->headers->get('cache-control'));
@@ -955,19 +955,19 @@ class EntryControllerTest extends WallabagCoreTestCase
955 955
956 // sharing is now disabled 956 // sharing is now disabled
957 $client->getContainer()->get('craue_config')->set('share_public', 0); 957 $client->getContainer()->get('craue_config')->set('share_public', 0);
958 $client->request('GET', '/share/'.$content->getUid()); 958 $client->request('GET', '/share/' . $content->getUid());
959 $this->assertEquals(404, $client->getResponse()->getStatusCode()); 959 $this->assertSame(404, $client->getResponse()->getStatusCode());
960 960
961 $client->request('GET', '/view/'.$content->getId()); 961 $client->request('GET', '/view/' . $content->getId());
962 $this->assertContains('no-cache', $client->getResponse()->headers->get('cache-control')); 962 $this->assertContains('no-cache', $client->getResponse()->headers->get('cache-control'));
963 963
964 // removing the share 964 // removing the share
965 $client->request('GET', '/share/delete/'.$content->getId()); 965 $client->request('GET', '/share/delete/' . $content->getId());
966 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 966 $this->assertSame(302, $client->getResponse()->getStatusCode());
967 967
968 // share is now disable 968 // share is now disable
969 $client->request('GET', '/share/'.$content->getUid()); 969 $client->request('GET', '/share/' . $content->getUid());
970 $this->assertEquals(404, $client->getResponse()->getStatusCode()); 970 $this->assertSame(404, $client->getResponse()->getStatusCode());
971 } 971 }
972 972
973 public function testNewEntryWithDownloadImagesEnabled() 973 public function testNewEntryWithDownloadImagesEnabled()
@@ -981,7 +981,7 @@ class EntryControllerTest extends WallabagCoreTestCase
981 981
982 $crawler = $client->request('GET', '/new'); 982 $crawler = $client->request('GET', '/new');
983 983
984 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 984 $this->assertSame(200, $client->getResponse()->getStatusCode());
985 985
986 $form = $crawler->filter('form[name=entry]')->form(); 986 $form = $crawler->filter('form[name=entry]')->form();
987 987
@@ -991,7 +991,7 @@ class EntryControllerTest extends WallabagCoreTestCase
991 991
992 $client->submit($form, $data); 992 $client->submit($form, $data);
993 993
994 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 994 $this->assertSame(302, $client->getResponse()->getStatusCode());
995 995
996 $em = $client->getContainer() 996 $em = $client->getContainer()
997 ->get('doctrine.orm.entity_manager'); 997 ->get('doctrine.orm.entity_manager');
@@ -1001,7 +1001,7 @@ class EntryControllerTest extends WallabagCoreTestCase
1001 ->findByUrlAndUserId($url, $this->getLoggedInUserId()); 1001 ->findByUrlAndUserId($url, $this->getLoggedInUserId());
1002 1002
1003 $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $entry); 1003 $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $entry);
1004 $this->assertEquals($url, $entry->getUrl()); 1004 $this->assertSame($url, $entry->getUrl());
1005 $this->assertContains('Perpignan', $entry->getTitle()); 1005 $this->assertContains('Perpignan', $entry->getTitle());
1006 // instead of checking for the filename (which might change) check that the image is now local 1006 // instead of checking for the filename (which might change) check that the image is now local
1007 $this->assertContains('https://your-wallabag-url-instance.com/assets/images/', $entry->getContent()); 1007 $this->assertContains('https://your-wallabag-url-instance.com/assets/images/', $entry->getContent());
@@ -1023,7 +1023,7 @@ class EntryControllerTest extends WallabagCoreTestCase
1023 1023
1024 $crawler = $client->request('GET', '/new'); 1024 $crawler = $client->request('GET', '/new');
1025 1025
1026 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 1026 $this->assertSame(200, $client->getResponse()->getStatusCode());
1027 1027
1028 $form = $crawler->filter('form[name=entry]')->form(); 1028 $form = $crawler->filter('form[name=entry]')->form();
1029 1029
@@ -1033,16 +1033,16 @@ class EntryControllerTest extends WallabagCoreTestCase
1033 1033
1034 $client->submit($form, $data); 1034 $client->submit($form, $data);
1035 1035
1036 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 1036 $this->assertSame(302, $client->getResponse()->getStatusCode());
1037 1037
1038 $content = $client->getContainer() 1038 $content = $client->getContainer()
1039 ->get('doctrine.orm.entity_manager') 1039 ->get('doctrine.orm.entity_manager')
1040 ->getRepository('WallabagCoreBundle:Entry') 1040 ->getRepository('WallabagCoreBundle:Entry')
1041 ->findByUrlAndUserId($url, $this->getLoggedInUserId()); 1041 ->findByUrlAndUserId($url, $this->getLoggedInUserId());
1042 1042
1043 $client->request('GET', '/delete/'.$content->getId()); 1043 $client->request('GET', '/delete/' . $content->getId());
1044 1044
1045 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 1045 $this->assertSame(302, $client->getResponse()->getStatusCode());
1046 1046
1047 $client->getContainer()->get('craue_config')->set('download_images_enabled', 0); 1047 $client->getContainer()->get('craue_config')->set('download_images_enabled', 0);
1048 } 1048 }
@@ -1063,11 +1063,11 @@ class EntryControllerTest extends WallabagCoreTestCase
1063 1063
1064 $this->getEntityManager()->flush(); 1064 $this->getEntityManager()->flush();
1065 1065
1066 $client->request('GET', '/view/'.$entry->getId()); 1066 $client->request('GET', '/view/' . $entry->getId());
1067 $client->request('GET', '/archive/'.$entry->getId()); 1067 $client->request('GET', '/archive/' . $entry->getId());
1068 1068
1069 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 1069 $this->assertSame(302, $client->getResponse()->getStatusCode());
1070 $this->assertEquals('/', $client->getResponse()->headers->get('location')); 1070 $this->assertSame('/', $client->getResponse()->headers->get('location'));
1071 } 1071 }
1072 1072
1073 public function testRedirectToCurrentPage() 1073 public function testRedirectToCurrentPage()
@@ -1086,11 +1086,11 @@ class EntryControllerTest extends WallabagCoreTestCase
1086 1086
1087 $this->getEntityManager()->flush(); 1087 $this->getEntityManager()->flush();
1088 1088
1089 $client->request('GET', '/view/'.$entry->getId()); 1089 $client->request('GET', '/view/' . $entry->getId());
1090 $client->request('GET', '/archive/'.$entry->getId()); 1090 $client->request('GET', '/archive/' . $entry->getId());
1091 1091
1092 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 1092 $this->assertSame(302, $client->getResponse()->getStatusCode());
1093 $this->assertContains('/view/'.$entry->getId(), $client->getResponse()->headers->get('location')); 1093 $this->assertContains('/view/' . $entry->getId(), $client->getResponse()->headers->get('location'));
1094 } 1094 }
1095 1095
1096 public function testFilterOnHttpStatus() 1096 public function testFilterOnHttpStatus()
@@ -1213,7 +1213,7 @@ class EntryControllerTest extends WallabagCoreTestCase
1213 $crawler = $client->submit($form, $data); 1213 $crawler = $client->submit($form, $data);
1214 1214
1215 $this->assertCount(1, $crawler->filter('div[class=entry]')); 1215 $this->assertCount(1, $crawler->filter('div[class=entry]'));
1216 $client->request('GET', '/delete/'.$entry->getId()); 1216 $client->request('GET', '/delete/' . $entry->getId());
1217 1217
1218 // test on list of all articles 1218 // test on list of all articles
1219 $crawler = $client->request('GET', '/all/list'); 1219 $crawler = $client->request('GET', '/all/list');
@@ -1315,7 +1315,7 @@ class EntryControllerTest extends WallabagCoreTestCase
1315 1315
1316 $crawler = $client->request('GET', '/new'); 1316 $crawler = $client->request('GET', '/new');
1317 1317
1318 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 1318 $this->assertSame(200, $client->getResponse()->getStatusCode());
1319 1319
1320 $form = $crawler->filter('form[name=entry]')->form(); 1320 $form = $crawler->filter('form[name=entry]')->form();
1321 1321
@@ -1325,7 +1325,7 @@ class EntryControllerTest extends WallabagCoreTestCase
1325 1325
1326 $client->submit($form, $data); 1326 $client->submit($form, $data);
1327 1327
1328 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 1328 $this->assertSame(302, $client->getResponse()->getStatusCode());
1329 1329
1330 $content = $client->getContainer() 1330 $content = $client->getContainer()
1331 ->get('doctrine.orm.entity_manager') 1331 ->get('doctrine.orm.entity_manager')
@@ -1333,8 +1333,8 @@ class EntryControllerTest extends WallabagCoreTestCase
1333 ->findByUrlAndUserId($url, $this->getLoggedInUserId()); 1333 ->findByUrlAndUserId($url, $this->getLoggedInUserId());
1334 1334
1335 $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content); 1335 $this->assertInstanceOf('Wallabag\CoreBundle\Entity\Entry', $content);
1336 $this->assertEquals($url, $content->getUrl()); 1336 $this->assertSame($url, $content->getUrl());
1337 $this->assertEquals($expectedLanguage, $content->getLanguage()); 1337 $this->assertSame($expectedLanguage, $content->getLanguage());
1338 } 1338 }
1339 1339
1340 /** 1340 /**
@@ -1362,7 +1362,7 @@ class EntryControllerTest extends WallabagCoreTestCase
1362 1362
1363 $crawler = $client->request('GET', '/new'); 1363 $crawler = $client->request('GET', '/new');
1364 1364
1365 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 1365 $this->assertSame(200, $client->getResponse()->getStatusCode());
1366 1366
1367 $form = $crawler->filter('form[name=entry]')->form(); 1367 $form = $crawler->filter('form[name=entry]')->form();
1368 1368
@@ -1372,11 +1372,11 @@ class EntryControllerTest extends WallabagCoreTestCase
1372 1372
1373 $client->submit($form, $data); 1373 $client->submit($form, $data);
1374 1374
1375 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 1375 $this->assertSame(302, $client->getResponse()->getStatusCode());
1376 1376
1377 $crawler = $client->followRedirect(); 1377 $crawler = $client->followRedirect();
1378 1378
1379 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 1379 $this->assertSame(200, $client->getResponse()->getStatusCode());
1380 $this->assertContains('flashes.entry.notice.entry_saved', $crawler->filter('body')->extract(['_text'])[0]); 1380 $this->assertContains('flashes.entry.notice.entry_saved', $crawler->filter('body')->extract(['_text'])[0]);
1381 1381
1382 $content = $em 1382 $content = $em
diff --git a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php
index b38961d3..ba9296af 100644
--- a/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/ExportControllerTest.php
@@ -12,7 +12,7 @@ class ExportControllerTest extends WallabagCoreTestCase
12 12
13 $client->request('GET', '/export/unread.csv'); 13 $client->request('GET', '/export/unread.csv');
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 ExportControllerTest extends WallabagCoreTestCase
23 23
24 $client->request('GET', '/export/awesomeness.epub'); 24 $client->request('GET', '/export/awesomeness.epub');
25 25
26 $this->assertEquals(404, $client->getResponse()->getStatusCode()); 26 $this->assertSame(404, $client->getResponse()->getStatusCode());
27 } 27 }
28 28
29 public function testUnknownFormatExport() 29 public function testUnknownFormatExport()
@@ -33,7 +33,7 @@ class ExportControllerTest extends WallabagCoreTestCase
33 33
34 $client->request('GET', '/export/unread.xslx'); 34 $client->request('GET', '/export/unread.xslx');
35 35
36 $this->assertEquals(404, $client->getResponse()->getStatusCode()); 36 $this->assertSame(404, $client->getResponse()->getStatusCode());
37 } 37 }
38 38
39 public function testUnsupportedFormatExport() 39 public function testUnsupportedFormatExport()
@@ -42,15 +42,15 @@ class ExportControllerTest extends WallabagCoreTestCase
42 $client = $this->getClient(); 42 $client = $this->getClient();
43 43
44 $client->request('GET', '/export/unread.doc'); 44 $client->request('GET', '/export/unread.doc');
45 $this->assertEquals(404, $client->getResponse()->getStatusCode()); 45 $this->assertSame(404, $client->getResponse()->getStatusCode());
46 46
47 $content = $client->getContainer() 47 $content = $client->getContainer()
48 ->get('doctrine.orm.entity_manager') 48 ->get('doctrine.orm.entity_manager')
49 ->getRepository('WallabagCoreBundle:Entry') 49 ->getRepository('WallabagCoreBundle:Entry')
50 ->findOneByUsernameAndNotArchived('admin'); 50 ->findOneByUsernameAndNotArchived('admin');
51 51
52 $client->request('GET', '/export/'.$content->getId().'.doc'); 52 $client->request('GET', '/export/' . $content->getId() . '.doc');
53 $this->assertEquals(404, $client->getResponse()->getStatusCode()); 53 $this->assertSame(404, $client->getResponse()->getStatusCode());
54 } 54 }
55 55
56 public function testBadEntryId() 56 public function testBadEntryId()
@@ -60,7 +60,7 @@ class ExportControllerTest extends WallabagCoreTestCase
60 60
61 $client->request('GET', '/export/0.mobi'); 61 $client->request('GET', '/export/0.mobi');
62 62
63 $this->assertEquals(404, $client->getResponse()->getStatusCode()); 63 $this->assertSame(404, $client->getResponse()->getStatusCode());
64 } 64 }
65 65
66 public function testEpubExport() 66 public function testEpubExport()
@@ -72,12 +72,12 @@ class ExportControllerTest extends WallabagCoreTestCase
72 $crawler = $client->request('GET', '/export/archive.epub'); 72 $crawler = $client->request('GET', '/export/archive.epub');
73 ob_end_clean(); 73 ob_end_clean();
74 74
75 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 75 $this->assertSame(200, $client->getResponse()->getStatusCode());
76 76
77 $headers = $client->getResponse()->headers; 77 $headers = $client->getResponse()->headers;
78 $this->assertEquals('application/epub+zip', $headers->get('content-type')); 78 $this->assertSame('application/epub+zip', $headers->get('content-type'));
79 $this->assertEquals('attachment; filename="Archive articles.epub"', $headers->get('content-disposition')); 79 $this->assertSame('attachment; filename="Archive articles.epub"', $headers->get('content-disposition'));
80 $this->assertEquals('binary', $headers->get('content-transfer-encoding')); 80 $this->assertSame('binary', $headers->get('content-transfer-encoding'));
81 } 81 }
82 82
83 public function testMobiExport() 83 public function testMobiExport()
@@ -91,15 +91,15 @@ class ExportControllerTest extends WallabagCoreTestCase
91 ->findOneByUsernameAndNotArchived('admin'); 91 ->findOneByUsernameAndNotArchived('admin');
92 92
93 ob_start(); 93 ob_start();
94 $crawler = $client->request('GET', '/export/'.$content->getId().'.mobi'); 94 $crawler = $client->request('GET', '/export/' . $content->getId() . '.mobi');
95 ob_end_clean(); 95 ob_end_clean();
96 96
97 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 97 $this->assertSame(200, $client->getResponse()->getStatusCode());
98 98
99 $headers = $client->getResponse()->headers; 99 $headers = $client->getResponse()->headers;
100 $this->assertEquals('application/x-mobipocket-ebook', $headers->get('content-type')); 100 $this->assertSame('application/x-mobipocket-ebook', $headers->get('content-type'));
101 $this->assertEquals('attachment; filename="'.preg_replace('/[^A-Za-z0-9\-]/', '', $content->getTitle()).'.mobi"', $headers->get('content-disposition')); 101 $this->assertSame('attachment; filename="' . preg_replace('/[^A-Za-z0-9\-]/', '', $content->getTitle()) . '.mobi"', $headers->get('content-disposition'));
102 $this->assertEquals('binary', $headers->get('content-transfer-encoding')); 102 $this->assertSame('binary', $headers->get('content-transfer-encoding'));
103 } 103 }
104 104
105 public function testPdfExport() 105 public function testPdfExport()
@@ -111,23 +111,23 @@ class ExportControllerTest extends WallabagCoreTestCase
111 $crawler = $client->request('GET', '/export/all.pdf'); 111 $crawler = $client->request('GET', '/export/all.pdf');
112 ob_end_clean(); 112 ob_end_clean();
113 113
114 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 114 $this->assertSame(200, $client->getResponse()->getStatusCode());
115 115
116 $headers = $client->getResponse()->headers; 116 $headers = $client->getResponse()->headers;
117 $this->assertEquals('application/pdf', $headers->get('content-type')); 117 $this->assertSame('application/pdf', $headers->get('content-type'));
118 $this->assertEquals('attachment; filename="All articles.pdf"', $headers->get('content-disposition')); 118 $this->assertSame('attachment; filename="All articles.pdf"', $headers->get('content-disposition'));
119 $this->assertEquals('binary', $headers->get('content-transfer-encoding')); 119 $this->assertSame('binary', $headers->get('content-transfer-encoding'));
120 120
121 ob_start(); 121 ob_start();
122 $crawler = $client->request('GET', '/export/tag_entries.pdf?tag=foo-bar'); 122 $crawler = $client->request('GET', '/export/tag_entries.pdf?tag=foo-bar');
123 ob_end_clean(); 123 ob_end_clean();
124 124
125 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 125 $this->assertSame(200, $client->getResponse()->getStatusCode());
126 126
127 $headers = $client->getResponse()->headers; 127 $headers = $client->getResponse()->headers;
128 $this->assertEquals('application/pdf', $headers->get('content-type')); 128 $this->assertSame('application/pdf', $headers->get('content-type'));
129 $this->assertEquals('attachment; filename="Tag_entries articles.pdf"', $headers->get('content-disposition')); 129 $this->assertSame('attachment; filename="Tag_entries articles.pdf"', $headers->get('content-disposition'));
130 $this->assertEquals('binary', $headers->get('content-transfer-encoding')); 130 $this->assertSame('binary', $headers->get('content-transfer-encoding'));
131 } 131 }
132 132
133 public function testTxtExport() 133 public function testTxtExport()
@@ -139,12 +139,12 @@ class ExportControllerTest extends WallabagCoreTestCase
139 $crawler = $client->request('GET', '/export/all.txt'); 139 $crawler = $client->request('GET', '/export/all.txt');
140 ob_end_clean(); 140 ob_end_clean();
141 141
142 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 142 $this->assertSame(200, $client->getResponse()->getStatusCode());
143 143
144 $headers = $client->getResponse()->headers; 144 $headers = $client->getResponse()->headers;
145 $this->assertEquals('text/plain; charset=UTF-8', $headers->get('content-type')); 145 $this->assertSame('text/plain; charset=UTF-8', $headers->get('content-type'));
146 $this->assertEquals('attachment; filename="All articles.txt"', $headers->get('content-disposition')); 146 $this->assertSame('attachment; filename="All articles.txt"', $headers->get('content-disposition'));
147 $this->assertEquals('UTF-8', $headers->get('content-transfer-encoding')); 147 $this->assertSame('UTF-8', $headers->get('content-transfer-encoding'));
148 } 148 }
149 149
150 public function testCsvExport() 150 public function testCsvExport()
@@ -169,19 +169,19 @@ class ExportControllerTest extends WallabagCoreTestCase
169 $crawler = $client->request('GET', '/export/archive.csv'); 169 $crawler = $client->request('GET', '/export/archive.csv');
170 ob_end_clean(); 170 ob_end_clean();
171 171
172 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 172 $this->assertSame(200, $client->getResponse()->getStatusCode());
173 173
174 $headers = $client->getResponse()->headers; 174 $headers = $client->getResponse()->headers;
175 $this->assertEquals('application/csv', $headers->get('content-type')); 175 $this->assertSame('application/csv', $headers->get('content-type'));
176 $this->assertEquals('attachment; filename="Archive articles.csv"', $headers->get('content-disposition')); 176 $this->assertSame('attachment; filename="Archive articles.csv"', $headers->get('content-disposition'));
177 $this->assertEquals('UTF-8', $headers->get('content-transfer-encoding')); 177 $this->assertSame('UTF-8', $headers->get('content-transfer-encoding'));
178 178
179 $csv = str_getcsv($client->getResponse()->getContent(), "\n"); 179 $csv = str_getcsv($client->getResponse()->getContent(), "\n");
180 180
181 $this->assertGreaterThan(1, $csv); 181 $this->assertGreaterThan(1, $csv);
182 // +1 for title line 182 // +1 for title line
183 $this->assertEquals(count($contentInDB) + 1, count($csv)); 183 $this->assertSame(count($contentInDB) + 1, count($csv));
184 $this->assertEquals('Title;URL;Content;Tags;"MIME Type";Language;"Creation date"', $csv[0]); 184 $this->assertSame('Title;URL;Content;Tags;"MIME Type";Language;"Creation date"', $csv[0]);
185 $this->assertContains($contentInDB[0]['title'], $csv[1]); 185 $this->assertContains($contentInDB[0]['title'], $csv[1]);
186 $this->assertContains($contentInDB[0]['url'], $csv[1]); 186 $this->assertContains($contentInDB[0]['url'], $csv[1]);
187 $this->assertContains($contentInDB[0]['content'], $csv[1]); 187 $this->assertContains($contentInDB[0]['content'], $csv[1]);
@@ -205,15 +205,15 @@ class ExportControllerTest extends WallabagCoreTestCase
205 ->findByUrlAndUserId('http://0.0.0.0/entry1', $this->getLoggedInUserId()); 205 ->findByUrlAndUserId('http://0.0.0.0/entry1', $this->getLoggedInUserId());
206 206
207 ob_start(); 207 ob_start();
208 $crawler = $client->request('GET', '/export/'.$contentInDB->getId().'.json'); 208 $crawler = $client->request('GET', '/export/' . $contentInDB->getId() . '.json');
209 ob_end_clean(); 209 ob_end_clean();
210 210
211 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 211 $this->assertSame(200, $client->getResponse()->getStatusCode());
212 212
213 $headers = $client->getResponse()->headers; 213 $headers = $client->getResponse()->headers;
214 $this->assertEquals('application/json', $headers->get('content-type')); 214 $this->assertSame('application/json', $headers->get('content-type'));
215 $this->assertEquals('attachment; filename="'.$contentInDB->getTitle().'.json"', $headers->get('content-disposition')); 215 $this->assertSame('attachment; filename="' . $contentInDB->getTitle() . '.json"', $headers->get('content-disposition'));
216 $this->assertEquals('UTF-8', $headers->get('content-transfer-encoding')); 216 $this->assertSame('UTF-8', $headers->get('content-transfer-encoding'));
217 217
218 $content = json_decode($client->getResponse()->getContent(), true); 218 $content = json_decode($client->getResponse()->getContent(), true);
219 $this->assertArrayHasKey('id', $content[0]); 219 $this->assertArrayHasKey('id', $content[0]);
@@ -230,16 +230,16 @@ class ExportControllerTest extends WallabagCoreTestCase
230 $this->assertArrayHasKey('created_at', $content[0]); 230 $this->assertArrayHasKey('created_at', $content[0]);
231 $this->assertArrayHasKey('updated_at', $content[0]); 231 $this->assertArrayHasKey('updated_at', $content[0]);
232 232
233 $this->assertEquals($contentInDB->isArchived(), $content[0]['is_archived']); 233 $this->assertSame($contentInDB->isArchived(), $content[0]['is_archived']);
234 $this->assertEquals($contentInDB->isStarred(), $content[0]['is_starred']); 234 $this->assertSame($contentInDB->isStarred(), $content[0]['is_starred']);
235 $this->assertEquals($contentInDB->getTitle(), $content[0]['title']); 235 $this->assertSame($contentInDB->getTitle(), $content[0]['title']);
236 $this->assertEquals($contentInDB->getUrl(), $content[0]['url']); 236 $this->assertSame($contentInDB->getUrl(), $content[0]['url']);
237 $this->assertEquals([['text' => 'This is my annotation /o/', 'quote' => 'content']], $content[0]['annotations']); 237 $this->assertSame([['text' => 'This is my annotation /o/', 'quote' => 'content']], $content[0]['annotations']);
238 $this->assertEquals($contentInDB->getMimetype(), $content[0]['mimetype']); 238 $this->assertSame($contentInDB->getMimetype(), $content[0]['mimetype']);
239 $this->assertEquals($contentInDB->getLanguage(), $content[0]['language']); 239 $this->assertSame($contentInDB->getLanguage(), $content[0]['language']);
240 $this->assertEquals($contentInDB->getReadingtime(), $content[0]['reading_time']); 240 $this->assertSame($contentInDB->getReadingtime(), $content[0]['reading_time']);
241 $this->assertEquals($contentInDB->getDomainname(), $content[0]['domain_name']); 241 $this->assertSame($contentInDB->getDomainname(), $content[0]['domain_name']);
242 $this->assertEquals(['foo bar', 'baz'], $content[0]['tags']); 242 $this->assertSame(['foo bar', 'baz'], $content[0]['tags']);
243 } 243 }
244 244
245 public function testXmlExport() 245 public function testXmlExport()
@@ -262,16 +262,16 @@ class ExportControllerTest extends WallabagCoreTestCase
262 $crawler = $client->request('GET', '/export/unread.xml'); 262 $crawler = $client->request('GET', '/export/unread.xml');
263 ob_end_clean(); 263 ob_end_clean();
264 264
265 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 265 $this->assertSame(200, $client->getResponse()->getStatusCode());
266 266
267 $headers = $client->getResponse()->headers; 267 $headers = $client->getResponse()->headers;
268 $this->assertEquals('application/xml', $headers->get('content-type')); 268 $this->assertSame('application/xml', $headers->get('content-type'));
269 $this->assertEquals('attachment; filename="Unread articles.xml"', $headers->get('content-disposition')); 269 $this->assertSame('attachment; filename="Unread articles.xml"', $headers->get('content-disposition'));
270 $this->assertEquals('UTF-8', $headers->get('content-transfer-encoding')); 270 $this->assertSame('UTF-8', $headers->get('content-transfer-encoding'));
271 271
272 $content = new \SimpleXMLElement($client->getResponse()->getContent()); 272 $content = new \SimpleXMLElement($client->getResponse()->getContent());
273 $this->assertGreaterThan(0, $content->count()); 273 $this->assertGreaterThan(0, $content->count());
274 $this->assertEquals(count($contentInDB), $content->count()); 274 $this->assertSame(count($contentInDB), $content->count());
275 $this->assertNotEmpty('id', (string) $content->entry[0]->id); 275 $this->assertNotEmpty('id', (string) $content->entry[0]->id);
276 $this->assertNotEmpty('title', (string) $content->entry[0]->title); 276 $this->assertNotEmpty('title', (string) $content->entry[0]->title);
277 $this->assertNotEmpty('url', (string) $content->entry[0]->url); 277 $this->assertNotEmpty('url', (string) $content->entry[0]->url);
diff --git a/tests/Wallabag/CoreBundle/Controller/RssControllerTest.php b/tests/Wallabag/CoreBundle/Controller/RssControllerTest.php
index 530c8bbf..6167fe2d 100644
--- a/tests/Wallabag/CoreBundle/Controller/RssControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/RssControllerTest.php
@@ -16,36 +16,36 @@ class RssControllerTest extends WallabagCoreTestCase
16 if (null === $nb) { 16 if (null === $nb) {
17 $this->assertGreaterThan(0, $xpath->query('//item')->length); 17 $this->assertGreaterThan(0, $xpath->query('//item')->length);
18 } else { 18 } else {
19 $this->assertEquals($nb, $xpath->query('//item')->length); 19 $this->assertSame($nb, $xpath->query('//item')->length);
20 } 20 }
21 21
22 $this->assertEquals(1, $xpath->query('/rss')->length); 22 $this->assertSame(1, $xpath->query('/rss')->length);
23 $this->assertEquals(1, $xpath->query('/rss/channel')->length); 23 $this->assertSame(1, $xpath->query('/rss/channel')->length);
24 24
25 $this->assertEquals(1, $xpath->query('/rss/channel/title')->length); 25 $this->assertSame(1, $xpath->query('/rss/channel/title')->length);
26 $this->assertEquals('wallabag - '.$type.' feed', $xpath->query('/rss/channel/title')->item(0)->nodeValue); 26 $this->assertSame('wallabag - ' . $type . ' feed', $xpath->query('/rss/channel/title')->item(0)->nodeValue);
27 27
28 $this->assertEquals(1, $xpath->query('/rss/channel/pubDate')->length); 28 $this->assertSame(1, $xpath->query('/rss/channel/pubDate')->length);
29 29
30 $this->assertEquals(1, $xpath->query('/rss/channel/generator')->length); 30 $this->assertSame(1, $xpath->query('/rss/channel/generator')->length);
31 $this->assertEquals('wallabag', $xpath->query('/rss/channel/generator')->item(0)->nodeValue); 31 $this->assertSame('wallabag', $xpath->query('/rss/channel/generator')->item(0)->nodeValue);
32 32
33 $this->assertEquals(1, $xpath->query('/rss/channel/description')->length); 33 $this->assertSame(1, $xpath->query('/rss/channel/description')->length);
34 $this->assertEquals('wallabag '.$type.' elements', $xpath->query('/rss/channel/description')->item(0)->nodeValue); 34 $this->assertSame('wallabag ' . $type . ' elements', $xpath->query('/rss/channel/description')->item(0)->nodeValue);
35 35
36 $this->assertEquals(1, $xpath->query('/rss/channel/link[@rel="self"]')->length); 36 $this->assertSame(1, $xpath->query('/rss/channel/link[@rel="self"]')->length);
37 $this->assertContains($urlPagination.'.xml', $xpath->query('/rss/channel/link[@rel="self"]')->item(0)->getAttribute('href')); 37 $this->assertContains($urlPagination . '.xml', $xpath->query('/rss/channel/link[@rel="self"]')->item(0)->getAttribute('href'));
38 38
39 $this->assertEquals(1, $xpath->query('/rss/channel/link[@rel="last"]')->length); 39 $this->assertSame(1, $xpath->query('/rss/channel/link[@rel="last"]')->length);
40 $this->assertContains($urlPagination.'.xml?page=', $xpath->query('/rss/channel/link[@rel="last"]')->item(0)->getAttribute('href')); 40 $this->assertContains($urlPagination . '.xml?page=', $xpath->query('/rss/channel/link[@rel="last"]')->item(0)->getAttribute('href'));
41 41
42 foreach ($xpath->query('//item') as $item) { 42 foreach ($xpath->query('//item') as $item) {
43 $this->assertEquals(1, $xpath->query('title', $item)->length); 43 $this->assertSame(1, $xpath->query('title', $item)->length);
44 $this->assertEquals(1, $xpath->query('source', $item)->length); 44 $this->assertSame(1, $xpath->query('source', $item)->length);
45 $this->assertEquals(1, $xpath->query('link', $item)->length); 45 $this->assertSame(1, $xpath->query('link', $item)->length);
46 $this->assertEquals(1, $xpath->query('guid', $item)->length); 46 $this->assertSame(1, $xpath->query('guid', $item)->length);
47 $this->assertEquals(1, $xpath->query('pubDate', $item)->length); 47 $this->assertSame(1, $xpath->query('pubDate', $item)->length);
48 $this->assertEquals(1, $xpath->query('description', $item)->length); 48 $this->assertSame(1, $xpath->query('description', $item)->length);
49 } 49 }
50 } 50 }
51 51
@@ -73,7 +73,7 @@ class RssControllerTest extends WallabagCoreTestCase
73 73
74 $client->request('GET', $url); 74 $client->request('GET', $url);
75 75
76 $this->assertEquals(404, $client->getResponse()->getStatusCode()); 76 $this->assertSame(404, $client->getResponse()->getStatusCode());
77 } 77 }
78 78
79 public function testUnread() 79 public function testUnread()
@@ -92,7 +92,7 @@ class RssControllerTest extends WallabagCoreTestCase
92 92
93 $client->request('GET', '/admin/SUPERTOKEN/unread.xml'); 93 $client->request('GET', '/admin/SUPERTOKEN/unread.xml');
94 94
95 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 95 $this->assertSame(200, $client->getResponse()->getStatusCode());
96 96
97 $this->validateDom($client->getResponse()->getContent(), 'unread', 'unread', 2); 97 $this->validateDom($client->getResponse()->getContent(), 'unread', 'unread', 2);
98 } 98 }
@@ -114,7 +114,7 @@ class RssControllerTest extends WallabagCoreTestCase
114 $client = $this->getClient(); 114 $client = $this->getClient();
115 $client->request('GET', '/admin/SUPERTOKEN/starred.xml'); 115 $client->request('GET', '/admin/SUPERTOKEN/starred.xml');
116 116
117 $this->assertEquals(200, $client->getResponse()->getStatusCode(), 1); 117 $this->assertSame(200, $client->getResponse()->getStatusCode(), 1);
118 118
119 $this->validateDom($client->getResponse()->getContent(), 'starred', 'starred'); 119 $this->validateDom($client->getResponse()->getContent(), 'starred', 'starred');
120 } 120 }
@@ -136,7 +136,7 @@ class RssControllerTest extends WallabagCoreTestCase
136 $client = $this->getClient(); 136 $client = $this->getClient();
137 $client->request('GET', '/admin/SUPERTOKEN/archive.xml'); 137 $client->request('GET', '/admin/SUPERTOKEN/archive.xml');
138 138
139 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 139 $this->assertSame(200, $client->getResponse()->getStatusCode());
140 140
141 $this->validateDom($client->getResponse()->getContent(), 'archive', 'archive'); 141 $this->validateDom($client->getResponse()->getContent(), 'archive', 'archive');
142 } 142 }
@@ -158,15 +158,15 @@ class RssControllerTest extends WallabagCoreTestCase
158 $client = $this->getClient(); 158 $client = $this->getClient();
159 159
160 $client->request('GET', '/admin/SUPERTOKEN/unread.xml'); 160 $client->request('GET', '/admin/SUPERTOKEN/unread.xml');
161 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 161 $this->assertSame(200, $client->getResponse()->getStatusCode());
162 $this->validateDom($client->getResponse()->getContent(), 'unread', 'unread'); 162 $this->validateDom($client->getResponse()->getContent(), 'unread', 'unread');
163 163
164 $client->request('GET', '/admin/SUPERTOKEN/unread.xml?page=2'); 164 $client->request('GET', '/admin/SUPERTOKEN/unread.xml?page=2');
165 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 165 $this->assertSame(200, $client->getResponse()->getStatusCode());
166 $this->validateDom($client->getResponse()->getContent(), 'unread', 'unread'); 166 $this->validateDom($client->getResponse()->getContent(), 'unread', 'unread');
167 167
168 $client->request('GET', '/admin/SUPERTOKEN/unread.xml?page=3000'); 168 $client->request('GET', '/admin/SUPERTOKEN/unread.xml?page=3000');
169 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 169 $this->assertSame(302, $client->getResponse()->getStatusCode());
170 } 170 }
171 171
172 public function testTags() 172 public function testTags()
@@ -186,11 +186,11 @@ class RssControllerTest extends WallabagCoreTestCase
186 $client = $this->getClient(); 186 $client = $this->getClient();
187 $client->request('GET', '/admin/SUPERTOKEN/tags/foo-bar.xml'); 187 $client->request('GET', '/admin/SUPERTOKEN/tags/foo-bar.xml');
188 188
189 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 189 $this->assertSame(200, $client->getResponse()->getStatusCode());
190 190
191 $this->validateDom($client->getResponse()->getContent(), 'tag (foo bar)', 'tags/foo-bar'); 191 $this->validateDom($client->getResponse()->getContent(), 'tag (foo bar)', 'tags/foo-bar');
192 192
193 $client->request('GET', '/admin/SUPERTOKEN/tags/foo-bar.xml?page=3000'); 193 $client->request('GET', '/admin/SUPERTOKEN/tags/foo-bar.xml?page=3000');
194 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 194 $this->assertSame(302, $client->getResponse()->getStatusCode());
195 } 195 }
196} 196}
diff --git a/tests/Wallabag/CoreBundle/Controller/SettingsControllerTest.php b/tests/Wallabag/CoreBundle/Controller/SettingsControllerTest.php
index 9b8b5702..6005c0df 100644
--- a/tests/Wallabag/CoreBundle/Controller/SettingsControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/SettingsControllerTest.php
@@ -17,7 +17,7 @@ class SettingsControllerTest extends WallabagCoreTestCase
17 17
18 $crawler = $client->request('GET', '/settings'); 18 $crawler = $client->request('GET', '/settings');
19 19
20 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 20 $this->assertSame(200, $client->getResponse()->getStatusCode());
21 } 21 }
22 22
23 public function testSettingsWithNormalUser() 23 public function testSettingsWithNormalUser()
@@ -27,6 +27,6 @@ class SettingsControllerTest extends WallabagCoreTestCase
27 27
28 $crawler = $client->request('GET', '/settings'); 28 $crawler = $client->request('GET', '/settings');
29 29
30 $this->assertEquals(403, $client->getResponse()->getStatusCode()); 30 $this->assertSame(403, $client->getResponse()->getStatusCode());
31 } 31 }
32} 32}
diff --git a/tests/Wallabag/CoreBundle/Controller/SiteCredentialControllerTest.php b/tests/Wallabag/CoreBundle/Controller/SiteCredentialControllerTest.php
index e73a9743..87ea2867 100644
--- a/tests/Wallabag/CoreBundle/Controller/SiteCredentialControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/SiteCredentialControllerTest.php
@@ -15,7 +15,7 @@ class SiteCredentialControllerTest extends WallabagCoreTestCase
15 15
16 $crawler = $client->request('GET', '/site-credentials/'); 16 $crawler = $client->request('GET', '/site-credentials/');
17 17
18 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 18 $this->assertSame(200, $client->getResponse()->getStatusCode());
19 19
20 $body = $crawler->filter('body')->extract(['_text'])[0]; 20 $body = $crawler->filter('body')->extract(['_text'])[0];
21 21
@@ -30,7 +30,7 @@ class SiteCredentialControllerTest extends WallabagCoreTestCase
30 30
31 $crawler = $client->request('GET', '/site-credentials/new'); 31 $crawler = $client->request('GET', '/site-credentials/new');
32 32
33 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 33 $this->assertSame(200, $client->getResponse()->getStatusCode());
34 34
35 $body = $crawler->filter('body')->extract(['_text'])[0]; 35 $body = $crawler->filter('body')->extract(['_text'])[0];
36 36
@@ -47,7 +47,7 @@ class SiteCredentialControllerTest extends WallabagCoreTestCase
47 47
48 $client->submit($form, $data); 48 $client->submit($form, $data);
49 49
50 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 50 $this->assertSame(302, $client->getResponse()->getStatusCode());
51 51
52 $crawler = $client->followRedirect(); 52 $crawler = $client->followRedirect();
53 53
@@ -61,9 +61,9 @@ class SiteCredentialControllerTest extends WallabagCoreTestCase
61 61
62 $credential = $this->createSiteCredential($client); 62 $credential = $this->createSiteCredential($client);
63 63
64 $crawler = $client->request('GET', '/site-credentials/'.$credential->getId().'/edit'); 64 $crawler = $client->request('GET', '/site-credentials/' . $credential->getId() . '/edit');
65 65
66 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 66 $this->assertSame(200, $client->getResponse()->getStatusCode());
67 67
68 $body = $crawler->filter('body')->extract(['_text'])[0]; 68 $body = $crawler->filter('body')->extract(['_text'])[0];
69 69
@@ -80,7 +80,7 @@ class SiteCredentialControllerTest extends WallabagCoreTestCase
80 80
81 $client->submit($form, $data); 81 $client->submit($form, $data);
82 82
83 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 83 $this->assertSame(302, $client->getResponse()->getStatusCode());
84 84
85 $crawler = $client->followRedirect(); 85 $crawler = $client->followRedirect();
86 86
@@ -96,9 +96,9 @@ class SiteCredentialControllerTest extends WallabagCoreTestCase
96 96
97 $this->logInAs('bob'); 97 $this->logInAs('bob');
98 98
99 $client->request('GET', '/site-credentials/'.$credential->getId().'/edit'); 99 $client->request('GET', '/site-credentials/' . $credential->getId() . '/edit');
100 100
101 $this->assertEquals(403, $client->getResponse()->getStatusCode()); 101 $this->assertSame(403, $client->getResponse()->getStatusCode());
102 } 102 }
103 103
104 public function testDeleteSiteCredential() 104 public function testDeleteSiteCredential()
@@ -108,15 +108,15 @@ class SiteCredentialControllerTest extends WallabagCoreTestCase
108 108
109 $credential = $this->createSiteCredential($client); 109 $credential = $this->createSiteCredential($client);
110 110
111 $crawler = $client->request('GET', '/site-credentials/'.$credential->getId().'/edit'); 111 $crawler = $client->request('GET', '/site-credentials/' . $credential->getId() . '/edit');
112 112
113 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 113 $this->assertSame(200, $client->getResponse()->getStatusCode());
114 114
115 $deleteForm = $crawler->filter('body')->selectButton('site_credential.form.delete')->form(); 115 $deleteForm = $crawler->filter('body')->selectButton('site_credential.form.delete')->form();
116 116
117 $client->submit($deleteForm, []); 117 $client->submit($deleteForm, []);
118 118
119 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 119 $this->assertSame(302, $client->getResponse()->getStatusCode());
120 120
121 $crawler = $client->followRedirect(); 121 $crawler = $client->followRedirect();
122 122
diff --git a/tests/Wallabag/CoreBundle/Controller/StaticControllerTest.php b/tests/Wallabag/CoreBundle/Controller/StaticControllerTest.php
index 98a37b50..17847937 100644
--- a/tests/Wallabag/CoreBundle/Controller/StaticControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/StaticControllerTest.php
@@ -13,7 +13,7 @@ class StaticControllerTest extends WallabagCoreTestCase
13 13
14 $client->request('GET', '/about'); 14 $client->request('GET', '/about');
15 15
16 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 16 $this->assertSame(200, $client->getResponse()->getStatusCode());
17 } 17 }
18 18
19 public function testHowto() 19 public function testHowto()
@@ -23,6 +23,6 @@ class StaticControllerTest extends WallabagCoreTestCase
23 23
24 $client->request('GET', '/howto'); 24 $client->request('GET', '/howto');
25 25
26 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 26 $this->assertSame(200, $client->getResponse()->getStatusCode());
27 } 27 }
28} 28}
diff --git a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
index af1ad7af..be25a8b5 100644
--- a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
@@ -17,7 +17,7 @@ class TagControllerTest extends WallabagCoreTestCase
17 17
18 $client->request('GET', '/tag/list'); 18 $client->request('GET', '/tag/list');
19 19
20 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 20 $this->assertSame(200, $client->getResponse()->getStatusCode());
21 } 21 }
22 22
23 public function testAddTagToEntry() 23 public function testAddTagToEntry()
@@ -31,7 +31,7 @@ class TagControllerTest extends WallabagCoreTestCase
31 $this->getEntityManager()->flush(); 31 $this->getEntityManager()->flush();
32 $this->getEntityManager()->clear(); 32 $this->getEntityManager()->clear();
33 33
34 $crawler = $client->request('GET', '/view/'.$entry->getId()); 34 $crawler = $client->request('GET', '/view/' . $entry->getId());
35 35
36 $form = $crawler->filter('form[name=tag]')->form(); 36 $form = $crawler->filter('form[name=tag]')->form();
37 37
@@ -40,7 +40,7 @@ class TagControllerTest extends WallabagCoreTestCase
40 ]; 40 ];
41 41
42 $client->submit($form, $data); 42 $client->submit($form, $data);
43 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 43 $this->assertSame(302, $client->getResponse()->getStatusCode());
44 44
45 // be sure to reload the entry 45 // be sure to reload the entry
46 $entry = $this->getEntityManager()->getRepository(Entry::class)->find($entry->getId()); 46 $entry = $this->getEntityManager()->getRepository(Entry::class)->find($entry->getId());
@@ -48,7 +48,7 @@ class TagControllerTest extends WallabagCoreTestCase
48 48
49 // tag already exists and already assigned 49 // tag already exists and already assigned
50 $client->submit($form, $data); 50 $client->submit($form, $data);
51 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 51 $this->assertSame(302, $client->getResponse()->getStatusCode());
52 52
53 $entry = $this->getEntityManager()->getRepository(Entry::class)->find($entry->getId()); 53 $entry = $this->getEntityManager()->getRepository(Entry::class)->find($entry->getId());
54 $this->assertCount(1, $entry->getTags()); 54 $this->assertCount(1, $entry->getTags());
@@ -59,7 +59,7 @@ class TagControllerTest extends WallabagCoreTestCase
59 ]; 59 ];
60 60
61 $client->submit($form, $data); 61 $client->submit($form, $data);
62 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 62 $this->assertSame(302, $client->getResponse()->getStatusCode());
63 63
64 $entry = $this->getEntityManager()->getRepository(Entry::class)->find($entry->getId()); 64 $entry = $this->getEntityManager()->getRepository(Entry::class)->find($entry->getId());
65 $this->assertCount(2, $entry->getTags()); 65 $this->assertCount(2, $entry->getTags());
@@ -75,7 +75,7 @@ class TagControllerTest extends WallabagCoreTestCase
75 ->getRepository('WallabagCoreBundle:Entry') 75 ->getRepository('WallabagCoreBundle:Entry')
76 ->findByUrlAndUserId('http://0.0.0.0/entry2', $this->getLoggedInUserId()); 76 ->findByUrlAndUserId('http://0.0.0.0/entry2', $this->getLoggedInUserId());
77 77
78 $crawler = $client->request('GET', '/view/'.$entry->getId()); 78 $crawler = $client->request('GET', '/view/' . $entry->getId());
79 79
80 $form = $crawler->filter('form[name=tag]')->form(); 80 $form = $crawler->filter('form[name=tag]')->form();
81 81
@@ -84,7 +84,7 @@ class TagControllerTest extends WallabagCoreTestCase
84 ]; 84 ];
85 85
86 $client->submit($form, $data); 86 $client->submit($form, $data);
87 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 87 $this->assertSame(302, $client->getResponse()->getStatusCode());
88 88
89 $newEntry = $client->getContainer() 89 $newEntry = $client->getContainer()
90 ->get('doctrine.orm.entity_manager') 90 ->get('doctrine.orm.entity_manager')
@@ -97,8 +97,8 @@ class TagControllerTest extends WallabagCoreTestCase
97 } 97 }
98 98
99 $this->assertGreaterThanOrEqual(2, count($tags)); 99 $this->assertGreaterThanOrEqual(2, count($tags));
100 $this->assertNotFalse(array_search('foo2', $tags), 'Tag foo2 is assigned to the entry'); 100 $this->assertNotFalse(array_search('foo2', $tags, true), 'Tag foo2 is assigned to the entry');
101 $this->assertNotFalse(array_search('bar2', $tags), 'Tag bar2 is assigned to the entry'); 101 $this->assertNotFalse(array_search('bar2', $tags, true), 'Tag bar2 is assigned to the entry');
102 } 102 }
103 103
104 public function testRemoveTagFromEntry() 104 public function testRemoveTagFromEntry()
@@ -116,27 +116,27 @@ class TagControllerTest extends WallabagCoreTestCase
116 $this->getEntityManager()->clear(); 116 $this->getEntityManager()->clear();
117 117
118 // We make a first request to set an history and test redirection after tag deletion 118 // We make a first request to set an history and test redirection after tag deletion
119 $client->request('GET', '/view/'.$entry->getId()); 119 $client->request('GET', '/view/' . $entry->getId());
120 $entryUri = $client->getRequest()->getUri(); 120 $entryUri = $client->getRequest()->getUri();
121 $client->request('GET', '/remove-tag/'.$entry->getId().'/'.$tag->getId()); 121 $client->request('GET', '/remove-tag/' . $entry->getId() . '/' . $tag->getId());
122 122
123 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 123 $this->assertSame(302, $client->getResponse()->getStatusCode());
124 $this->assertEquals($entryUri, $client->getResponse()->getTargetUrl()); 124 $this->assertSame($entryUri, $client->getResponse()->getTargetUrl());
125 125
126 // re-retrieve the entry to be sure to get fresh data from database (mostly for tags) 126 // re-retrieve the entry to be sure to get fresh data from database (mostly for tags)
127 $entry = $this->getEntityManager()->getRepository(Entry::class)->find($entry->getId()); 127 $entry = $this->getEntityManager()->getRepository(Entry::class)->find($entry->getId());
128 $this->assertNotContains($this->tagName, $entry->getTags()); 128 $this->assertNotContains($this->tagName, $entry->getTags());
129 129
130 $client->request('GET', '/remove-tag/'.$entry->getId().'/'.$tag->getId()); 130 $client->request('GET', '/remove-tag/' . $entry->getId() . '/' . $tag->getId());
131 131
132 $this->assertEquals(404, $client->getResponse()->getStatusCode()); 132 $this->assertSame(404, $client->getResponse()->getStatusCode());
133 133
134 $tag = $client->getContainer() 134 $tag = $client->getContainer()
135 ->get('doctrine.orm.entity_manager') 135 ->get('doctrine.orm.entity_manager')
136 ->getRepository('WallabagCoreBundle:Tag') 136 ->getRepository('WallabagCoreBundle:Tag')
137 ->findOneByLabel($this->tagName); 137 ->findOneByLabel($this->tagName);
138 138
139 $this->assertNull($tag, $this->tagName.' was removed because it begun an orphan tag'); 139 $this->assertNull($tag, $this->tagName . ' was removed because it begun an orphan tag');
140 } 140 }
141 141
142 public function testShowEntriesForTagAction() 142 public function testShowEntriesForTagAction()
@@ -165,9 +165,9 @@ class TagControllerTest extends WallabagCoreTestCase
165 ->getRepository('WallabagCoreBundle:Tag') 165 ->getRepository('WallabagCoreBundle:Tag')
166 ->findOneByEntryAndTagLabel($entry, $this->tagName); 166 ->findOneByEntryAndTagLabel($entry, $this->tagName);
167 167
168 $crawler = $client->request('GET', '/tag/list/'.$tag->getSlug()); 168 $crawler = $client->request('GET', '/tag/list/' . $tag->getSlug());
169 169
170 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 170 $this->assertSame(200, $client->getResponse()->getStatusCode());
171 $this->assertCount(1, $crawler->filter('[id*="entry-"]')); 171 $this->assertCount(1, $crawler->filter('[id*="entry-"]'));
172 172
173 $entry->removeTag($tag); 173 $entry->removeTag($tag);
diff --git a/tests/Wallabag/CoreBundle/Event/Listener/LocaleListenerTest.php b/tests/Wallabag/CoreBundle/Event/Listener/LocaleListenerTest.php
index 84a54d3a..0dbd9f70 100644
--- a/tests/Wallabag/CoreBundle/Event/Listener/LocaleListenerTest.php
+++ b/tests/Wallabag/CoreBundle/Event/Listener/LocaleListenerTest.php
@@ -13,15 +13,6 @@ use Wallabag\CoreBundle\Event\Listener\LocaleListener;
13 13
14class LocaleListenerTest extends \PHPUnit_Framework_TestCase 14class LocaleListenerTest extends \PHPUnit_Framework_TestCase
15{ 15{
16 private function getEvent(Request $request)
17 {
18 $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')
19 ->disableOriginalConstructor()
20 ->getMock();
21
22 return new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
23 }
24
25 public function testWithoutSession() 16 public function testWithoutSession()
26 { 17 {
27 $request = Request::create('/'); 18 $request = Request::create('/');
@@ -30,7 +21,7 @@ class LocaleListenerTest extends \PHPUnit_Framework_TestCase
30 $event = $this->getEvent($request); 21 $event = $this->getEvent($request);
31 22
32 $listener->onKernelRequest($event); 23 $listener->onKernelRequest($event);
33 $this->assertEquals('en', $request->getLocale()); 24 $this->assertSame('en', $request->getLocale());
34 } 25 }
35 26
36 public function testWithPreviousSession() 27 public function testWithPreviousSession()
@@ -44,7 +35,7 @@ class LocaleListenerTest extends \PHPUnit_Framework_TestCase
44 $event = $this->getEvent($request); 35 $event = $this->getEvent($request);
45 36
46 $listener->onKernelRequest($event); 37 $listener->onKernelRequest($event);
47 $this->assertEquals('fr', $request->getLocale()); 38 $this->assertSame('fr', $request->getLocale());
48 } 39 }
49 40
50 public function testLocaleFromRequestAttribute() 41 public function testLocaleFromRequestAttribute()
@@ -59,8 +50,8 @@ class LocaleListenerTest extends \PHPUnit_Framework_TestCase
59 $event = $this->getEvent($request); 50 $event = $this->getEvent($request);
60 51
61 $listener->onKernelRequest($event); 52 $listener->onKernelRequest($event);
62 $this->assertEquals('en', $request->getLocale()); 53 $this->assertSame('en', $request->getLocale());
63 $this->assertEquals('es', $request->getSession()->get('_locale')); 54 $this->assertSame('es', $request->getSession()->get('_locale'));
64 } 55 }
65 56
66 public function testSubscribedEvents() 57 public function testSubscribedEvents()
@@ -81,6 +72,15 @@ class LocaleListenerTest extends \PHPUnit_Framework_TestCase
81 $event 72 $event
82 ); 73 );
83 74
84 $this->assertEquals('fr', $request->getLocale()); 75 $this->assertSame('fr', $request->getLocale());
76 }
77
78 private function getEvent(Request $request)
79 {
80 $kernel = $this->getMockBuilder('Symfony\Component\HttpKernel\HttpKernelInterface')
81 ->disableOriginalConstructor()
82 ->getMock();
83
84 return new GetResponseEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST);
85 } 85 }
86} 86}
diff --git a/tests/Wallabag/CoreBundle/Event/Listener/UserLocaleListenerTest.php b/tests/Wallabag/CoreBundle/Event/Listener/UserLocaleListenerTest.php
index 45aecc63..91ce0102 100644
--- a/tests/Wallabag/CoreBundle/Event/Listener/UserLocaleListenerTest.php
+++ b/tests/Wallabag/CoreBundle/Event/Listener/UserLocaleListenerTest.php
@@ -32,7 +32,7 @@ class UserLocaleListenerTest extends \PHPUnit_Framework_TestCase
32 32
33 $listener->onInteractiveLogin($event); 33 $listener->onInteractiveLogin($event);
34 34
35 $this->assertEquals('fr', $session->get('_locale')); 35 $this->assertSame('fr', $session->get('_locale'));
36 } 36 }
37 37
38 public function testWithoutLanguage() 38 public function testWithoutLanguage()
@@ -53,6 +53,6 @@ class UserLocaleListenerTest extends \PHPUnit_Framework_TestCase
53 53
54 $listener->onInteractiveLogin($event); 54 $listener->onInteractiveLogin($event);
55 55
56 $this->assertEquals('', $session->get('_locale')); 56 $this->assertSame('', $session->get('_locale'));
57 } 57 }
58} 58}
diff --git a/tests/Wallabag/CoreBundle/Event/Subscriber/TablePrefixSubscriberTest.php b/tests/Wallabag/CoreBundle/Event/Subscriber/TablePrefixSubscriberTest.php
index b8cd0fad..64e3c6d9 100644
--- a/tests/Wallabag/CoreBundle/Event/Subscriber/TablePrefixSubscriberTest.php
+++ b/tests/Wallabag/CoreBundle/Event/Subscriber/TablePrefixSubscriberTest.php
@@ -46,12 +46,12 @@ class TablePrefixSubscriberTest extends \PHPUnit_Framework_TestCase
46 46
47 $metaDataEvent = new LoadClassMetadataEventArgs($metaClass, $em); 47 $metaDataEvent = new LoadClassMetadataEventArgs($metaClass, $em);
48 48
49 $this->assertEquals($tableNameExpected, $metaDataEvent->getClassMetadata()->getTableName()); 49 $this->assertSame($tableNameExpected, $metaDataEvent->getClassMetadata()->getTableName());
50 50
51 $subscriber->loadClassMetadata($metaDataEvent); 51 $subscriber->loadClassMetadata($metaDataEvent);
52 52
53 $this->assertEquals($finalTableName, $metaDataEvent->getClassMetadata()->getTableName()); 53 $this->assertSame($finalTableName, $metaDataEvent->getClassMetadata()->getTableName());
54 $this->assertEquals($finalTableNameQuoted, $metaDataEvent->getClassMetadata()->getQuotedTableName($platform)); 54 $this->assertSame($finalTableNameQuoted, $metaDataEvent->getClassMetadata()->getQuotedTableName($platform));
55 } 55 }
56 56
57 /** 57 /**
@@ -75,8 +75,8 @@ class TablePrefixSubscriberTest extends \PHPUnit_Framework_TestCase
75 75
76 $evm->dispatchEvent('loadClassMetadata', $metaDataEvent); 76 $evm->dispatchEvent('loadClassMetadata', $metaDataEvent);
77 77
78 $this->assertEquals($finalTableName, $metaDataEvent->getClassMetadata()->getTableName()); 78 $this->assertSame($finalTableName, $metaDataEvent->getClassMetadata()->getTableName());
79 $this->assertEquals($finalTableNameQuoted, $metaDataEvent->getClassMetadata()->getQuotedTableName($platform)); 79 $this->assertSame($finalTableNameQuoted, $metaDataEvent->getClassMetadata()->getQuotedTableName($platform));
80 } 80 }
81 81
82 public function testPrefixManyToMany() 82 public function testPrefixManyToMany()
@@ -103,12 +103,12 @@ class TablePrefixSubscriberTest extends \PHPUnit_Framework_TestCase
103 103
104 $metaDataEvent = new LoadClassMetadataEventArgs($metaClass, $em); 104 $metaDataEvent = new LoadClassMetadataEventArgs($metaClass, $em);
105 105
106 $this->assertEquals('entry', $metaDataEvent->getClassMetadata()->getTableName()); 106 $this->assertSame('entry', $metaDataEvent->getClassMetadata()->getTableName());
107 107
108 $subscriber->loadClassMetadata($metaDataEvent); 108 $subscriber->loadClassMetadata($metaDataEvent);
109 109
110 $this->assertEquals('yo_entry', $metaDataEvent->getClassMetadata()->getTableName()); 110 $this->assertSame('yo_entry', $metaDataEvent->getClassMetadata()->getTableName());
111 $this->assertEquals('yo_entry_tag', $metaDataEvent->getClassMetadata()->associationMappings['tags']['joinTable']['name']); 111 $this->assertSame('yo_entry_tag', $metaDataEvent->getClassMetadata()->associationMappings['tags']['joinTable']['name']);
112 $this->assertEquals('yo_entry', $metaDataEvent->getClassMetadata()->getQuotedTableName(new \Doctrine\DBAL\Platforms\MySqlPlatform())); 112 $this->assertSame('yo_entry', $metaDataEvent->getClassMetadata()->getQuotedTableName(new \Doctrine\DBAL\Platforms\MySqlPlatform()));
113 } 113 }
114} 114}
diff --git a/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php b/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php
index b0c81e7b..85036e35 100644
--- a/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php
+++ b/tests/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilderTest.php
@@ -2,13 +2,13 @@
2 2
3namespace Tests\Wallabag\CoreBundle\GuzzleSiteAuthenticator; 3namespace Tests\Wallabag\CoreBundle\GuzzleSiteAuthenticator;
4 4
5use Monolog\Handler\TestHandler;
6use Monolog\Logger;
7use BD\GuzzleSiteAuthenticator\SiteConfig\SiteConfig; 5use BD\GuzzleSiteAuthenticator\SiteConfig\SiteConfig;
8use Graby\SiteConfig\SiteConfig as GrabySiteConfig; 6use Graby\SiteConfig\SiteConfig as GrabySiteConfig;
9use Wallabag\CoreBundle\GuzzleSiteAuthenticator\GrabySiteConfigBuilder; 7use Monolog\Handler\TestHandler;
10use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; 8use Monolog\Logger;
11use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; 9use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
10use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
11use Wallabag\CoreBundle\GuzzleSiteAuthenticator\GrabySiteConfigBuilder;
12 12
13class GrabySiteConfigBuilderTest extends \PHPUnit_Framework_TestCase 13class GrabySiteConfigBuilderTest extends \PHPUnit_Framework_TestCase
14{ 14{
@@ -68,7 +68,7 @@ class GrabySiteConfigBuilderTest extends \PHPUnit_Framework_TestCase
68 68
69 $config = $this->builder->buildForHost('www.example.com'); 69 $config = $this->builder->buildForHost('www.example.com');
70 70
71 $this->assertEquals( 71 $this->assertSame(
72 new SiteConfig([ 72 new SiteConfig([
73 'host' => 'example.com', 73 'host' => 'example.com',
74 'requiresLogin' => true, 74 'requiresLogin' => true,
diff --git a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
index dbddbc5c..7e19631b 100644
--- a/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
+++ b/tests/Wallabag/CoreBundle/Helper/ContentProxyTest.php
@@ -2,18 +2,18 @@
2 2
3namespace Tests\Wallabag\CoreBundle\Helper; 3namespace Tests\Wallabag\CoreBundle\Helper;
4 4
5use Psr\Log\NullLogger; 5use Graby\Graby;
6use Monolog\Logger;
7use Monolog\Handler\TestHandler; 6use Monolog\Handler\TestHandler;
8use Wallabag\CoreBundle\Helper\ContentProxy; 7use Monolog\Logger;
8use Psr\Log\NullLogger;
9use Symfony\Component\Validator\ConstraintViolation;
10use Symfony\Component\Validator\ConstraintViolationList;
11use Symfony\Component\Validator\Validator\RecursiveValidator;
9use Wallabag\CoreBundle\Entity\Entry; 12use Wallabag\CoreBundle\Entity\Entry;
10use Wallabag\CoreBundle\Entity\Tag; 13use Wallabag\CoreBundle\Entity\Tag;
11use Wallabag\UserBundle\Entity\User; 14use Wallabag\CoreBundle\Helper\ContentProxy;
12use Wallabag\CoreBundle\Helper\RuleBasedTagger; 15use Wallabag\CoreBundle\Helper\RuleBasedTagger;
13use Graby\Graby; 16use Wallabag\UserBundle\Entity\User;
14use Symfony\Component\Validator\Validator\RecursiveValidator;
15use Symfony\Component\Validator\ConstraintViolationList;
16use Symfony\Component\Validator\ConstraintViolation;
17 17
18class ContentProxyTest extends \PHPUnit_Framework_TestCase 18class ContentProxyTest extends \PHPUnit_Framework_TestCase
19{ 19{
@@ -44,14 +44,14 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
44 $entry = new Entry(new User()); 44 $entry = new Entry(new User());
45 $proxy->updateEntry($entry, 'http://user@:80'); 45 $proxy->updateEntry($entry, 'http://user@:80');
46 46
47 $this->assertEquals('http://user@:80', $entry->getUrl()); 47 $this->assertSame('http://user@:80', $entry->getUrl());
48 $this->assertEmpty($entry->getTitle()); 48 $this->assertEmpty($entry->getTitle());
49 $this->assertEquals($this->fetchingErrorMessage, $entry->getContent()); 49 $this->assertSame($this->fetchingErrorMessage, $entry->getContent());
50 $this->assertEmpty($entry->getPreviewPicture()); 50 $this->assertEmpty($entry->getPreviewPicture());
51 $this->assertEmpty($entry->getMimetype()); 51 $this->assertEmpty($entry->getMimetype());
52 $this->assertEmpty($entry->getLanguage()); 52 $this->assertEmpty($entry->getLanguage());
53 $this->assertEquals(0.0, $entry->getReadingTime()); 53 $this->assertSame(0.0, $entry->getReadingTime());
54 $this->assertEquals(false, $entry->getDomainName()); 54 $this->assertSame(false, $entry->getDomainName());
55 } 55 }
56 56
57 public function testWithEmptyContent() 57 public function testWithEmptyContent()
@@ -79,14 +79,14 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
79 $entry = new Entry(new User()); 79 $entry = new Entry(new User());
80 $proxy->updateEntry($entry, 'http://0.0.0.0'); 80 $proxy->updateEntry($entry, 'http://0.0.0.0');
81 81
82 $this->assertEquals('http://0.0.0.0', $entry->getUrl()); 82 $this->assertSame('http://0.0.0.0', $entry->getUrl());
83 $this->assertEmpty($entry->getTitle()); 83 $this->assertEmpty($entry->getTitle());
84 $this->assertEquals($this->fetchingErrorMessage, $entry->getContent()); 84 $this->assertSame($this->fetchingErrorMessage, $entry->getContent());
85 $this->assertEmpty($entry->getPreviewPicture()); 85 $this->assertEmpty($entry->getPreviewPicture());
86 $this->assertEmpty($entry->getMimetype()); 86 $this->assertEmpty($entry->getMimetype());
87 $this->assertEmpty($entry->getLanguage()); 87 $this->assertEmpty($entry->getLanguage());
88 $this->assertEquals(0.0, $entry->getReadingTime()); 88 $this->assertSame(0.0, $entry->getReadingTime());
89 $this->assertEquals('0.0.0.0', $entry->getDomainName()); 89 $this->assertSame('0.0.0.0', $entry->getDomainName());
90 } 90 }
91 91
92 public function testWithEmptyContentButOG() 92 public function testWithEmptyContentButOG()
@@ -119,15 +119,15 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
119 $entry = new Entry(new User()); 119 $entry = new Entry(new User());
120 $proxy->updateEntry($entry, 'http://domain.io'); 120 $proxy->updateEntry($entry, 'http://domain.io');
121 121
122 $this->assertEquals('http://domain.io', $entry->getUrl()); 122 $this->assertSame('http://domain.io', $entry->getUrl());
123 $this->assertEquals('my title', $entry->getTitle()); 123 $this->assertSame('my title', $entry->getTitle());
124 $this->assertEquals($this->fetchingErrorMessage.'<p><i>But we found a short description: </i></p>desc', $entry->getContent()); 124 $this->assertSame($this->fetchingErrorMessage . '<p><i>But we found a short description: </i></p>desc', $entry->getContent());
125 $this->assertEmpty($entry->getPreviewPicture()); 125 $this->assertEmpty($entry->getPreviewPicture());
126 $this->assertEmpty($entry->getLanguage()); 126 $this->assertEmpty($entry->getLanguage());
127 $this->assertEmpty($entry->getHttpStatus()); 127 $this->assertEmpty($entry->getHttpStatus());
128 $this->assertEmpty($entry->getMimetype()); 128 $this->assertEmpty($entry->getMimetype());
129 $this->assertEquals(0.0, $entry->getReadingTime()); 129 $this->assertSame(0.0, $entry->getReadingTime());
130 $this->assertEquals('domain.io', $entry->getDomainName()); 130 $this->assertSame('domain.io', $entry->getDomainName());
131 } 131 }
132 132
133 public function testWithContent() 133 public function testWithContent()
@@ -161,15 +161,15 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
161 $entry = new Entry(new User()); 161 $entry = new Entry(new User());
162 $proxy->updateEntry($entry, 'http://0.0.0.0'); 162 $proxy->updateEntry($entry, 'http://0.0.0.0');
163 163
164 $this->assertEquals('http://1.1.1.1', $entry->getUrl()); 164 $this->assertSame('http://1.1.1.1', $entry->getUrl());
165 $this->assertEquals('this is my title', $entry->getTitle()); 165 $this->assertSame('this is my title', $entry->getTitle());
166 $this->assertContains('this is my content', $entry->getContent()); 166 $this->assertContains('this is my content', $entry->getContent());
167 $this->assertEquals('http://3.3.3.3/cover.jpg', $entry->getPreviewPicture()); 167 $this->assertSame('http://3.3.3.3/cover.jpg', $entry->getPreviewPicture());
168 $this->assertEquals('text/html', $entry->getMimetype()); 168 $this->assertSame('text/html', $entry->getMimetype());
169 $this->assertEquals('fr', $entry->getLanguage()); 169 $this->assertSame('fr', $entry->getLanguage());
170 $this->assertEquals('200', $entry->getHttpStatus()); 170 $this->assertSame('200', $entry->getHttpStatus());
171 $this->assertEquals(4.0, $entry->getReadingTime()); 171 $this->assertSame(4.0, $entry->getReadingTime());
172 $this->assertEquals('1.1.1.1', $entry->getDomainName()); 172 $this->assertSame('1.1.1.1', $entry->getDomainName());
173 } 173 }
174 174
175 public function testWithContentAndNoOgImage() 175 public function testWithContentAndNoOgImage()
@@ -203,15 +203,15 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
203 $entry = new Entry(new User()); 203 $entry = new Entry(new User());
204 $proxy->updateEntry($entry, 'http://0.0.0.0'); 204 $proxy->updateEntry($entry, 'http://0.0.0.0');
205 205
206 $this->assertEquals('http://1.1.1.1', $entry->getUrl()); 206 $this->assertSame('http://1.1.1.1', $entry->getUrl());
207 $this->assertEquals('this is my title', $entry->getTitle()); 207 $this->assertSame('this is my title', $entry->getTitle());
208 $this->assertContains('this is my content', $entry->getContent()); 208 $this->assertContains('this is my content', $entry->getContent());
209 $this->assertNull($entry->getPreviewPicture()); 209 $this->assertNull($entry->getPreviewPicture());
210 $this->assertEquals('text/html', $entry->getMimetype()); 210 $this->assertSame('text/html', $entry->getMimetype());
211 $this->assertEquals('fr', $entry->getLanguage()); 211 $this->assertSame('fr', $entry->getLanguage());
212 $this->assertEquals('200', $entry->getHttpStatus()); 212 $this->assertSame('200', $entry->getHttpStatus());
213 $this->assertEquals(4.0, $entry->getReadingTime()); 213 $this->assertSame(4.0, $entry->getReadingTime());
214 $this->assertEquals('1.1.1.1', $entry->getDomainName()); 214 $this->assertSame('1.1.1.1', $entry->getDomainName());
215 } 215 }
216 216
217 public function testWithContentAndBadLanguage() 217 public function testWithContentAndBadLanguage()
@@ -248,14 +248,14 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
248 $entry = new Entry(new User()); 248 $entry = new Entry(new User());
249 $proxy->updateEntry($entry, 'http://0.0.0.0'); 249 $proxy->updateEntry($entry, 'http://0.0.0.0');
250 250
251 $this->assertEquals('http://1.1.1.1', $entry->getUrl()); 251 $this->assertSame('http://1.1.1.1', $entry->getUrl());
252 $this->assertEquals('this is my title', $entry->getTitle()); 252 $this->assertSame('this is my title', $entry->getTitle());
253 $this->assertContains('this is my content', $entry->getContent()); 253 $this->assertContains('this is my content', $entry->getContent());
254 $this->assertEquals('text/html', $entry->getMimetype()); 254 $this->assertSame('text/html', $entry->getMimetype());
255 $this->assertNull($entry->getLanguage()); 255 $this->assertNull($entry->getLanguage());
256 $this->assertEquals('200', $entry->getHttpStatus()); 256 $this->assertSame('200', $entry->getHttpStatus());
257 $this->assertEquals(4.0, $entry->getReadingTime()); 257 $this->assertSame(4.0, $entry->getReadingTime());
258 $this->assertEquals('1.1.1.1', $entry->getDomainName()); 258 $this->assertSame('1.1.1.1', $entry->getDomainName());
259 } 259 }
260 260
261 public function testWithContentAndBadOgImage() 261 public function testWithContentAndBadOgImage()
@@ -297,15 +297,15 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
297 $entry = new Entry(new User()); 297 $entry = new Entry(new User());
298 $proxy->updateEntry($entry, 'http://0.0.0.0'); 298 $proxy->updateEntry($entry, 'http://0.0.0.0');
299 299
300 $this->assertEquals('http://1.1.1.1', $entry->getUrl()); 300 $this->assertSame('http://1.1.1.1', $entry->getUrl());
301 $this->assertEquals('this is my title', $entry->getTitle()); 301 $this->assertSame('this is my title', $entry->getTitle());
302 $this->assertContains('this is my content', $entry->getContent()); 302 $this->assertContains('this is my content', $entry->getContent());
303 $this->assertNull($entry->getPreviewPicture()); 303 $this->assertNull($entry->getPreviewPicture());
304 $this->assertEquals('text/html', $entry->getMimetype()); 304 $this->assertSame('text/html', $entry->getMimetype());
305 $this->assertEquals('fr', $entry->getLanguage()); 305 $this->assertSame('fr', $entry->getLanguage());
306 $this->assertEquals('200', $entry->getHttpStatus()); 306 $this->assertSame('200', $entry->getHttpStatus());
307 $this->assertEquals(4.0, $entry->getReadingTime()); 307 $this->assertSame(4.0, $entry->getReadingTime());
308 $this->assertEquals('1.1.1.1', $entry->getDomainName()); 308 $this->assertSame('1.1.1.1', $entry->getDomainName());
309 } 309 }
310 310
311 public function testWithForcedContent() 311 public function testWithForcedContent()
@@ -333,14 +333,14 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
333 ] 333 ]
334 ); 334 );
335 335
336 $this->assertEquals('http://1.1.1.1', $entry->getUrl()); 336 $this->assertSame('http://1.1.1.1', $entry->getUrl());
337 $this->assertEquals('this is my title', $entry->getTitle()); 337 $this->assertSame('this is my title', $entry->getTitle());
338 $this->assertContains('this is my content', $entry->getContent()); 338 $this->assertContains('this is my content', $entry->getContent());
339 $this->assertEquals('text/html', $entry->getMimetype()); 339 $this->assertSame('text/html', $entry->getMimetype());
340 $this->assertEquals('fr', $entry->getLanguage()); 340 $this->assertSame('fr', $entry->getLanguage());
341 $this->assertEquals(4.0, $entry->getReadingTime()); 341 $this->assertSame(4.0, $entry->getReadingTime());
342 $this->assertEquals('1.1.1.1', $entry->getDomainName()); 342 $this->assertSame('1.1.1.1', $entry->getDomainName());
343 $this->assertEquals('24/03/2014', $entry->getPublishedAt()->format('d/m/Y')); 343 $this->assertSame('24/03/2014', $entry->getPublishedAt()->format('d/m/Y'));
344 $this->assertContains('Jeremy', $entry->getPublishedBy()); 344 $this->assertContains('Jeremy', $entry->getPublishedBy());
345 $this->assertContains('Nico', $entry->getPublishedBy()); 345 $this->assertContains('Nico', $entry->getPublishedBy());
346 $this->assertContains('Thomas', $entry->getPublishedBy()); 346 $this->assertContains('Thomas', $entry->getPublishedBy());
@@ -371,14 +371,14 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
371 ] 371 ]
372 ); 372 );
373 373
374 $this->assertEquals('http://1.1.1.1', $entry->getUrl()); 374 $this->assertSame('http://1.1.1.1', $entry->getUrl());
375 $this->assertEquals('this is my title', $entry->getTitle()); 375 $this->assertSame('this is my title', $entry->getTitle());
376 $this->assertContains('this is my content', $entry->getContent()); 376 $this->assertContains('this is my content', $entry->getContent());
377 $this->assertEquals('text/html', $entry->getMimetype()); 377 $this->assertSame('text/html', $entry->getMimetype());
378 $this->assertEquals('fr', $entry->getLanguage()); 378 $this->assertSame('fr', $entry->getLanguage());
379 $this->assertEquals(4.0, $entry->getReadingTime()); 379 $this->assertSame(4.0, $entry->getReadingTime());
380 $this->assertEquals('1.1.1.1', $entry->getDomainName()); 380 $this->assertSame('1.1.1.1', $entry->getDomainName());
381 $this->assertEquals('08/09/2016', $entry->getPublishedAt()->format('d/m/Y')); 381 $this->assertSame('08/09/2016', $entry->getPublishedAt()->format('d/m/Y'));
382 } 382 }
383 383
384 public function testWithForcedContentAndBadDate() 384 public function testWithForcedContentAndBadDate()
@@ -406,13 +406,13 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
406 ] 406 ]
407 ); 407 );
408 408
409 $this->assertEquals('http://1.1.1.1', $entry->getUrl()); 409 $this->assertSame('http://1.1.1.1', $entry->getUrl());
410 $this->assertEquals('this is my title', $entry->getTitle()); 410 $this->assertSame('this is my title', $entry->getTitle());
411 $this->assertContains('this is my content', $entry->getContent()); 411 $this->assertContains('this is my content', $entry->getContent());
412 $this->assertEquals('text/html', $entry->getMimetype()); 412 $this->assertSame('text/html', $entry->getMimetype());
413 $this->assertEquals('fr', $entry->getLanguage()); 413 $this->assertSame('fr', $entry->getLanguage());
414 $this->assertEquals(4.0, $entry->getReadingTime()); 414 $this->assertSame(4.0, $entry->getReadingTime());
415 $this->assertEquals('1.1.1.1', $entry->getDomainName()); 415 $this->assertSame('1.1.1.1', $entry->getDomainName());
416 $this->assertNull($entry->getPublishedAt()); 416 $this->assertNull($entry->getPublishedAt());
417 417
418 $records = $handler->getRecords(); 418 $records = $handler->getRecords();
@@ -488,14 +488,14 @@ class ContentProxyTest extends \PHPUnit_Framework_TestCase
488 ] 488 ]
489 ); 489 );
490 490
491 $this->assertEquals('http://1.1.1.1', $entry->getUrl()); 491 $this->assertSame('http://1.1.1.1', $entry->getUrl());
492 $this->assertEquals('this is my title', $entry->getTitle()); 492 $this->assertSame('this is my title', $entry->getTitle());
493 $this->assertNotContains($escapedString, $entry->getContent()); 493 $this->assertNotContains($escapedString, $entry->getContent());
494 $this->assertEquals('http://3.3.3.3/cover.jpg', $entry->getPreviewPicture()); 494 $this->assertSame('http://3.3.3.3/cover.jpg', $entry->getPreviewPicture());
495 $this->assertEquals('text/html', $entry->getMimetype()); 495 $this->assertSame('text/html', $entry->getMimetype());
496 $this->assertEquals('fr', $entry->getLanguage()); 496 $this->assertSame('fr', $entry->getLanguage());
497 $this->assertEquals('200', $entry->getHttpStatus()); 497 $this->assertSame('200', $entry->getHttpStatus());
498 $this->assertEquals('1.1.1.1', $entry->getDomainName()); 498 $this->assertSame('1.1.1.1', $entry->getDomainName());
499 } 499 }
500 500
501 private function getTaggerMock() 501 private function getTaggerMock()
diff --git a/tests/Wallabag/CoreBundle/Helper/CryptoProxyTest.php b/tests/Wallabag/CoreBundle/Helper/CryptoProxyTest.php
index cede8696..782c29c3 100644
--- a/tests/Wallabag/CoreBundle/Helper/CryptoProxyTest.php
+++ b/tests/Wallabag/CoreBundle/Helper/CryptoProxyTest.php
@@ -2,9 +2,9 @@
2 2
3namespace Tests\Wallabag\CoreBundle\Helper; 3namespace Tests\Wallabag\CoreBundle\Helper;
4 4
5use Psr\Log\NullLogger;
6use Monolog\Logger;
7use Monolog\Handler\TestHandler; 5use Monolog\Handler\TestHandler;
6use Monolog\Logger;
7use Psr\Log\NullLogger;
8use Wallabag\CoreBundle\Helper\CryptoProxy; 8use Wallabag\CoreBundle\Helper\CryptoProxy;
9 9
10class CryptoProxyTest extends \PHPUnit_Framework_TestCase 10class CryptoProxyTest extends \PHPUnit_Framework_TestCase
@@ -14,7 +14,7 @@ class CryptoProxyTest extends \PHPUnit_Framework_TestCase
14 $logHandler = new TestHandler(); 14 $logHandler = new TestHandler();
15 $logger = new Logger('test', [$logHandler]); 15 $logger = new Logger('test', [$logHandler]);
16 16
17 $crypto = new CryptoProxy(sys_get_temp_dir().'/'.uniqid('', true).'.txt', $logger); 17 $crypto = new CryptoProxy(sys_get_temp_dir() . '/' . uniqid('', true) . '.txt', $logger);
18 $crypted = $crypto->crypt('test'); 18 $crypted = $crypto->crypt('test');
19 $decrypted = $crypto->decrypt($crypted); 19 $decrypted = $crypto->decrypt($crypted);
20 20
@@ -27,14 +27,14 @@ class CryptoProxyTest extends \PHPUnit_Framework_TestCase
27 } 27 }
28 28
29 /** 29 /**
30 * @expectedException RuntimeException 30 * @expectedException \RuntimeException
31 * @expectedExceptionMessage Decrypt fail 31 * @expectedExceptionMessage Decrypt fail
32 * 32 *
33 * @return [type] [description] 33 * @return [type] [description]
34 */ 34 */
35 public function testDecryptBadValue() 35 public function testDecryptBadValue()
36 { 36 {
37 $crypto = new CryptoProxy(sys_get_temp_dir().'/'.uniqid('', true).'.txt', new NullLogger()); 37 $crypto = new CryptoProxy(sys_get_temp_dir() . '/' . uniqid('', true) . '.txt', new NullLogger());
38 $crypto->decrypt('badvalue'); 38 $crypto->decrypt('badvalue');
39 } 39 }
40} 40}
diff --git a/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php b/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php
index c02f9658..c61f65d0 100644
--- a/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php
+++ b/tests/Wallabag/CoreBundle/Helper/DownloadImagesTest.php
@@ -2,13 +2,13 @@
2 2
3namespace Tests\Wallabag\CoreBundle\Helper; 3namespace Tests\Wallabag\CoreBundle\Helper;
4 4
5use Wallabag\CoreBundle\Helper\DownloadImages;
6use Monolog\Logger;
7use Monolog\Handler\TestHandler;
8use GuzzleHttp\Client; 5use GuzzleHttp\Client;
9use GuzzleHttp\Subscriber\Mock;
10use GuzzleHttp\Message\Response; 6use GuzzleHttp\Message\Response;
11use GuzzleHttp\Stream\Stream; 7use GuzzleHttp\Stream\Stream;
8use GuzzleHttp\Subscriber\Mock;
9use Monolog\Handler\TestHandler;
10use Monolog\Logger;
11use Wallabag\CoreBundle\Helper\DownloadImages;
12 12
13class DownloadImagesTest extends \PHPUnit_Framework_TestCase 13class DownloadImagesTest extends \PHPUnit_Framework_TestCase
14{ 14{
@@ -34,15 +34,15 @@ class DownloadImagesTest extends \PHPUnit_Framework_TestCase
34 $client = new Client(); 34 $client = new Client();
35 35
36 $mock = new Mock([ 36 $mock = new Mock([
37 new Response(200, ['content-type' => 'image/png'], Stream::factory(file_get_contents(__DIR__.'/../fixtures/unnamed.png'))), 37 new Response(200, ['content-type' => 'image/png'], Stream::factory(file_get_contents(__DIR__ . '/../fixtures/unnamed.png'))),
38 ]); 38 ]);
39 39
40 $client->getEmitter()->attach($mock); 40 $client->getEmitter()->attach($mock);
41 41
42 $logHandler = new TestHandler(); 42 $logHandler = new TestHandler();
43 $logger = new Logger('test', array($logHandler)); 43 $logger = new Logger('test', [$logHandler]);
44 44
45 $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger); 45 $download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger);
46 46
47 $res = $download->processHtml(123, $html, $url); 47 $res = $download->processHtml(123, $html, $url);
48 48
@@ -61,9 +61,9 @@ class DownloadImagesTest extends \PHPUnit_Framework_TestCase
61 $client->getEmitter()->attach($mock); 61 $client->getEmitter()->attach($mock);
62 62
63 $logHandler = new TestHandler(); 63 $logHandler = new TestHandler();
64 $logger = new Logger('test', array($logHandler)); 64 $logger = new Logger('test', [$logHandler]);
65 65
66 $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger); 66 $download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger);
67 $res = $download->processHtml(123, '<div><img src="http://i.imgur.com/T9qgcHc.jpg" /></div>', 'http://imgur.com/gallery/WxtWY'); 67 $res = $download->processHtml(123, '<div><img src="http://i.imgur.com/T9qgcHc.jpg" /></div>', 'http://imgur.com/gallery/WxtWY');
68 68
69 $this->assertContains('http://i.imgur.com/T9qgcHc.jpg', $res, 'Image were not replace because of content-type'); 69 $this->assertContains('http://i.imgur.com/T9qgcHc.jpg', $res, 'Image were not replace because of content-type');
@@ -87,18 +87,18 @@ class DownloadImagesTest extends \PHPUnit_Framework_TestCase
87 $client = new Client(); 87 $client = new Client();
88 88
89 $mock = new Mock([ 89 $mock = new Mock([
90 new Response(200, ['content-type' => $header], Stream::factory(file_get_contents(__DIR__.'/../fixtures/unnamed.png'))), 90 new Response(200, ['content-type' => $header], Stream::factory(file_get_contents(__DIR__ . '/../fixtures/unnamed.png'))),
91 ]); 91 ]);
92 92
93 $client->getEmitter()->attach($mock); 93 $client->getEmitter()->attach($mock);
94 94
95 $logHandler = new TestHandler(); 95 $logHandler = new TestHandler();
96 $logger = new Logger('test', array($logHandler)); 96 $logger = new Logger('test', [$logHandler]);
97 97
98 $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger); 98 $download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger);
99 $res = $download->processSingleImage(123, 'T9qgcHc.jpg', 'http://imgur.com/gallery/WxtWY'); 99 $res = $download->processSingleImage(123, 'T9qgcHc.jpg', 'http://imgur.com/gallery/WxtWY');
100 100
101 $this->assertContains('/assets/images/9/b/9b0ead26/ebe60399.'.$extension, $res); 101 $this->assertContains('/assets/images/9/b/9b0ead26/ebe60399.' . $extension, $res);
102 } 102 }
103 103
104 public function testProcessSingleImageWithBadUrl() 104 public function testProcessSingleImageWithBadUrl()
@@ -112,9 +112,9 @@ class DownloadImagesTest extends \PHPUnit_Framework_TestCase
112 $client->getEmitter()->attach($mock); 112 $client->getEmitter()->attach($mock);
113 113
114 $logHandler = new TestHandler(); 114 $logHandler = new TestHandler();
115 $logger = new Logger('test', array($logHandler)); 115 $logger = new Logger('test', [$logHandler]);
116 116
117 $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger); 117 $download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger);
118 $res = $download->processSingleImage(123, 'T9qgcHc.jpg', 'http://imgur.com/gallery/WxtWY'); 118 $res = $download->processSingleImage(123, 'T9qgcHc.jpg', 'http://imgur.com/gallery/WxtWY');
119 119
120 $this->assertFalse($res, 'Image can not be found, so it will not be replaced'); 120 $this->assertFalse($res, 'Image can not be found, so it will not be replaced');
@@ -131,9 +131,9 @@ class DownloadImagesTest extends \PHPUnit_Framework_TestCase
131 $client->getEmitter()->attach($mock); 131 $client->getEmitter()->attach($mock);
132 132
133 $logHandler = new TestHandler(); 133 $logHandler = new TestHandler();
134 $logger = new Logger('test', array($logHandler)); 134 $logger = new Logger('test', [$logHandler]);
135 135
136 $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger); 136 $download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger);
137 $res = $download->processSingleImage(123, 'http://i.imgur.com/T9qgcHc.jpg', 'http://imgur.com/gallery/WxtWY'); 137 $res = $download->processSingleImage(123, 'http://i.imgur.com/T9qgcHc.jpg', 'http://imgur.com/gallery/WxtWY');
138 138
139 $this->assertFalse($res, 'Image can not be loaded, so it will not be replaced'); 139 $this->assertFalse($res, 'Image can not be loaded, so it will not be replaced');
@@ -144,15 +144,15 @@ class DownloadImagesTest extends \PHPUnit_Framework_TestCase
144 $client = new Client(); 144 $client = new Client();
145 145
146 $mock = new Mock([ 146 $mock = new Mock([
147 new Response(200, ['content-type' => 'image/png'], Stream::factory(file_get_contents(__DIR__.'/../fixtures/unnamed.png'))), 147 new Response(200, ['content-type' => 'image/png'], Stream::factory(file_get_contents(__DIR__ . '/../fixtures/unnamed.png'))),
148 ]); 148 ]);
149 149
150 $client->getEmitter()->attach($mock); 150 $client->getEmitter()->attach($mock);
151 151
152 $logHandler = new TestHandler(); 152 $logHandler = new TestHandler();
153 $logger = new Logger('test', array($logHandler)); 153 $logger = new Logger('test', [$logHandler]);
154 154
155 $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger); 155 $download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger);
156 $res = $download->processSingleImage(123, '/i.imgur.com/T9qgcHc.jpg', 'imgur.com/gallery/WxtWY'); 156 $res = $download->processSingleImage(123, '/i.imgur.com/T9qgcHc.jpg', 'imgur.com/gallery/WxtWY');
157 157
158 $this->assertFalse($res, 'Absolute image can not be determined, so it will not be replaced'); 158 $this->assertFalse($res, 'Absolute image can not be determined, so it will not be replaced');
@@ -163,15 +163,15 @@ class DownloadImagesTest extends \PHPUnit_Framework_TestCase
163 $client = new Client(); 163 $client = new Client();
164 164
165 $mock = new Mock([ 165 $mock = new Mock([
166 new Response(200, ['content-type' => null], Stream::factory(file_get_contents(__DIR__.'/../fixtures/image-no-content-type.jpg'))), 166 new Response(200, ['content-type' => null], Stream::factory(file_get_contents(__DIR__ . '/../fixtures/image-no-content-type.jpg'))),
167 ]); 167 ]);
168 168
169 $client->getEmitter()->attach($mock); 169 $client->getEmitter()->attach($mock);
170 170
171 $logHandler = new TestHandler(); 171 $logHandler = new TestHandler();
172 $logger = new Logger('test', array($logHandler)); 172 $logger = new Logger('test', [$logHandler]);
173 173
174 $download = new DownloadImages($client, sys_get_temp_dir().'/wallabag_test', 'http://wallabag.io/', $logger); 174 $download = new DownloadImages($client, sys_get_temp_dir() . '/wallabag_test', 'http://wallabag.io/', $logger);
175 175
176 $res = $download->processSingleImage( 176 $res = $download->processSingleImage(
177 123, 177 123,
diff --git a/tests/Wallabag/CoreBundle/Helper/RedirectTest.php b/tests/Wallabag/CoreBundle/Helper/RedirectTest.php
index f420d06a..7fd2ea2b 100644
--- a/tests/Wallabag/CoreBundle/Helper/RedirectTest.php
+++ b/tests/Wallabag/CoreBundle/Helper/RedirectTest.php
@@ -2,11 +2,11 @@
2 2
3namespace Tests\Wallabag\CoreBundle\Helper; 3namespace Tests\Wallabag\CoreBundle\Helper;
4 4
5use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
6use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
5use Wallabag\CoreBundle\Entity\Config; 7use Wallabag\CoreBundle\Entity\Config;
6use Wallabag\UserBundle\Entity\User;
7use Wallabag\CoreBundle\Helper\Redirect; 8use Wallabag\CoreBundle\Helper\Redirect;
8use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken; 9use Wallabag\UserBundle\Entity\User;
9use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
10 10
11class RedirectTest extends \PHPUnit_Framework_TestCase 11class RedirectTest extends \PHPUnit_Framework_TestCase
12{ 12{
@@ -56,21 +56,21 @@ class RedirectTest extends \PHPUnit_Framework_TestCase
56 { 56 {
57 $redirectUrl = $this->redirect->to(null, 'fallback'); 57 $redirectUrl = $this->redirect->to(null, 'fallback');
58 58
59 $this->assertEquals('fallback', $redirectUrl); 59 $this->assertSame('fallback', $redirectUrl);
60 } 60 }
61 61
62 public function testRedirectToNullWithoutFallback() 62 public function testRedirectToNullWithoutFallback()
63 { 63 {
64 $redirectUrl = $this->redirect->to(null); 64 $redirectUrl = $this->redirect->to(null);
65 65
66 $this->assertEquals($this->routerMock->generate('homepage'), $redirectUrl); 66 $this->assertSame($this->routerMock->generate('homepage'), $redirectUrl);
67 } 67 }
68 68
69 public function testRedirectToValidUrl() 69 public function testRedirectToValidUrl()
70 { 70 {
71 $redirectUrl = $this->redirect->to('/unread/list'); 71 $redirectUrl = $this->redirect->to('/unread/list');
72 72
73 $this->assertEquals('/unread/list', $redirectUrl); 73 $this->assertSame('/unread/list', $redirectUrl);
74 } 74 }
75 75
76 public function testWithNotLoggedUser() 76 public function testWithNotLoggedUser()
@@ -78,7 +78,7 @@ class RedirectTest extends \PHPUnit_Framework_TestCase
78 $redirect = new Redirect($this->routerMock, new TokenStorage()); 78 $redirect = new Redirect($this->routerMock, new TokenStorage());
79 $redirectUrl = $redirect->to('/unread/list'); 79 $redirectUrl = $redirect->to('/unread/list');
80 80
81 $this->assertEquals('/unread/list', $redirectUrl); 81 $this->assertSame('/unread/list', $redirectUrl);
82 } 82 }
83 83
84 public function testUserForRedirectToHomepage() 84 public function testUserForRedirectToHomepage()
@@ -87,7 +87,7 @@ class RedirectTest extends \PHPUnit_Framework_TestCase
87 87
88 $redirectUrl = $this->redirect->to('/unread/list'); 88 $redirectUrl = $this->redirect->to('/unread/list');
89 89
90 $this->assertEquals($this->routerMock->generate('homepage'), $redirectUrl); 90 $this->assertSame($this->routerMock->generate('homepage'), $redirectUrl);
91 } 91 }
92 92
93 public function testUserForRedirectWithIgnoreActionMarkAsRead() 93 public function testUserForRedirectWithIgnoreActionMarkAsRead()
@@ -96,7 +96,7 @@ class RedirectTest extends \PHPUnit_Framework_TestCase
96 96
97 $redirectUrl = $this->redirect->to('/unread/list', '', true); 97 $redirectUrl = $this->redirect->to('/unread/list', '', true);
98 98
99 $this->assertEquals('/unread/list', $redirectUrl); 99 $this->assertSame('/unread/list', $redirectUrl);
100 } 100 }
101 101
102 public function testUserForRedirectNullWithFallbackWithIgnoreActionMarkAsRead() 102 public function testUserForRedirectNullWithFallbackWithIgnoreActionMarkAsRead()
@@ -105,6 +105,6 @@ class RedirectTest extends \PHPUnit_Framework_TestCase
105 105
106 $redirectUrl = $this->redirect->to(null, 'fallback', true); 106 $redirectUrl = $this->redirect->to(null, 'fallback', true);
107 107
108 $this->assertEquals('fallback', $redirectUrl); 108 $this->assertSame('fallback', $redirectUrl);
109 } 109 }
110} 110}
diff --git a/tests/Wallabag/CoreBundle/Helper/RuleBasedTaggerTest.php b/tests/Wallabag/CoreBundle/Helper/RuleBasedTaggerTest.php
index 1e21f400..c31af680 100644
--- a/tests/Wallabag/CoreBundle/Helper/RuleBasedTaggerTest.php
+++ b/tests/Wallabag/CoreBundle/Helper/RuleBasedTaggerTest.php
@@ -182,7 +182,7 @@ class RuleBasedTaggerTest extends \PHPUnit_Framework_TestCase
182 $tags = $entry->getTags(); 182 $tags = $entry->getTags();
183 183
184 $this->assertCount(1, $tags); 184 $this->assertCount(1, $tags);
185 $this->assertEquals('hey', $tags[0]->getLabel()); 185 $this->assertSame('hey', $tags[0]->getLabel());
186 } 186 }
187 } 187 }
188 188
diff --git a/tests/Wallabag/CoreBundle/Helper/TagsAssignerTest.php b/tests/Wallabag/CoreBundle/Helper/TagsAssignerTest.php
index 6d6d6484..475cd349 100644
--- a/tests/Wallabag/CoreBundle/Helper/TagsAssignerTest.php
+++ b/tests/Wallabag/CoreBundle/Helper/TagsAssignerTest.php
@@ -5,8 +5,8 @@ namespace Tests\Wallabag\CoreBundle\Helper;
5use Wallabag\CoreBundle\Entity\Entry; 5use Wallabag\CoreBundle\Entity\Entry;
6use Wallabag\CoreBundle\Entity\Tag; 6use Wallabag\CoreBundle\Entity\Tag;
7use Wallabag\CoreBundle\Helper\TagsAssigner; 7use Wallabag\CoreBundle\Helper\TagsAssigner;
8use Wallabag\UserBundle\Entity\User;
9use Wallabag\CoreBundle\Repository\TagRepository; 8use Wallabag\CoreBundle\Repository\TagRepository;
9use Wallabag\UserBundle\Entity\User;
10 10
11class TagsAssignerTest extends \PHPUnit_Framework_TestCase 11class TagsAssignerTest extends \PHPUnit_Framework_TestCase
12{ 12{
@@ -20,8 +20,8 @@ class TagsAssignerTest extends \PHPUnit_Framework_TestCase
20 $tagsAssigner->assignTagsToEntry($entry, [' tag1', 'tag2 ']); 20 $tagsAssigner->assignTagsToEntry($entry, [' tag1', 'tag2 ']);
21 21
22 $this->assertCount(2, $entry->getTags()); 22 $this->assertCount(2, $entry->getTags());
23 $this->assertEquals('tag1', $entry->getTags()[0]->getLabel()); 23 $this->assertSame('tag1', $entry->getTags()[0]->getLabel());
24 $this->assertEquals('tag2', $entry->getTags()[1]->getLabel()); 24 $this->assertSame('tag2', $entry->getTags()[1]->getLabel());
25 } 25 }
26 26
27 public function testAssignTagsWithString() 27 public function testAssignTagsWithString()
@@ -34,8 +34,8 @@ class TagsAssignerTest extends \PHPUnit_Framework_TestCase
34 $tagsAssigner->assignTagsToEntry($entry, 'tag1, tag2'); 34 $tagsAssigner->assignTagsToEntry($entry, 'tag1, tag2');
35 35
36 $this->assertCount(2, $entry->getTags()); 36 $this->assertCount(2, $entry->getTags());
37 $this->assertEquals('tag1', $entry->getTags()[0]->getLabel()); 37 $this->assertSame('tag1', $entry->getTags()[0]->getLabel());
38 $this->assertEquals('tag2', $entry->getTags()[1]->getLabel()); 38 $this->assertSame('tag2', $entry->getTags()[1]->getLabel());
39 } 39 }
40 40
41 public function testAssignTagsWithEmptyArray() 41 public function testAssignTagsWithEmptyArray()
@@ -76,8 +76,8 @@ class TagsAssignerTest extends \PHPUnit_Framework_TestCase
76 $tagsAssigner->assignTagsToEntry($entry, 'tag1, tag2'); 76 $tagsAssigner->assignTagsToEntry($entry, 'tag1, tag2');
77 77
78 $this->assertCount(2, $entry->getTags()); 78 $this->assertCount(2, $entry->getTags());
79 $this->assertEquals('tag1', $entry->getTags()[0]->getLabel()); 79 $this->assertSame('tag1', $entry->getTags()[0]->getLabel());
80 $this->assertEquals('tag2', $entry->getTags()[1]->getLabel()); 80 $this->assertSame('tag2', $entry->getTags()[1]->getLabel());
81 } 81 }
82 82
83 public function testAssignTagsNotFlushed() 83 public function testAssignTagsNotFlushed()
@@ -96,7 +96,7 @@ class TagsAssignerTest extends \PHPUnit_Framework_TestCase
96 $tagsAssigner->assignTagsToEntry($entry, 'tag1', [$tagEntity]); 96 $tagsAssigner->assignTagsToEntry($entry, 'tag1', [$tagEntity]);
97 97
98 $this->assertCount(1, $entry->getTags()); 98 $this->assertCount(1, $entry->getTags());
99 $this->assertEquals('tag1', $entry->getTags()[0]->getLabel()); 99 $this->assertSame('tag1', $entry->getTags()[0]->getLabel());
100 } 100 }
101 101
102 private function getTagRepositoryMock() 102 private function getTagRepositoryMock()
diff --git a/tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php b/tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php
index ca8e0d50..74c645ef 100644
--- a/tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php
+++ b/tests/Wallabag/CoreBundle/ParamConverter/UsernameRssTokenConverterTest.php
@@ -212,6 +212,6 @@ class UsernameRssTokenConverterTest extends \PHPUnit_Framework_TestCase
212 212
213 $converter->apply($request, $params); 213 $converter->apply($request, $params);
214 214
215 $this->assertEquals($user, $request->attributes->get('user')); 215 $this->assertSame($user, $request->attributes->get('user'));
216 } 216 }
217} 217}
diff --git a/tests/Wallabag/CoreBundle/Tools/UtilsTest.php b/tests/Wallabag/CoreBundle/Tools/UtilsTest.php
index 435c25ca..4521e485 100644
--- a/tests/Wallabag/CoreBundle/Tools/UtilsTest.php
+++ b/tests/Wallabag/CoreBundle/Tools/UtilsTest.php
@@ -18,7 +18,7 @@ class UtilsTest extends \PHPUnit_Framework_TestCase
18 public function examples() 18 public function examples()
19 { 19 {
20 $examples = []; 20 $examples = [];
21 $finder = (new Finder())->in(__DIR__.'/samples'); 21 $finder = (new Finder())->in(__DIR__ . '/samples');
22 foreach ($finder->getIterator() as $file) { 22 foreach ($finder->getIterator() as $file) {
23 $examples[] = [$file->getContents(), 1]; 23 $examples[] = [$file->getContents(), 1];
24 } 24 }
diff --git a/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php b/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php
index b1c8c946..ceec4b37 100644
--- a/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php
+++ b/tests/Wallabag/CoreBundle/Twig/WallabagExtensionTest.php
@@ -26,8 +26,8 @@ class WallabagExtensionTest extends \PHPUnit_Framework_TestCase
26 26
27 $extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator); 27 $extension = new WallabagExtension($entryRepository, $tagRepository, $tokenStorage, 0, $translator);
28 28
29 $this->assertEquals('lemonde.fr', $extension->removeWww('www.lemonde.fr')); 29 $this->assertSame('lemonde.fr', $extension->removeWww('www.lemonde.fr'));
30 $this->assertEquals('lemonde.fr', $extension->removeWww('lemonde.fr')); 30 $this->assertSame('lemonde.fr', $extension->removeWww('lemonde.fr'));
31 $this->assertEquals('gist.github.com', $extension->removeWww('gist.github.com')); 31 $this->assertSame('gist.github.com', $extension->removeWww('gist.github.com'));
32 } 32 }
33} 33}
diff --git a/tests/Wallabag/CoreBundle/WallabagCoreTestCase.php b/tests/Wallabag/CoreBundle/WallabagCoreTestCase.php
index eec6939d..1eda5199 100644
--- a/tests/Wallabag/CoreBundle/WallabagCoreTestCase.php
+++ b/tests/Wallabag/CoreBundle/WallabagCoreTestCase.php
@@ -18,11 +18,6 @@ abstract class WallabagCoreTestCase extends WebTestCase
18 */ 18 */
19 private $client = null; 19 private $client = null;
20 20
21 public function getClient()
22 {
23 return $this->client;
24 }
25
26 public function setUp() 21 public function setUp()
27 { 22 {
28 parent::setUp(); 23 parent::setUp();
@@ -30,6 +25,11 @@ abstract class WallabagCoreTestCase extends WebTestCase
30 $this->client = static::createClient(); 25 $this->client = static::createClient();
31 } 26 }
32 27
28 public function getClient()
29 {
30 return $this->client;
31 }
32
33 public function resetDatabase(Client $client) 33 public function resetDatabase(Client $client)
34 { 34 {
35 $application = new Application($client->getKernel()); 35 $application = new Application($client->getKernel());
@@ -83,10 +83,10 @@ abstract class WallabagCoreTestCase extends WebTestCase
83 $loginManager = $container->get('fos_user.security.login_manager'); 83 $loginManager = $container->get('fos_user.security.login_manager');
84 $firewallName = $container->getParameter('fos_user.firewall_name'); 84 $firewallName = $container->getParameter('fos_user.firewall_name');
85 85
86 $user = $userManager->findUserBy(array('username' => $username)); 86 $user = $userManager->findUserBy(['username' => $username]);
87 $loginManager->logInUser($firewallName, $user); 87 $loginManager->logInUser($firewallName, $user);
88 88
89 $session->set('_security_'.$firewallName, serialize($container->get('security.token_storage')->getToken())); 89 $session->set('_security_' . $firewallName, serialize($container->get('security.token_storage')->getToken()));
90 $session->save(); 90 $session->save();
91 91
92 $cookie = new Cookie($session->getName(), $session->getId()); 92 $cookie = new Cookie($session->getName(), $session->getId());
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}
diff --git a/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php b/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php
index b46256a6..adc2cf09 100644
--- a/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php
+++ b/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php
@@ -12,7 +12,7 @@ class ManageControllerTest extends WallabagCoreTestCase
12 12
13 $client->request('GET', '/users/list'); 13 $client->request('GET', '/users/list');
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,16 +23,16 @@ class ManageControllerTest extends WallabagCoreTestCase
23 23
24 // Create a new user in the database 24 // Create a new user in the database
25 $crawler = $client->request('GET', '/users/list'); 25 $crawler = $client->request('GET', '/users/list');
26 $this->assertEquals(200, $client->getResponse()->getStatusCode(), 'Unexpected HTTP status code for GET /users/'); 26 $this->assertSame(200, $client->getResponse()->getStatusCode(), 'Unexpected HTTP status code for GET /users/');
27 $crawler = $client->click($crawler->selectLink('user.list.create_new_one')->link()); 27 $crawler = $client->click($crawler->selectLink('user.list.create_new_one')->link());
28 28
29 // Fill in the form and submit it 29 // Fill in the form and submit it
30 $form = $crawler->selectButton('user.form.save')->form(array( 30 $form = $crawler->selectButton('user.form.save')->form([
31 'new_user[username]' => 'test_user', 31 'new_user[username]' => 'test_user',
32 'new_user[email]' => 'test@test.io', 32 'new_user[email]' => 'test@test.io',
33 'new_user[plainPassword][first]' => 'testtest', 33 'new_user[plainPassword][first]' => 'testtest',
34 'new_user[plainPassword][second]' => 'testtest', 34 'new_user[plainPassword][second]' => 'testtest',
35 )); 35 ]);
36 36
37 $client->submit($form); 37 $client->submit($form);
38 $client->followRedirect(); 38 $client->followRedirect();
@@ -44,12 +44,12 @@ class ManageControllerTest extends WallabagCoreTestCase
44 // Edit the user 44 // Edit the user
45 $crawler = $client->click($crawler->selectLink('user.list.edit_action')->last()->link()); 45 $crawler = $client->click($crawler->selectLink('user.list.edit_action')->last()->link());
46 46
47 $form = $crawler->selectButton('user.form.save')->form(array( 47 $form = $crawler->selectButton('user.form.save')->form([
48 'user[name]' => 'Foo User', 48 'user[name]' => 'Foo User',
49 'user[username]' => 'test_user', 49 'user[username]' => 'test_user',
50 'user[email]' => 'test@test.io', 50 'user[email]' => 'test@test.io',
51 'user[enabled]' => true, 51 'user[enabled]' => true,
52 )); 52 ]);
53 53
54 $client->submit($form); 54 $client->submit($form);
55 $crawler = $client->followRedirect(); 55 $crawler = $client->followRedirect();
@@ -73,10 +73,10 @@ class ManageControllerTest extends WallabagCoreTestCase
73 $this->logInAs('admin'); 73 $this->logInAs('admin');
74 $client = $this->getClient(); 74 $client = $this->getClient();
75 75
76 $crawler = $client->request('GET', '/users/'.$this->getLoggedInUserId().'/edit'); 76 $crawler = $client->request('GET', '/users/' . $this->getLoggedInUserId() . '/edit');
77 $disabled = $crawler->selectButton('user.form.delete')->extract('disabled'); 77 $disabled = $crawler->selectButton('user.form.delete')->extract('disabled');
78 78
79 $this->assertEquals('disabled', $disabled[0]); 79 $this->assertSame('disabled', $disabled[0]);
80 } 80 }
81 81
82 public function testUserSearch() 82 public function testUserSearch()
diff --git a/tests/Wallabag/UserBundle/EventListener/AuthenticationFailureListenerTest.php b/tests/Wallabag/UserBundle/EventListener/AuthenticationFailureListenerTest.php
index 6191ea13..9e33cdca 100644
--- a/tests/Wallabag/UserBundle/EventListener/AuthenticationFailureListenerTest.php
+++ b/tests/Wallabag/UserBundle/EventListener/AuthenticationFailureListenerTest.php
@@ -2,14 +2,14 @@
2 2
3namespace Tests\Wallabag\UserBundle\EventListener; 3namespace Tests\Wallabag\UserBundle\EventListener;
4 4
5use Monolog\Handler\TestHandler;
6use Monolog\Logger;
5use Symfony\Component\EventDispatcher\EventDispatcher; 7use Symfony\Component\EventDispatcher\EventDispatcher;
6use Symfony\Component\HttpFoundation\Request; 8use Symfony\Component\HttpFoundation\Request;
7use Wallabag\UserBundle\EventListener\AuthenticationFailureListener;
8use Monolog\Logger;
9use Monolog\Handler\TestHandler;
10use Symfony\Component\HttpFoundation\RequestStack; 9use Symfony\Component\HttpFoundation\RequestStack;
11use Symfony\Component\Security\Core\AuthenticationEvents; 10use Symfony\Component\Security\Core\AuthenticationEvents;
12use Symfony\Component\Security\Core\Event\AuthenticationFailureEvent; 11use Symfony\Component\Security\Core\Event\AuthenticationFailureEvent;
12use Wallabag\UserBundle\EventListener\AuthenticationFailureListener;
13 13
14class AuthenticationFailureListenerTest extends \PHPUnit_Framework_TestCase 14class AuthenticationFailureListenerTest extends \PHPUnit_Framework_TestCase
15{ 15{
diff --git a/tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php b/tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php
index 01796ded..e5a145b8 100644
--- a/tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php
+++ b/tests/Wallabag/UserBundle/EventListener/CreateConfigListenerTest.php
@@ -8,8 +8,8 @@ use Symfony\Component\EventDispatcher\EventDispatcher;
8use Symfony\Component\HttpFoundation\Request; 8use Symfony\Component\HttpFoundation\Request;
9use Symfony\Component\HttpFoundation\Response; 9use Symfony\Component\HttpFoundation\Response;
10use Wallabag\CoreBundle\Entity\Config; 10use Wallabag\CoreBundle\Entity\Config;
11use Wallabag\UserBundle\EventListener\CreateConfigListener;
12use Wallabag\UserBundle\Entity\User; 11use Wallabag\UserBundle\Entity\User;
12use Wallabag\UserBundle\EventListener\CreateConfigListener;
13 13
14class CreateConfigListenerTest extends \PHPUnit_Framework_TestCase 14class CreateConfigListenerTest extends \PHPUnit_Framework_TestCase
15{ 15{
diff --git a/tests/Wallabag/UserBundle/Mailer/AuthCodeMailerTest.php b/tests/Wallabag/UserBundle/Mailer/AuthCodeMailerTest.php
index 21412da6..7381ccf1 100644
--- a/tests/Wallabag/UserBundle/Mailer/AuthCodeMailerTest.php
+++ b/tests/Wallabag/UserBundle/Mailer/AuthCodeMailerTest.php
@@ -68,8 +68,8 @@ TWIG;
68 68
69 $msg = $this->spool->getMessages()[0]; 69 $msg = $this->spool->getMessages()[0];
70 $this->assertArrayHasKey('test@wallabag.io', $msg->getTo()); 70 $this->assertArrayHasKey('test@wallabag.io', $msg->getTo());
71 $this->assertEquals(['nobody@test.io' => 'wallabag test'], $msg->getFrom()); 71 $this->assertSame(['nobody@test.io' => 'wallabag test'], $msg->getFrom());
72 $this->assertEquals('subject', $msg->getSubject()); 72 $this->assertSame('subject', $msg->getSubject());
73 $this->assertContains('text body http://0.0.0.0/support', $msg->toString()); 73 $this->assertContains('text body http://0.0.0.0/support', $msg->toString());
74 $this->assertContains('html body 666666', $msg->toString()); 74 $this->assertContains('html body 666666', $msg->toString());
75 } 75 }