aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/Wallabag/CoreBundle/Controller/TagController.php2
-rw-r--r--src/Wallabag/CoreBundle/Entity/Entry.php6
-rw-r--r--src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php9
-rw-r--r--src/Wallabag/CoreBundle/Helper/Redirect.php10
-rw-r--r--src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php1
-rw-r--r--tests/Wallabag/CoreBundle/Command/InstallCommandTest.php106
-rw-r--r--tests/Wallabag/CoreBundle/Controller/TagControllerTest.php10
-rw-r--r--tests/Wallabag/CoreBundle/Helper/RedirectTest.php18
8 files changed, 70 insertions, 92 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/TagController.php b/src/Wallabag/CoreBundle/Controller/TagController.php
index fb6a720b..736eb1dc 100644
--- a/src/Wallabag/CoreBundle/Controller/TagController.php
+++ b/src/Wallabag/CoreBundle/Controller/TagController.php
@@ -70,7 +70,7 @@ class TagController extends Controller
70 $em->flush(); 70 $em->flush();
71 } 71 }
72 72
73 $redirectUrl = $this->get('wallabag_core.helper.redirect')->to($request->headers->get('referer')); 73 $redirectUrl = $this->get('wallabag_core.helper.redirect')->to($request->headers->get('referer'), '', true);
74 74
75 return $this->redirect($redirectUrl); 75 return $this->redirect($redirectUrl);
76 } 76 }
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php
index 08a67c34..9a7dd4e7 100644
--- a/src/Wallabag/CoreBundle/Entity/Entry.php
+++ b/src/Wallabag/CoreBundle/Entity/Entry.php
@@ -550,7 +550,7 @@ class Entry
550 } 550 }
551 551
552 /** 552 /**
553 * @return ArrayCollection<Tag> 553 * @return ArrayCollection
554 */ 554 */
555 public function getTags() 555 public function getTags()
556 { 556 {
@@ -685,7 +685,7 @@ class Entry
685 } 685 }
686 686
687 /** 687 /**
688 * @return int 688 * @return string
689 */ 689 */
690 public function getHttpStatus() 690 public function getHttpStatus()
691 { 691 {
@@ -693,7 +693,7 @@ class Entry
693 } 693 }
694 694
695 /** 695 /**
696 * @param int $httpStatus 696 * @param string $httpStatus
697 * 697 *
698 * @return Entry 698 * @return Entry
699 */ 699 */
diff --git a/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php b/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php
index c712bb26..1c56fa9f 100644
--- a/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php
+++ b/src/Wallabag/CoreBundle/GuzzleSiteAuthenticator/GrabySiteConfigBuilder.php
@@ -5,7 +5,6 @@ namespace Wallabag\CoreBundle\GuzzleSiteAuthenticator;
5use BD\GuzzleSiteAuthenticator\SiteConfig\SiteConfig; 5use BD\GuzzleSiteAuthenticator\SiteConfig\SiteConfig;
6use BD\GuzzleSiteAuthenticator\SiteConfig\SiteConfigBuilder; 6use BD\GuzzleSiteAuthenticator\SiteConfig\SiteConfigBuilder;
7use Graby\SiteConfig\ConfigBuilder; 7use Graby\SiteConfig\ConfigBuilder;
8use OutOfRangeException;
9use Psr\Log\LoggerInterface; 8use Psr\Log\LoggerInterface;
10 9
11class GrabySiteConfigBuilder implements SiteConfigBuilder 10class GrabySiteConfigBuilder implements SiteConfigBuilder
@@ -38,13 +37,7 @@ class GrabySiteConfigBuilder implements SiteConfigBuilder
38 } 37 }
39 38
40 /** 39 /**
41 * Builds the SiteConfig for a host. 40 * {@inheritdoc}
42 *
43 * @param string $host The "www." prefix is ignored
44 *
45 * @return SiteConfig
46 *
47 * @throws OutOfRangeException If there is no config for $host
48 */ 41 */
49 public function buildForHost($host) 42 public function buildForHost($host)
50 { 43 {
diff --git a/src/Wallabag/CoreBundle/Helper/Redirect.php b/src/Wallabag/CoreBundle/Helper/Redirect.php
index f78b7fe0..abc84d08 100644
--- a/src/Wallabag/CoreBundle/Helper/Redirect.php
+++ b/src/Wallabag/CoreBundle/Helper/Redirect.php
@@ -21,12 +21,13 @@ class Redirect
21 } 21 }
22 22
23 /** 23 /**
24 * @param string $url URL to redirect 24 * @param string $url URL to redirect
25 * @param string $fallback Fallback URL if $url is null 25 * @param string $fallback Fallback URL if $url is null
26 * @param bool $ignoreActionMarkAsRead Ignore configured action when mark as read
26 * 27 *
27 * @return string 28 * @return string
28 */ 29 */
29 public function to($url, $fallback = '') 30 public function to($url, $fallback = '', $ignoreActionMarkAsRead = false)
30 { 31 {
31 $user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null; 32 $user = $this->tokenStorage->getToken() ? $this->tokenStorage->getToken()->getUser() : null;
32 33
@@ -34,7 +35,8 @@ class Redirect
34 return $url; 35 return $url;
35 } 36 }
36 37
37 if (Config::REDIRECT_TO_HOMEPAGE === $user->getConfig()->getActionMarkAsRead()) { 38 if (!$ignoreActionMarkAsRead &&
39 Config::REDIRECT_TO_HOMEPAGE === $user->getConfig()->getActionMarkAsRead()) {
38 return $this->router->generate('homepage'); 40 return $this->router->generate('homepage');
39 } 41 }
40 42
diff --git a/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php b/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php
index add27db2..509d0dec 100644
--- a/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php
+++ b/src/Wallabag/CoreBundle/Helper/RuleBasedTagger.php
@@ -15,6 +15,7 @@ class RuleBasedTagger
15 private $rulerz; 15 private $rulerz;
16 private $tagRepository; 16 private $tagRepository;
17 private $entryRepository; 17 private $entryRepository;
18 private $logger;
18 19
19 public function __construct(RulerZ $rulerz, TagRepository $tagRepository, EntryRepository $entryRepository, LoggerInterface $logger) 20 public function __construct(RulerZ $rulerz, TagRepository $tagRepository, EntryRepository $entryRepository, LoggerInterface $logger)
20 { 21 {
diff --git a/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php b/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php
index 122a87d4..71c2ffc6 100644
--- a/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php
+++ b/tests/Wallabag/CoreBundle/Command/InstallCommandTest.php
@@ -67,18 +67,14 @@ class InstallCommandTest extends WallabagCoreTestCase
67 67
68 $command = $application->find('wallabag:install'); 68 $command = $application->find('wallabag:install');
69 69
70 // We mock the QuestionHelper
71 $question = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper')
72 ->disableOriginalConstructor()
73 ->getMock();
74 $question->expects($this->any())
75 ->method('ask')
76 ->will($this->returnValue('yes_'.uniqid('', true)));
77
78 // We override the standard helper with our mock
79 $command->getHelperSet()->set($question, 'question');
80
81 $tester = new CommandTester($command); 70 $tester = new CommandTester($command);
71 $tester->setInputs([
72 'y', // dropping database
73 'y', // create super admin
74 'username_'.uniqid('', true), // username
75 'password_'.uniqid('', true), // password
76 'email_'.uniqid('', true).'@wallabag.it', // email
77 ]);
82 $tester->execute([ 78 $tester->execute([
83 'command' => $command->getName(), 79 'command' => $command->getName(),
84 ]); 80 ]);
@@ -97,18 +93,13 @@ class InstallCommandTest extends WallabagCoreTestCase
97 93
98 $command = $application->find('wallabag:install'); 94 $command = $application->find('wallabag:install');
99 95
100 // We mock the QuestionHelper
101 $question = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper')
102 ->disableOriginalConstructor()
103 ->getMock();
104 $question->expects($this->any())
105 ->method('ask')
106 ->will($this->returnValue('yes_'.uniqid('', true)));
107
108 // We override the standard helper with our mock
109 $command->getHelperSet()->set($question, 'question');
110
111 $tester = new CommandTester($command); 96 $tester = new CommandTester($command);
97 $tester->setInputs([
98 'y', // create super admin
99 'username_'.uniqid('', true), // username
100 'password_'.uniqid('', true), // password
101 'email_'.uniqid('', true).'@wallabag.it', // email
102 ]);
112 $tester->execute([ 103 $tester->execute([
113 'command' => $command->getName(), 104 'command' => $command->getName(),
114 '--reset' => true, 105 '--reset' => true,
@@ -150,18 +141,13 @@ class InstallCommandTest extends WallabagCoreTestCase
150 141
151 $command = $application->find('wallabag:install'); 142 $command = $application->find('wallabag:install');
152 143
153 // We mock the QuestionHelper
154 $question = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper')
155 ->disableOriginalConstructor()
156 ->getMock();
157 $question->expects($this->any())
158 ->method('ask')
159 ->will($this->returnValue('yes_'.uniqid('', true)));
160
161 // We override the standard helper with our mock
162 $command->getHelperSet()->set($question, 'question');
163
164 $tester = new CommandTester($command); 144 $tester = new CommandTester($command);
145 $tester->setInputs([
146 'y', // create super admin
147 'username_'.uniqid('', true), // username
148 'password_'.uniqid('', true), // password
149 'email_'.uniqid('', true).'@wallabag.it', // email
150 ]);
165 $tester->execute([ 151 $tester->execute([
166 'command' => $command->getName(), 152 'command' => $command->getName(),
167 ]); 153 ]);
@@ -183,23 +169,12 @@ class InstallCommandTest extends WallabagCoreTestCase
183 169
184 $command = $application->find('wallabag:install'); 170 $command = $application->find('wallabag:install');
185 171
186 // We mock the QuestionHelper
187 $question = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper')
188 ->disableOriginalConstructor()
189 ->getMock();
190
191 $question->expects($this->exactly(3))
192 ->method('ask')
193 ->will($this->onConsecutiveCalls(
194 false, // don't want to reset the entire database
195 true, // do want to reset the schema
196 false // don't want to create a new user
197 ));
198
199 // We override the standard helper with our mock
200 $command->getHelperSet()->set($question, 'question');
201
202 $tester = new CommandTester($command); 172 $tester = new CommandTester($command);
173 $tester->setInputs([
174 'n', // don't want to reset the entire database
175 'y', // do want to reset the schema
176 'n', // don't want to create a new user
177 ]);
203 $tester->execute([ 178 $tester->execute([
204 'command' => $command->getName(), 179 'command' => $command->getName(),
205 ]); 180 ]);
@@ -239,22 +214,11 @@ class InstallCommandTest extends WallabagCoreTestCase
239 214
240 $command = $application->find('wallabag:install'); 215 $command = $application->find('wallabag:install');
241 216
242 // We mock the QuestionHelper
243 $question = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper')
244 ->disableOriginalConstructor()
245 ->getMock();
246
247 $question->expects($this->exactly(2))
248 ->method('ask')
249 ->will($this->onConsecutiveCalls(
250 false, // don't want to reset the entire database
251 false // don't want to create a new user
252 ));
253
254 // We override the standard helper with our mock
255 $command->getHelperSet()->set($question, 'question');
256
257 $tester = new CommandTester($command); 217 $tester = new CommandTester($command);
218 $tester->setInputs([
219 'n', // don't want to reset the entire database
220 'n', // don't want to create a new user
221 ]);
258 $tester->execute([ 222 $tester->execute([
259 'command' => $command->getName(), 223 'command' => $command->getName(),
260 ]); 224 ]);
@@ -275,21 +239,11 @@ class InstallCommandTest extends WallabagCoreTestCase
275 239
276 $command = $application->find('wallabag:install'); 240 $command = $application->find('wallabag:install');
277 241
278 // We mock the QuestionHelper
279 $question = $this->getMockBuilder('Symfony\Component\Console\Helper\QuestionHelper')
280 ->disableOriginalConstructor()
281 ->getMock();
282 $question->expects($this->any())
283 ->method('ask')
284 ->will($this->returnValue('yes_'.uniqid('', true)));
285
286 // We override the standard helper with our mock
287 $command->getHelperSet()->set($question, 'question');
288
289 $tester = new CommandTester($command); 242 $tester = new CommandTester($command);
290 $tester->execute([ 243 $tester->execute([
291 'command' => $command->getName(), 244 'command' => $command->getName(),
292 '--no-interaction' => true, 245 ], [
246 'interactive' => false,
293 ]); 247 ]);
294 248
295 $this->assertContains('Checking system requirements.', $tester->getDisplay()); 249 $this->assertContains('Checking system requirements.', $tester->getDisplay());
diff --git a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
index c3b22dcd..80611a87 100644
--- a/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/TagControllerTest.php
@@ -126,9 +126,19 @@ class TagControllerTest extends WallabagCoreTestCase
126 ->getRepository('WallabagCoreBundle:Tag') 126 ->getRepository('WallabagCoreBundle:Tag')
127 ->findOneByEntryAndTagLabel($entry, $this->tagName); 127 ->findOneByEntryAndTagLabel($entry, $this->tagName);
128 128
129 // We make a first request to set an history and test redirection after tag deletion
130 $client->request('GET', '/view/'.$entry->getId());
131 $entryUri = $client->getRequest()->getUri();
129 $client->request('GET', '/remove-tag/'.$entry->getId().'/'.$tag->getId()); 132 $client->request('GET', '/remove-tag/'.$entry->getId().'/'.$tag->getId());
130 133
131 $this->assertEquals(302, $client->getResponse()->getStatusCode()); 134 $this->assertEquals(302, $client->getResponse()->getStatusCode());
135 $this->assertEquals($entryUri, $client->getResponse()->getTargetUrl());
136
137 // re-retrieve the entry to be sure to get fresh data from database (mostly for tags)
138 $entry = $client->getContainer()
139 ->get('doctrine.orm.entity_manager')
140 ->getRepository('WallabagCoreBundle:Entry')
141 ->findByUrlAndUserId('http://0.0.0.0/entry1', $this->getLoggedInUserId());
132 142
133 $this->assertNotContains($this->tagName, $entry->getTags()); 143 $this->assertNotContains($this->tagName, $entry->getTags());
134 144
diff --git a/tests/Wallabag/CoreBundle/Helper/RedirectTest.php b/tests/Wallabag/CoreBundle/Helper/RedirectTest.php
index 0539f20a..f420d06a 100644
--- a/tests/Wallabag/CoreBundle/Helper/RedirectTest.php
+++ b/tests/Wallabag/CoreBundle/Helper/RedirectTest.php
@@ -89,4 +89,22 @@ class RedirectTest extends \PHPUnit_Framework_TestCase
89 89
90 $this->assertEquals($this->routerMock->generate('homepage'), $redirectUrl); 90 $this->assertEquals($this->routerMock->generate('homepage'), $redirectUrl);
91 } 91 }
92
93 public function testUserForRedirectWithIgnoreActionMarkAsRead()
94 {
95 $this->token->getUser()->getConfig()->setActionMarkAsRead(Config::REDIRECT_TO_HOMEPAGE);
96
97 $redirectUrl = $this->redirect->to('/unread/list', '', true);
98
99 $this->assertEquals('/unread/list', $redirectUrl);
100 }
101
102 public function testUserForRedirectNullWithFallbackWithIgnoreActionMarkAsRead()
103 {
104 $this->token->getUser()->getConfig()->setActionMarkAsRead(Config::REDIRECT_TO_HOMEPAGE);
105
106 $redirectUrl = $this->redirect->to(null, 'fallback', true);
107
108 $this->assertEquals('fallback', $redirectUrl);
109 }
92} 110}