• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

api-platform / core / 10885997573

16 Sep 2024 02:31PM UTC coverage: 6.961% (-0.3%) from 7.281%
10885997573

push

github

web-flow
 feat(laravel): filter validations rules

* refactor(metadata): move parameter validation to the validator component

* feat(laravel): validations rules filters

* cs fixes

* fix(laravel): eloquent filters validation

* fix(laravel): eloquent filters

* fixes

* fix

---------

Co-authored-by: soyuka <soyuka@users.noreply.github.com>
Co-authored-by: Nathan <nathan@les-tilleuls.coop>

87 of 188 new or added lines in 6 files covered. (46.28%)

7 existing lines in 2 files now uncovered.

11475 of 164843 relevant lines covered (6.96%)

14.22 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/tests/Fixtures/TestBundle/Document/SearchFilterParameter.php
1
<?php
2

3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <dunglas@gmail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types=1);
13

14
namespace ApiPlatform\Tests\Fixtures\TestBundle\Document;
15

16
use ApiPlatform\Metadata\ApiFilter;
17
use ApiPlatform\Metadata\GetCollection;
18
use ApiPlatform\Metadata\GraphQl\QueryCollection;
19
use ApiPlatform\Metadata\QueryParameter;
20
use ApiPlatform\Tests\Fixtures\TestBundle\Filter\ODMSearchFilterValueTransformer;
21
use ApiPlatform\Tests\Fixtures\TestBundle\Filter\ODMSearchTextAndDateFilter;
22
use ApiPlatform\Tests\Fixtures\TestBundle\Filter\QueryParameterOdmFilter;
23
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
24

25
#[GetCollection(
26
    uriTemplate: 'search_filter_parameter{._format}',
×
27
    parameters: [
×
28
        'foo' => new QueryParameter(filter: 'app_odm_search_filter_via_parameter'),
×
NEW
29
        'fooAlias' => new QueryParameter(filter: 'app_odm_search_filter_via_parameter', property: 'foo'),
×
UNCOV
30
        'order[:property]' => new QueryParameter(filter: 'app_odm_search_filter_via_parameter.order_filter'),
×
31

32
        'searchPartial[:property]' => new QueryParameter(filter: 'app_odm_search_filter_partial'),
×
33
        'searchExact[:property]' => new QueryParameter(filter: 'app_odm_search_filter_with_exact'),
×
34
        'searchOnTextAndDate[:property]' => new QueryParameter(filter: 'app_odm_filter_date_and_search'),
×
35
        'q' => new QueryParameter(property: 'hydra:freetextQuery'),
×
36
    ]
×
37
)]
×
38
#[QueryCollection(
39
    parameters: [
×
40
        'foo' => new QueryParameter(filter: 'app_odm_search_filter_via_parameter'),
×
41
        'order[:property]' => new QueryParameter(filter: 'app_odm_search_filter_via_parameter.order_filter'),
×
42

43
        'searchPartial[:property]' => new QueryParameter(filter: 'app_odm_search_filter_partial'),
×
44
        'searchExact[:property]' => new QueryParameter(filter: 'app_odm_search_filter_with_exact'),
×
45
        'searchOnTextAndDate[:property]' => new QueryParameter(filter: 'app_odm_filter_date_and_search'),
×
46
        'q' => new QueryParameter(property: 'hydra:freetextQuery'),
×
47
    ]
×
48
)]
×
49
#[ApiFilter(ODMSearchFilterValueTransformer::class, alias: 'app_odm_search_filter_partial', properties: ['foo' => 'partial'], arguments: ['key' => 'searchPartial'])]
50
#[ApiFilter(ODMSearchFilterValueTransformer::class, alias: 'app_odm_search_filter_with_exact', properties: ['foo' => 'exact'], arguments: ['key' => 'searchExact'])]
51
#[ApiFilter(ODMSearchTextAndDateFilter::class, alias: 'app_odm_filter_date_and_search', properties: ['foo', 'createdAt'], arguments: ['dateFilterProperties' => ['createdAt' => 'exclude_null'], 'searchFilterProperties' => ['foo' => 'exact']])]
52
#[QueryParameter(key: ':property', filter: QueryParameterOdmFilter::class)]
53
#[ODM\Document]
54
class SearchFilterParameter
55
{
56
    /**
57
     * @var int The id
58
     */
59
    #[ODM\Field]
60
    #[ODM\Id(strategy: 'INCREMENT', type: 'int')]
61
    private ?int $id = null;
62
    #[ODM\Field]
63
    private string $foo = '';
64
    #[ODM\Field(type: 'date_immutable', nullable: true)]
65
    private ?\DateTimeImmutable $createdAt = null;
66

67
    public function getId(): ?int
68
    {
69
        return $this->id;
×
70
    }
71

72
    public function getFoo(): string
73
    {
74
        return $this->foo;
×
75
    }
76

77
    public function setFoo(string $foo): void
78
    {
79
        $this->foo = $foo;
×
80
    }
81

82
    public function getCreatedAt(): ?\DateTimeImmutable
83
    {
84
        return $this->createdAt;
×
85
    }
86

87
    public function setCreatedAt(\DateTimeImmutable $createdAt): void
88
    {
89
        $this->createdAt = $createdAt;
×
90
    }
91
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc