aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/Wallabag/ApiBundle/Controller/EntryRestController.php3
-rw-r--r--src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php11
-rw-r--r--src/Wallabag/CoreBundle/Resources/views/themes/common/Static/about.html.twig4
-rw-r--r--tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php16
-rw-r--r--tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php20
5 files changed, 50 insertions, 4 deletions
diff --git a/src/Wallabag/ApiBundle/Controller/EntryRestController.php b/src/Wallabag/ApiBundle/Controller/EntryRestController.php
index e9e1aca3..54c1747c 100644
--- a/src/Wallabag/ApiBundle/Controller/EntryRestController.php
+++ b/src/Wallabag/ApiBundle/Controller/EntryRestController.php
@@ -98,12 +98,13 @@ class EntryRestController extends WallabagRestController
98 $tags = $request->query->get('tags', ''); 98 $tags = $request->query->get('tags', '');
99 $since = $request->query->get('since', 0); 99 $since = $request->query->get('since', 0);
100 100
101 /** @var \Pagerfanta\Pagerfanta $pager */
101 $pager = $this->getDoctrine() 102 $pager = $this->getDoctrine()
102 ->getRepository('WallabagCoreBundle:Entry') 103 ->getRepository('WallabagCoreBundle:Entry')
103 ->findEntries($this->getUser()->getId(), $isArchived, $isStarred, $sort, $order, $since, $tags); 104 ->findEntries($this->getUser()->getId(), $isArchived, $isStarred, $sort, $order, $since, $tags);
104 105
105 $pager->setCurrentPage($page);
106 $pager->setMaxPerPage($perPage); 106 $pager->setMaxPerPage($perPage);
107 $pager->setCurrentPage($page);
107 108
108 $pagerfantaFactory = new PagerfantaFactory('page', 'perPage'); 109 $pagerfantaFactory = new PagerfantaFactory('page', 'perPage');
109 $paginatedCollection = $pagerfantaFactory->createRepresentation( 110 $paginatedCollection = $pagerfantaFactory->createRepresentation(
diff --git a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php
index ee66c728..556578d1 100644
--- a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php
+++ b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php
@@ -3,6 +3,7 @@
3namespace Wallabag\CoreBundle\Form\Type; 3namespace 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\Query\QueryInterface; 7use Lexik\Bundle\FormFilterBundle\Filter\Query\QueryInterface;
7use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\NumberRangeFilterType; 8use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\NumberRangeFilterType;
8use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\DateRangeFilterType; 9use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\DateRangeFilterType;
@@ -33,7 +34,7 @@ class EntryFilterType extends AbstractType
33 $this->user = $tokenStorage->getToken() ? $tokenStorage->getToken()->getUser() : null; 34 $this->user = $tokenStorage->getToken() ? $tokenStorage->getToken()->getUser() : null;
34 35
35 if (null === $this->user || !is_object($this->user)) { 36 if (null === $this->user || !is_object($this->user)) {
36 return null; 37 return;
37 } 38 }
38 } 39 }
39 40
@@ -41,6 +42,14 @@ class EntryFilterType extends AbstractType
41 { 42 {
42 $builder 43 $builder
43 ->add('readingTime', NumberRangeFilterType::class, [ 44 ->add('readingTime', NumberRangeFilterType::class, [
45 'left_number_options' => [
46 'condition_operator' => FilterOperands::OPERATOR_GREATER_THAN_EQUAL,
47 'attr' => ['min' => 0],
48 ],
49 'right_number_options' => [
50 'condition_operator' => FilterOperands::OPERATOR_LOWER_THAN_EQUAL,
51 'attr' => ['min' => 0],
52 ],
44 'apply_filter' => function (QueryInterface $filterQuery, $field, $values) { 53 'apply_filter' => function (QueryInterface $filterQuery, $field, $values) {
45 $lower = $values['value']['left_number'][0]; 54 $lower = $values['value']['left_number'][0];
46 $upper = $values['value']['right_number'][0]; 55 $upper = $values['value']['right_number'][0];
diff --git a/src/Wallabag/CoreBundle/Resources/views/themes/common/Static/about.html.twig b/src/Wallabag/CoreBundle/Resources/views/themes/common/Static/about.html.twig
index db193e81..f82e5dc5 100644
--- a/src/Wallabag/CoreBundle/Resources/views/themes/common/Static/about.html.twig
+++ b/src/Wallabag/CoreBundle/Resources/views/themes/common/Static/about.html.twig
@@ -106,8 +106,8 @@
106 <tr><td>hoa/zformat</td><td>BSD-3-Clause</td></tr> 106 <tr><td>hoa/zformat</td><td>BSD-3-Clause</td></tr>
107 <tr><td>htmlawed/htmlawed</td><td>GPL-2.0+ or LGPL-3.0</td></tr> 107 <tr><td>htmlawed/htmlawed</td><td>GPL-2.0+ or LGPL-3.0</td></tr>
108 <tr><td>incenteev/composer-parameter-handler</td><td>MIT</td></tr> 108 <tr><td>incenteev/composer-parameter-handler</td><td>MIT</td></tr>
109 <tr><td>j0k3r/graby</td><td>AGPL-3.0</td></tr> 109 <tr><td>j0k3r/graby</td><td>MIT</td></tr>
110 <tr><td>j0k3r/graby-site-config</td><td>AGPL-3.0</td></tr> 110 <tr><td>j0k3r/graby-site-config</td><td>Public domain</td></tr>
111 <tr><td>j0k3r/php-readability</td><td>Apache-2.0</td></tr> 111 <tr><td>j0k3r/php-readability</td><td>Apache-2.0</td></tr>
112 <tr><td>j0k3r/safecurl</td><td>MIT</td></tr> 112 <tr><td>j0k3r/safecurl</td><td>MIT</td></tr>
113 <tr><td>jdorn/sql-formatter</td><td>MIT</td></tr> 113 <tr><td>jdorn/sql-formatter</td><td>MIT</td></tr>
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
index deafd1fa..0a65f9ce 100644
--- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
+++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php
@@ -157,6 +157,22 @@ class EntryRestControllerTest extends WallabagApiTestCase
157 $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); 157 $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type'));
158 } 158 }
159 159
160 public function testGetEntriesOnPageTwo()
161 {
162 $this->client->request('GET', '/api/entries', [
163 'page' => 2,
164 'perPage' => 2,
165 ]);
166
167 $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
168
169 $content = json_decode($this->client->getResponse()->getContent(), true);
170
171 $this->assertGreaterThanOrEqual(0, $content['total']);
172 $this->assertEquals(2, $content['page']);
173 $this->assertEquals(2, $content['limit']);
174 }
175
160 public function testGetStarredEntries() 176 public function testGetStarredEntries()
161 { 177 {
162 $this->client->request('GET', '/api/entries', ['starred' => 1, 'sort' => 'updated']); 178 $this->client->request('GET', '/api/entries', ['starred' => 1, 'sort' => 'updated']);
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
index 3eb6d47f..7db4cf1f 100644
--- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
@@ -591,6 +591,26 @@ class EntryControllerTest extends WallabagCoreTestCase
591 $this->assertCount(1, $crawler->filter('div[class=entry]')); 591 $this->assertCount(1, $crawler->filter('div[class=entry]'));
592 } 592 }
593 593
594 public function testFilterOnReadingTimeWithNegativeValue()
595 {
596 $this->logInAs('admin');
597 $client = $this->getClient();
598
599 $crawler = $client->request('GET', '/unread/list');
600
601 $form = $crawler->filter('button[id=submit-filter]')->form();
602
603 $data = [
604 'entry_filter[readingTime][right_number]' => -22,
605 'entry_filter[readingTime][left_number]' => -22,
606 ];
607
608 $crawler = $client->submit($form, $data);
609
610 // forcing negative value results in no entry displayed
611 $this->assertCount(0, $crawler->filter('div[class=entry]'));
612 }
613
594 public function testFilterOnReadingTimeOnlyUpper() 614 public function testFilterOnReadingTimeOnlyUpper()
595 { 615 {
596 $this->logInAs('admin'); 616 $this->logInAs('admin');