diff options
Diffstat (limited to 'src/Wallabag')
4 files changed, 59 insertions, 2 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/ConfigController.php b/src/Wallabag/CoreBundle/Controller/ConfigController.php index ccc3e8a1..4f75511b 100644 --- a/src/Wallabag/CoreBundle/Controller/ConfigController.php +++ b/src/Wallabag/CoreBundle/Controller/ConfigController.php | |||
@@ -140,6 +140,7 @@ class ConfigController extends Controller | |||
140 | $config->setItemsPerPage($this->getParameter('wallabag_core.items_on_page')); | 140 | $config->setItemsPerPage($this->getParameter('wallabag_core.items_on_page')); |
141 | $config->setRssLimit($this->getParameter('wallabag_core.rss_limit')); | 141 | $config->setRssLimit($this->getParameter('wallabag_core.rss_limit')); |
142 | $config->setLanguage($this->getParameter('wallabag_core.language')); | 142 | $config->setLanguage($this->getParameter('wallabag_core.language')); |
143 | $config->setReadingSpeed($this->getParameter('wallabag_core.reading_speed')); | ||
143 | 144 | ||
144 | $em->persist($config); | 145 | $em->persist($config); |
145 | 146 | ||
diff --git a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php index dcdb3ab7..cd4d3490 100644 --- a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php +++ b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php | |||
@@ -35,6 +35,20 @@ class EntryFilterType extends AbstractType | |||
35 | { | 35 | { |
36 | $builder | 36 | $builder |
37 | ->add('readingTime', NumberRangeFilterType::class, [ | 37 | ->add('readingTime', NumberRangeFilterType::class, [ |
38 | 'apply_filter' => function (QueryInterface $filterQuery, $field, $values) { | ||
39 | $value = $values['value']; | ||
40 | |||
41 | if (null === $value['left_number'][0] || null === $value['right_number'][0]) { | ||
42 | return; | ||
43 | } | ||
44 | |||
45 | $min = (int) ($value['left_number'][0] * $this->user->getConfig()->getReadingSpeed()); | ||
46 | $max = (int) ($value['right_number'][0] * $this->user->getConfig()->getReadingSpeed()); | ||
47 | |||
48 | $expression = $filterQuery->getExpr()->between($field, $min, $max); | ||
49 | |||
50 | return $filterQuery->createCondition($expression); | ||
51 | }, | ||
38 | 'label' => 'entry.filters.reading_time.label', | 52 | 'label' => 'entry.filters.reading_time.label', |
39 | ]) | 53 | ]) |
40 | ->add('createdAt', DateRangeFilterType::class, [ | 54 | ->add('createdAt', DateRangeFilterType::class, [ |
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php index 1aa1a7ed..8cdedfda 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php | |||
@@ -60,6 +60,43 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
60 | $this->assertContains('flashes.config.notice.config_saved', $alert[0]); | 60 | $this->assertContains('flashes.config.notice.config_saved', $alert[0]); |
61 | } | 61 | } |
62 | 62 | ||
63 | public function testChangeReadingSpeed() | ||
64 | { | ||
65 | $this->logInAs('admin'); | ||
66 | $client = $this->getClient(); | ||
67 | |||
68 | $crawler = $client->request('GET', '/unread/list'); | ||
69 | $form = $crawler->filter('button[id=submit-filter]')->form(); | ||
70 | $dataFilters = [ | ||
71 | 'entry_filter[readingTime][right_number]' => 22, | ||
72 | 'entry_filter[readingTime][left_number]' => 22, | ||
73 | ]; | ||
74 | $crawler = $client->submit($form, $dataFilters); | ||
75 | $this->assertCount(1, $crawler->filter('div[class=entry]')); | ||
76 | |||
77 | // Change reading speed | ||
78 | $crawler = $client->request('GET', '/config'); | ||
79 | $form = $crawler->filter('button[id=config_save]')->form(); | ||
80 | $data = [ | ||
81 | 'config[reading_speed]' => '2', | ||
82 | ]; | ||
83 | $client->submit($form, $data); | ||
84 | |||
85 | // Is the entry still available via filters? | ||
86 | $crawler = $client->request('GET', '/unread/list'); | ||
87 | $form = $crawler->filter('button[id=submit-filter]')->form(); | ||
88 | $crawler = $client->submit($form, $dataFilters); | ||
89 | $this->assertCount(0, $crawler->filter('div[class=entry]')); | ||
90 | |||
91 | // Restore old configuration | ||
92 | $crawler = $client->request('GET', '/config'); | ||
93 | $form = $crawler->filter('button[id=config_save]')->form(); | ||
94 | $data = [ | ||
95 | 'config[reading_speed]' => '0.5', | ||
96 | ]; | ||
97 | $client->submit($form, $data); | ||
98 | } | ||
99 | |||
63 | public function dataForUpdateFailed() | 100 | public function dataForUpdateFailed() |
64 | { | 101 | { |
65 | return [ | 102 | return [ |
@@ -355,6 +392,11 @@ class ConfigControllerTest extends WallabagCoreTestCase | |||
355 | 392 | ||
356 | $this->assertTrue(false !== $user); | 393 | $this->assertTrue(false !== $user); |
357 | $this->assertTrue($user->isEnabled()); | 394 | $this->assertTrue($user->isEnabled()); |
395 | $this->assertEquals('material', $user->getConfig()->getTheme()); | ||
396 | $this->assertEquals(12, $user->getConfig()->getItemsPerPage()); | ||
397 | $this->assertEquals(50, $user->getConfig()->getRssLimit()); | ||
398 | $this->assertEquals('en', $user->getConfig()->getLanguage()); | ||
399 | $this->assertEquals(1, $user->getConfig()->getReadingSpeed()); | ||
358 | } | 400 | } |
359 | 401 | ||
360 | public function testRssUpdateResetToken() | 402 | public function testRssUpdateResetToken() |
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php index 64ebd631..df4c34cd 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php | |||
@@ -462,8 +462,8 @@ class EntryControllerTest extends WallabagCoreTestCase | |||
462 | $form = $crawler->filter('button[id=submit-filter]')->form(); | 462 | $form = $crawler->filter('button[id=submit-filter]')->form(); |
463 | 463 | ||
464 | $data = [ | 464 | $data = [ |
465 | 'entry_filter[readingTime][right_number]' => 11, | 465 | 'entry_filter[readingTime][right_number]' => 22, |
466 | 'entry_filter[readingTime][left_number]' => 11, | 466 | 'entry_filter[readingTime][left_number]' => 22, |
467 | ]; | 467 | ]; |
468 | 468 | ||
469 | $crawler = $client->submit($form, $data); | 469 | $crawler = $client->submit($form, $data); |