aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-07-20 12:02:02 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-07-20 12:02:02 +0200
commit0faeabefa7faedb3a6a3675a5e49e947554adae9 (patch)
treee51ae7db64408b159b2dfa13bfa9e01530223dc9
parent2bb138ef6df2d1a608b42907185b274fb87f4513 (diff)
parent317fc6e684356b645ea1327c2631c7d5fc193ddd (diff)
downloadwallabag-0faeabefa7faedb3a6a3675a5e49e947554adae9.tar.gz
wallabag-0faeabefa7faedb3a6a3675a5e49e947554adae9.tar.zst
wallabag-0faeabefa7faedb3a6a3675a5e49e947554adae9.zip
Merge remote-tracking branch 'origin/master' into 2.1
-rw-r--r--.gitignore3
-rw-r--r--.travis.yml1
-rw-r--r--README.md2
-rw-r--r--app/config/config.yml41
-rw-r--r--app/config/config_dev.yml13
-rw-r--r--app/config/config_prod.yml10
-rw-r--r--app/config/routing.yml4
-rw-r--r--app/config/routing_dev.yml6
-rw-r--r--app/config/security.yml16
l---------bin/doctrine1
l---------bin/doctrine-dbal1
l---------bin/doctrine-migrations1
l---------bin/doctrine.php1
l---------bin/php-cs-fixer1
l---------bin/security-checker1
-rwxr-xr-xbin/symfony_requirements2
-rw-r--r--composer.json2
-rw-r--r--docs/en/user/installation.rst2
-rw-r--r--docs/fr/user/installation.rst2
-rw-r--r--src/Wallabag/CoreBundle/Resources/translations/messages.es.yml2
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig4
-rw-r--r--tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php2
-rw-r--r--tests/Wallabag/CoreBundle/Controller/TagControllerTest.php6
-rw-r--r--tests/Wallabag/CoreBundle/WallabagCoreTestCase.php32
-rw-r--r--tests/Wallabag/ImportBundle/Controller/PocketControllerTest.php57
-rw-r--r--tests/Wallabag/ImportBundle/fixtures/unnamed.pngbin0 -> 3688 bytes
26 files changed, 149 insertions, 64 deletions
diff --git a/.gitignore b/.gitignore
index 5eca0e6b..fb51034e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,6 +10,9 @@
10/var/sessions/* 10/var/sessions/*
11!var/sessions/.gitkeep 11!var/sessions/.gitkeep
12!var/SymfonyRequirements.php 12!var/SymfonyRequirements.php
13/bin/*
14!/bin/console
15!/bin/symfony_requirements
13 16
14# Parameters 17# Parameters
15/app/config/parameters.yml 18/app/config/parameters.yml
diff --git a/.travis.yml b/.travis.yml
index 17c3abaf..dd8815c1 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -23,6 +23,7 @@ php:
23 - 5.5 23 - 5.5
24 - 5.6 24 - 5.6
25 - 7.0 25 - 7.0
26 - nightly
26 - hhvm 27 - hhvm
27 28
28node_js: 29node_js:
diff --git a/README.md b/README.md
index 2a7b54bf..0d87d7bb 100644
--- a/README.md
+++ b/README.md
@@ -10,7 +10,7 @@ More informations on our website: [wallabag.org](https://wallabag.org)
10 10
11# Install wallabag 11# Install wallabag
12 12
13If you don't have it yet, please [install composer](https://getcomposer.org/download/). 13If you don't have it yet, please [install composer](https://getcomposer.org/download/) or be sure to use Composer 1.2 (`composer selfupdate` can help you about that).
14Then you can install wallabag by executing the following commands: 14Then you can install wallabag by executing the following commands:
15 15
16``` 16```
diff --git a/app/config/config.yml b/app/config/config.yml
index 29847820..a1517e97 100644
--- a/app/config/config.yml
+++ b/app/config/config.yml
@@ -5,25 +5,27 @@ imports:
5 5
6framework: 6framework:
7 #esi: ~ 7 #esi: ~
8 translator: { fallback: "%locale%" } 8 translator:
9 secret: "%secret%" 9 enabled: true
10 fallback: "%locale%"
11 secret: "%secret%"
10 router: 12 router:
11 resource: "%kernel.root_dir%/config/routing.yml" 13 resource: "%kernel.root_dir%/config/routing.yml"
12 strict_requirements: ~ 14 strict_requirements: ~
13 form: ~ 15 form: ~
14 csrf_protection: ~ 16 csrf_protection: ~
15 validation: { enable_annotations: true } 17 validation:
18 enable_annotations: true
16 templating: 19 templating:
17 engines: ['twig'] 20 engines: ['twig']
18 #assets_version: SomeVersionScheme 21 default_locale: "%locale%"
19 default_locale: "%locale%" 22 trusted_hosts: ~
20 trusted_hosts: ~
21 trusted_proxies: ~ 23 trusted_proxies: ~
22 session: 24 session:
23 # handler_id set to null will use default session handler from php.ini 25 # handler_id set to null will use default session handler from php.ini
24 handler_id: session.handler.native_file 26 handler_id: session.handler.native_file
25 save_path: "%kernel.root_dir%/../var/sessions/%kernel.environment%" 27 save_path: "%kernel.root_dir%/../var/sessions/%kernel.environment%"
26 fragments: ~ 28 fragments: ~
27 http_method_override: true 29 http_method_override: true
28 assets: ~ 30 assets: ~
29 31
@@ -54,7 +56,7 @@ wallabag_import:
54 56
55# Twig Configuration 57# Twig Configuration
56twig: 58twig:
57 debug: "%kernel.debug%" 59 debug: "%kernel.debug%"
58 strict_variables: "%kernel.debug%" 60 strict_variables: "%kernel.debug%"
59 form_themes: 61 form_themes:
60 - "LexikFormFilterBundle:Form:form_div_layout.html.twig" 62 - "LexikFormFilterBundle:Form:form_div_layout.html.twig"
@@ -62,14 +64,14 @@ twig:
62# Doctrine Configuration 64# Doctrine Configuration
63doctrine: 65doctrine:
64 dbal: 66 dbal:
65 driver: "%database_driver%" 67 driver: "%database_driver%"
66 host: "%database_host%" 68 host: "%database_host%"
67 port: "%database_port%" 69 port: "%database_port%"
68 dbname: "%database_name%" 70 dbname: "%database_name%"
69 user: "%database_user%" 71 user: "%database_user%"
70 password: "%database_password%" 72 password: "%database_password%"
71 charset: UTF8 73 charset: UTF8
72 path: "%database_path%" 74 path: "%database_path%"
73 server_version: 5.6 75 server_version: 5.6
74 76
75 orm: 77 orm:
@@ -95,10 +97,11 @@ doctrine_migrations:
95# Swiftmailer Configuration 97# Swiftmailer Configuration
96swiftmailer: 98swiftmailer:
97 transport: "%mailer_transport%" 99 transport: "%mailer_transport%"
98 host: "%mailer_host%" 100 host: "%mailer_host%"
99 username: "%mailer_user%" 101 username: "%mailer_user%"
100 password: "%mailer_password%" 102 password: "%mailer_password%"
101 spool: { type: memory } 103 spool:
104 type: memory
102 105
103fos_rest: 106fos_rest:
104 param_fetcher_listener: true 107 param_fetcher_listener: true
@@ -160,7 +163,7 @@ liip_theme:
160 163
161fos_user: 164fos_user:
162 db_driver: orm 165 db_driver: orm
163 firewall_name: main 166 firewall_name: secured_area
164 user_class: Wallabag\UserBundle\Entity\User 167 user_class: Wallabag\UserBundle\Entity\User
165 registration: 168 registration:
166 confirmation: 169 confirmation:
diff --git a/app/config/config_dev.yml b/app/config/config_dev.yml
index f3030ff1..77840682 100644
--- a/app/config/config_dev.yml
+++ b/app/config/config_dev.yml
@@ -5,7 +5,8 @@ framework:
5 router: 5 router:
6 resource: "%kernel.root_dir%/config/routing_dev.yml" 6 resource: "%kernel.root_dir%/config/routing_dev.yml"
7 strict_requirements: true 7 strict_requirements: true
8 profiler: { only_exceptions: false } 8 profiler:
9 only_exceptions: false
9 10
10web_profiler: 11web_profiler:
11 toolbar: true 12 toolbar: true
@@ -14,19 +15,19 @@ web_profiler:
14monolog: 15monolog:
15 handlers: 16 handlers:
16 main: 17 main:
17 type: stream 18 type: stream
18 path: "%kernel.logs_dir%/%kernel.environment%.log" 19 path: "%kernel.logs_dir%/%kernel.environment%.log"
19 level: debug 20 level: debug
20 channels: ['!event'] 21 channels: ['!event']
21 console: 22 console:
22 type: console 23 type: console
23 bubble: false 24 bubble: false
24 verbosity_levels: 25 verbosity_levels:
25 VERBOSITY_VERBOSE: INFO 26 VERBOSITY_VERBOSE: INFO
26 VERBOSITY_VERY_VERBOSE: DEBUG 27 VERBOSITY_VERY_VERBOSE: DEBUG
27 channels: ['!event', '!doctrine'] 28 channels: ['!event', '!doctrine']
28 console_very_verbose: 29 console_very_verbose:
29 type: console 30 type: console
30 bubble: false 31 bubble: false
31 verbosity_levels: 32 verbosity_levels:
32 VERBOSITY_VERBOSE: NOTICE 33 VERBOSITY_VERBOSE: NOTICE
diff --git a/app/config/config_prod.yml b/app/config/config_prod.yml
index 65b040cc..5a4dd69e 100644
--- a/app/config/config_prod.yml
+++ b/app/config/config_prod.yml
@@ -14,12 +14,12 @@ imports:
14monolog: 14monolog:
15 handlers: 15 handlers:
16 main: 16 main:
17 type: fingers_crossed 17 type: fingers_crossed
18 action_level: error 18 action_level: error
19 handler: nested 19 handler: nested
20 nested: 20 nested:
21 type: stream 21 type: stream
22 path: "%kernel.logs_dir%/%kernel.environment%.log" 22 path: "%kernel.logs_dir%/%kernel.environment%.log"
23 level: debug 23 level: debug
24 console: 24 console:
25 type: console 25 type: console
diff --git a/app/config/routing.yml b/app/config/routing.yml
index 6a6aa6ac..40cc7165 100644
--- a/app/config/routing.yml
+++ b/app/config/routing.yml
@@ -4,8 +4,8 @@ wallabag_annotation:
4 4
5wallabag_import: 5wallabag_import:
6 resource: "@WallabagImportBundle/Controller/" 6 resource: "@WallabagImportBundle/Controller/"
7 type: annotation 7 type: annotation
8 prefix: /import 8 prefix: /import
9 9
10wallabag_api: 10wallabag_api:
11 resource: "@WallabagApiBundle/Resources/config/routing.yml" 11 resource: "@WallabagApiBundle/Resources/config/routing.yml"
diff --git a/app/config/routing_dev.yml b/app/config/routing_dev.yml
index 404f6a3b..95c1b026 100644
--- a/app/config/routing_dev.yml
+++ b/app/config/routing_dev.yml
@@ -1,14 +1,14 @@
1_wdt: 1_wdt:
2 resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml" 2 resource: "@WebProfilerBundle/Resources/config/routing/wdt.xml"
3 prefix: /_wdt 3 prefix: /_wdt
4 4
5_profiler: 5_profiler:
6 resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml" 6 resource: "@WebProfilerBundle/Resources/config/routing/profiler.xml"
7 prefix: /_profiler 7 prefix: /_profiler
8 8
9_errors: 9_errors:
10 resource: "@TwigBundle/Resources/config/routing/errors.xml" 10 resource: "@TwigBundle/Resources/config/routing/errors.xml"
11 prefix: /_error 11 prefix: /_error
12 12
13_main: 13_main:
14 resource: routing.yml 14 resource: routing.yml
diff --git a/app/config/security.yml b/app/config/security.yml
index 0748c06c..e24e03df 100644
--- a/app/config/security.yml
+++ b/app/config/security.yml
@@ -3,12 +3,14 @@ security:
3 FOS\UserBundle\Model\UserInterface: sha512 3 FOS\UserBundle\Model\UserInterface: sha512
4 4
5 role_hierarchy: 5 role_hierarchy:
6 ROLE_ADMIN: ROLE_USER 6 ROLE_ADMIN: ROLE_USER
7 ROLE_SUPER_ADMIN: [ ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH ] 7 ROLE_SUPER_ADMIN: [ ROLE_USER, ROLE_ADMIN, ROLE_ALLOWED_TO_SWITCH ]
8 8
9 providers: 9 providers:
10 administrators: 10 administrators:
11 entity: { class: WallabagUserBundle:User, property: username } 11 entity:
12 class: WallabagUserBundle:User
13 property: username
12 fos_userbundle: 14 fos_userbundle:
13 id: fos_user.user_provider.username 15 id: fos_user.user_provider.username
14 16
@@ -31,7 +33,7 @@ security:
31 anonymous: true 33 anonymous: true
32 34
33 login_firewall: 35 login_firewall:
34 pattern: ^/login$ 36 pattern: ^/login$
35 anonymous: ~ 37 anonymous: ~
36 38
37 secured_area: 39 secured_area:
@@ -40,12 +42,12 @@ security:
40 provider: fos_userbundle 42 provider: fos_userbundle
41 csrf_token_generator: security.csrf.token_manager 43 csrf_token_generator: security.csrf.token_manager
42 44
43 anonymous: true 45 anonymous: true
44 remember_me: 46 remember_me:
45 secret: "%secret%" 47 secret: "%secret%"
46 lifetime: 31536000 48 lifetime: 31536000
47 path: / 49 path: /
48 domain: ~ 50 domain: ~
49 51
50 logout: 52 logout:
51 path: /logout 53 path: /logout
diff --git a/bin/doctrine b/bin/doctrine
deleted file mode 120000
index 0f72e36f..00000000
--- a/bin/doctrine
+++ /dev/null
@@ -1 +0,0 @@
1../vendor/doctrine/orm/bin/doctrine \ No newline at end of file
diff --git a/bin/doctrine-dbal b/bin/doctrine-dbal
deleted file mode 120000
index 110e93c5..00000000
--- a/bin/doctrine-dbal
+++ /dev/null
@@ -1 +0,0 @@
1../vendor/doctrine/dbal/bin/doctrine-dbal \ No newline at end of file
diff --git a/bin/doctrine-migrations b/bin/doctrine-migrations
deleted file mode 120000
index 7184da71..00000000
--- a/bin/doctrine-migrations
+++ /dev/null
@@ -1 +0,0 @@
1../vendor/doctrine/migrations/bin/doctrine-migrations \ No newline at end of file
diff --git a/bin/doctrine.php b/bin/doctrine.php
deleted file mode 120000
index b22b74da..00000000
--- a/bin/doctrine.php
+++ /dev/null
@@ -1 +0,0 @@
1../vendor/doctrine/orm/bin/doctrine.php \ No newline at end of file
diff --git a/bin/php-cs-fixer b/bin/php-cs-fixer
deleted file mode 120000
index 4d771203..00000000
--- a/bin/php-cs-fixer
+++ /dev/null
@@ -1 +0,0 @@
1../vendor/friendsofphp/php-cs-fixer/php-cs-fixer \ No newline at end of file
diff --git a/bin/security-checker b/bin/security-checker
deleted file mode 120000
index 85f6e8ed..00000000
--- a/bin/security-checker
+++ /dev/null
@@ -1 +0,0 @@
1../vendor/sensiolabs/security-checker/security-checker \ No newline at end of file
diff --git a/bin/symfony_requirements b/bin/symfony_requirements
index 7cd559a4..8825a964 100755
--- a/bin/symfony_requirements
+++ b/bin/symfony_requirements
@@ -13,7 +13,7 @@ echo '> PHP is using the following php.ini file:'.PHP_EOL;
13if ($iniPath) { 13if ($iniPath) {
14 echo_style('green', ' '.$iniPath); 14 echo_style('green', ' '.$iniPath);
15} else { 15} else {
16 echo_style('warning', ' WARNING: No configuration file (php.ini) used by PHP!'); 16 echo_style('yellow', ' WARNING: No configuration file (php.ini) used by PHP!');
17} 17}
18 18
19echo PHP_EOL.PHP_EOL; 19echo PHP_EOL.PHP_EOL;
diff --git a/composer.json b/composer.json
index 7beb9bd9..38ccec81 100644
--- a/composer.json
+++ b/composer.json
@@ -73,7 +73,7 @@
73 "grandt/phpepub": "~4.0", 73 "grandt/phpepub": "~4.0",
74 "wallabag/php-mobi": "~1.0.0", 74 "wallabag/php-mobi": "~1.0.0",
75 "kphoen/rulerz-bundle": "~0.10", 75 "kphoen/rulerz-bundle": "~0.10",
76 "guzzlehttp/guzzle": "^5.2.0", 76 "guzzlehttp/guzzle": "^5.3.1",
77 "doctrine/doctrine-migrations-bundle": "^1.0", 77 "doctrine/doctrine-migrations-bundle": "^1.0",
78 "paragonie/random_compat": "~1.0", 78 "paragonie/random_compat": "~1.0",
79 "craue/config-bundle": "~1.4", 79 "craue/config-bundle": "~1.4",
diff --git a/docs/en/user/installation.rst b/docs/en/user/installation.rst
index 58d9fb7e..bd3095e0 100644
--- a/docs/en/user/installation.rst
+++ b/docs/en/user/installation.rst
@@ -37,7 +37,7 @@ Installation
37On a dedicated web server (recommended way) 37On a dedicated web server (recommended way)
38~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 38~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
39 39
40wallabag uses a large number of libraries in order to function. These libraries must be installed with a tool called Composer. You need to install it if you have not already done so. 40wallabag uses a large number of libraries in order to function. These libraries must be installed with a tool called Composer. You need to install it if you have not already done so and be sure to use the 1.2 version (if you already have Composer, run a ``composer selfupdate``).
41 41
42Install Composer: 42Install Composer:
43 43
diff --git a/docs/fr/user/installation.rst b/docs/fr/user/installation.rst
index b1136c12..0693fc5d 100644
--- a/docs/fr/user/installation.rst
+++ b/docs/fr/user/installation.rst
@@ -35,7 +35,7 @@ Installation
35Sur un serveur dédié (méthode conseillée) 35Sur un serveur dédié (méthode conseillée)
36~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 36~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
37 37
38wallabag utilise un grand nombre de bibliothèques pour fonctionner. Ces bibliothèques doivent être installées à l'aide d'un outil nommé Composer. Vous devez l'installer si ce n'est déjà fait. 38wallabag utilise un grand nombre de bibliothèques pour fonctionner. Ces bibliothèques doivent être installées à l'aide d'un outil nommé Composer. Vous devez l'installer si ce n'est déjà fait et vous assurer que vous utilisez bien la version 1.2 (si vous avez déjà Composer, faite un ``composer selfupdate``).
39 39
40Installation de Composer : 40Installation de Composer :
41 41
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
index f3fa44f1..5a755e6c 100644
--- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
+++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml
@@ -135,7 +135,7 @@ config:
135 135
136entry: 136entry:
137 page_titles: 137 page_titles:
138 unread: 'Artúclos no leídos' 138 unread: 'Artículos no leídos'
139 starred: 'Artículos favoritos' 139 starred: 'Artículos favoritos'
140 archived: 'Artículos archivados' 140 archived: 'Artículos archivados'
141 filtered: 'Artículos filtrados' 141 filtered: 'Artículos filtrados'
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig
index ed0ad2f6..56382096 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/material/layout.html.twig
@@ -129,10 +129,10 @@
129 <a target="_blank" class="grey-text text-lighten-3" href="https://itunes.apple.com/app/id828331015" title="iOS"> 129 <a target="_blank" class="grey-text text-lighten-3" href="https://itunes.apple.com/app/id828331015" title="iOS">
130 <span class="icon-apple"></span> 130 <span class="icon-apple"></span>
131 </a> 131 </a>
132 <a target="_blank" class="grey-text text-lighten-3" href="https://addons.mozilla.org/firefox/addon/wallabag/" title="Firefox"> 132 <a target="_blank" class="grey-text text-lighten-3" href="https://addons.mozilla.org/firefox/addon/wallabag-v2/" title="Firefox">
133 <span class="icon-firefox"></span> 133 <span class="icon-firefox"></span>
134 </a> 134 </a>
135 <a target="_blank" class="grey-text text-lighten-3" href="https://chrome.google.com/webstore/detail/wallabagit/peehlcgckcnclnjlndmoddifcicdnabm" title="Chrome"> 135 <a target="_blank" class="grey-text text-lighten-3" href="https://chrome.google.com/webstore/detail/wallabagger/gbmgphmejlcoihgedabhgjdkcahacjlj" title="Chrome">
136 <span class="icon-chrome"></span> 136 <span class="icon-chrome"></span>
137 </a> 137 </a>
138 </p> 138 </p>
diff --git a/tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php b/tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php
index f503ff4b..03355f5a 100644
--- a/tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/SecurityControllerTest.php
@@ -36,7 +36,7 @@ class SecurityControllerTest extends WallabagCoreTestCase
36 $em->persist($user); 36 $em->persist($user);
37 $em->flush(); 37 $em->flush();
38 38
39 $this->logInAs('admin'); 39 $this->logInAsUsingHttp('admin');
40 $crawler = $client->request('GET', '/config'); 40 $crawler = $client->request('GET', '/config');
41 $this->assertContains('scheb_two_factor.trusted', $crawler->filter('body')->extract(['_text'])[0]); 41 $this->assertContains('scheb_two_factor.trusted', $crawler->filter('body')->extract(['_text'])[0]);
42 42
diff --git a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
index a019d36c..58450e5f 100644
--- a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
@@ -39,6 +39,12 @@ class TagControllerTest extends WallabagCoreTestCase
39 $client->submit($form, $data); 39 $client->submit($form, $data);
40 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 40 $this->assertEquals(302, $client->getResponse()->getStatusCode());
41 41
42 // be sure to reload the entry
43 $entry = $client->getContainer()
44 ->get('doctrine.orm.entity_manager')
45 ->getRepository('WallabagCoreBundle:Entry')
46 ->findOneByUsernameAndNotArchived('admin');
47
42 $this->assertEquals(1, count($entry->getTags())); 48 $this->assertEquals(1, count($entry->getTags()));
43 49
44 # tag already exists and already assigned 50 # tag already exists and already assigned
diff --git a/tests/Wallabag/CoreBundle/WallabagCoreTestCase.php b/tests/Wallabag/CoreBundle/WallabagCoreTestCase.php
index c69e8330..c0055888 100644
--- a/tests/Wallabag/CoreBundle/WallabagCoreTestCase.php
+++ b/tests/Wallabag/CoreBundle/WallabagCoreTestCase.php
@@ -3,6 +3,7 @@
3namespace Tests\Wallabag\CoreBundle; 3namespace Tests\Wallabag\CoreBundle;
4 4
5use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; 5use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
6use Symfony\Component\BrowserKit\Cookie;
6 7
7abstract class WallabagCoreTestCase extends WebTestCase 8abstract class WallabagCoreTestCase extends WebTestCase
8{ 9{
@@ -20,8 +21,39 @@ abstract class WallabagCoreTestCase extends WebTestCase
20 $this->client = static::createClient(); 21 $this->client = static::createClient();
21 } 22 }
22 23
24 /**
25 * Login a user without making a HTTP request.
26 * If we make a HTTP request we lose ability to mock service in the container.
27 *
28 * @param string $username User to log in
29 */
23 public function logInAs($username) 30 public function logInAs($username)
24 { 31 {
32 $container = $this->client->getContainer();
33 $session = $container->get('session');
34
35 $userManager = $container->get('fos_user.user_manager');
36 $loginManager = $container->get('fos_user.security.login_manager');
37 $firewallName = $container->getParameter('fos_user.firewall_name');
38
39 $user = $userManager->findUserBy(array('username' => $username));
40 $loginManager->loginUser($firewallName, $user);
41
42 $session->set('_security_'.$firewallName, serialize($container->get('security.token_storage')->getToken()));
43 $session->save();
44
45 $cookie = new Cookie($session->getName(), $session->getId());
46 $this->client->getCookieJar()->set($cookie);
47 }
48
49 /**
50 * Instead of `logInAs` this method use a HTTP request to log in the user.
51 * Could be better for some tests.
52 *
53 * @param string $username User to log in
54 */
55 public function logInAsUsingHttp($username)
56 {
25 $crawler = $this->client->request('GET', '/login'); 57 $crawler = $this->client->request('GET', '/login');
26 $form = $crawler->filter('button[type=submit]')->form(); 58 $form = $crawler->filter('button[type=submit]')->form();
27 $data = [ 59 $data = [
diff --git a/tests/Wallabag/ImportBundle/Controller/PocketControllerTest.php b/tests/Wallabag/ImportBundle/Controller/PocketControllerTest.php
index 6aaf1b57..e0e61df8 100644
--- a/tests/Wallabag/ImportBundle/Controller/PocketControllerTest.php
+++ b/tests/Wallabag/ImportBundle/Controller/PocketControllerTest.php
@@ -22,15 +22,13 @@ class PocketControllerTest extends WallabagCoreTestCase
22 $this->logInAs('admin'); 22 $this->logInAs('admin');
23 $client = $this->getClient(); 23 $client = $this->getClient();
24 24
25 $crawler = $client->request('GET', '/import/pocket/auth'); 25 $client->request('GET', '/import/pocket/auth');
26 26
27 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 27 $this->assertEquals(302, $client->getResponse()->getStatusCode());
28 } 28 }
29 29
30 public function testImportPocketAuth() 30 public function testImportPocketAuth()
31 { 31 {
32 $this->markTestSkipped('PocketImport: Find a way to properly mock a service.');
33
34 $this->logInAs('admin'); 32 $this->logInAs('admin');
35 $client = $this->getClient(); 33 $client = $this->getClient();
36 34
@@ -43,9 +41,9 @@ class PocketControllerTest extends WallabagCoreTestCase
43 ->method('getRequestToken') 41 ->method('getRequestToken')
44 ->willReturn('token'); 42 ->willReturn('token');
45 43
46 $client->getContainer()->set('wallabag_import.pocket.import', $pocketImport); 44 static::$kernel->getContainer()->set('wallabag_import.pocket.import', $pocketImport);
47 45
48 $crawler = $client->request('GET', '/import/pocket/auth'); 46 $client->request('GET', '/import/pocket/auth');
49 47
50 $this->assertEquals(301, $client->getResponse()->getStatusCode()); 48 $this->assertEquals(301, $client->getResponse()->getStatusCode());
51 $this->assertContains('getpocket.com/auth/authorize', $client->getResponse()->headers->get('location')); 49 $this->assertContains('getpocket.com/auth/authorize', $client->getResponse()->headers->get('location'));
@@ -56,10 +54,55 @@ class PocketControllerTest extends WallabagCoreTestCase
56 $this->logInAs('admin'); 54 $this->logInAs('admin');
57 $client = $this->getClient(); 55 $client = $this->getClient();
58 56
59 $crawler = $client->request('GET', '/import/pocket/callback'); 57 $pocketImport = $this->getMockBuilder('Wallabag\ImportBundle\Import\PocketImport')
58 ->disableOriginalConstructor()
59 ->getMock();
60
61 $pocketImport
62 ->expects($this->once())
63 ->method('authorize')
64 ->willReturn(false);
65
66 static::$kernel->getContainer()->set('wallabag_import.pocket.import', $pocketImport);
67
68 $client->request('GET', '/import/pocket/callback');
60 69
61 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 70 $this->assertEquals(302, $client->getResponse()->getStatusCode());
62 $this->assertContains('import/pocket', $client->getResponse()->headers->get('location')); 71 $this->assertContains('/', $client->getResponse()->headers->get('location'), 'Import is ok, redirect to homepage');
63 $this->assertEquals('flashes.import.notice.failed', $client->getContainer()->get('session')->getFlashBag()->peek('notice')[0]); 72 $this->assertEquals('flashes.import.notice.failed', $client->getContainer()->get('session')->getFlashBag()->peek('notice')[0]);
64 } 73 }
74
75 public function testImportPocketCallback()
76 {
77 $this->logInAs('admin');
78 $client = $this->getClient();
79
80 $pocketImport = $this->getMockBuilder('Wallabag\ImportBundle\Import\PocketImport')
81 ->disableOriginalConstructor()
82 ->getMock();
83
84 $pocketImport
85 ->expects($this->once())
86 ->method('authorize')
87 ->willReturn(true);
88
89 $pocketImport
90 ->expects($this->once())
91 ->method('setMarkAsRead')
92 ->with(false)
93 ->willReturn($pocketImport);
94
95 $pocketImport
96 ->expects($this->once())
97 ->method('import')
98 ->willReturn(true);
99
100 static::$kernel->getContainer()->set('wallabag_import.pocket.import', $pocketImport);
101
102 $client->request('GET', '/import/pocket/callback');
103
104 $this->assertEquals(302, $client->getResponse()->getStatusCode());
105 $this->assertContains('/', $client->getResponse()->headers->get('location'), 'Import is ok, redirect to homepage');
106 $this->assertEquals('flashes.import.notice.summary', $client->getContainer()->get('session')->getFlashBag()->peek('notice')[0]);
107 }
65} 108}
diff --git a/tests/Wallabag/ImportBundle/fixtures/unnamed.png b/tests/Wallabag/ImportBundle/fixtures/unnamed.png
new file mode 100644
index 00000000..e6dd9caa
--- /dev/null
+++ b/tests/Wallabag/ImportBundle/fixtures/unnamed.png
Binary files differ