diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2016-11-18 23:05:02 +0100 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2016-11-18 23:05:02 +0100 |
commit | d215273c65ed7aecf0a1f887c91752eaf41d191b (patch) | |
tree | 109a91745ba45ae886222d2e34b9491a2d0d3b00 | |
parent | e10e6ab34e62129d57fc69d7b9b69b08c20e6f5a (diff) | |
download | wallabag-d215273c65ed7aecf0a1f887c91752eaf41d191b.tar.gz wallabag-d215273c65ed7aecf0a1f887c91752eaf41d191b.tar.zst wallabag-d215273c65ed7aecf0a1f887c91752eaf41d191b.zip |
Check if status code is OK
-rw-r--r-- | src/Wallabag/CoreBundle/Form/Type/EntryFilterType.php | 13 | ||||
-rw-r--r-- | tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php | 11 |
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; | |||
11 | use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\ChoiceFilterType; | 11 | use Lexik\Bundle\FormFilterBundle\Filter\Form\Type\ChoiceFilterType; |
12 | use Symfony\Component\Form\AbstractType; | 12 | use Symfony\Component\Form\AbstractType; |
13 | use Symfony\Component\Form\FormBuilderInterface; | 13 | use Symfony\Component\Form\FormBuilderInterface; |
14 | use Symfony\Component\HttpFoundation\Response; | ||
14 | use Symfony\Component\OptionsResolver\OptionsResolver; | 15 | use Symfony\Component\OptionsResolver\OptionsResolver; |
15 | use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage; | 16 | use 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 | } |