aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php13
-rw-r--r--tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php11
2 files changed, 24 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php
index 38321d17..8e2883f7 100644
--- a/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php
+++ b/src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php
@@ -11,6 +11,7 @@ use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\CheckboxFilterType;
11use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\ChoiceFilterType; 11use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\ChoiceFilterType;
12use Symfony\Component\Form\AbstractType; 12use Symfony\Component\Form\AbstractType;
13use Symfony\Component\Form\FormBuilderInterface; 13use Symfony\Component\Form\FormBuilderInterface;
14use Symfony\Component\HttpFoundation\Response;
14use Symfony\Component\OptionsResolver\OptionsResolver; 15use Symfony\Component\OptionsResolver\OptionsResolver;
15use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; 16use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
16 17
@@ -91,6 +92,18 @@ class EntryFilterType extends AbstractType
91 'label' => 'entry.filters.domain_label', 92 'label' => 'entry.filters.domain_label',
92 ]) 93 ])
93 ->add('httpStatus', TextFilterType::class, [ 94 ->add('httpStatus', TextFilterType::class, [
95 'apply_filter' => function (QueryInterface $filterQuery, $field, $values) {
96 $value = $values['value'];
97 if (false === array_key_exists($value, Response::$statusTexts)) {
98 return;
99 }
100
101 $paramName = sprintf('%s', str_replace('.', '_', $field));
102 $expression = $filterQuery->getExpr()->eq($field, ':'.$paramName);
103 $parameters = array($paramName => $value);
104
105 return $filterQuery->createCondition($expression, $parameters);
106 },
94 'label' => 'entry.filters.http_status_label', 107 'label' => 'entry.filters.http_status_label',
95 ]) 108 ])
96 ->add('isArchived', CheckboxFilterType::class, [ 109 ->add('isArchived', CheckboxFilterType::class, [
diff --git a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
index 771903fe..09cf01b8 100644
--- a/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
+++ b/tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php
@@ -1006,5 +1006,16 @@ class EntryControllerTest extends WallabagCoreTestCase
1006 $crawler = $client->submit($form, $data); 1006 $crawler = $client->submit($form, $data);
1007 1007
1008 $this->assertCount(1, $crawler->filter('div[class=entry]')); 1008 $this->assertCount(1, $crawler->filter('div[class=entry]'));
1009
1010 $crawler = $client->request('GET', '/all/list');
1011 $form = $crawler->filter('button[id=submit-filter]')->form();
1012
1013 $data = [
1014 'entry_filter[httpStatus]' => 1024,
1015 ];
1016
1017 $crawler = $client->submit($form, $data);
1018
1019 $this->assertCount(7, $crawler->filter('div[class=entry]'));
1009 } 1020 }
1010} 1021}