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

api-platform / core / 14726100744

29 Apr 2025 07:49AM UTC coverage: 8.463% (-0.02%) from 8.479%
14726100744

push

github

web-flow
doc(doctrine): compute and sort a virtual field (#7113)

9 of 180 new or added lines in 6 files covered. (5.0%)

293 existing lines in 12 files now uncovered.

13400 of 158343 relevant lines covered (8.46%)

22.89 hits per line

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

0.0
/tests/Fixtures/TestBundle/Filter/SortComputedFieldFilter.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\Filter;
15

16
use ApiPlatform\Doctrine\Orm\Filter\FilterInterface;
17
use ApiPlatform\Doctrine\Orm\Util\QueryNameGeneratorInterface;
18
use ApiPlatform\Metadata\JsonSchemaFilterInterface;
19
use ApiPlatform\Metadata\Operation;
20
use ApiPlatform\Metadata\Parameter;
21
use ApiPlatform\State\ParameterNotFound;
22
use Doctrine\ORM\QueryBuilder;
23

24
class SortComputedFieldFilter implements FilterInterface, JsonSchemaFilterInterface
25
{
26
    public function getDescription(string $resourceClass): array
27
    {
NEW
28
        return [];
×
29
    }
30

31
    public function apply(QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, ?Operation $operation = null, array $context = []): void
32
    {
NEW
33
        if ($context['parameter']->getValue() instanceof ParameterNotFound) {
×
NEW
34
            return;
×
35
        }
36

NEW
37
        $queryBuilder->addOrderBy('totalQuantity', $context['parameter']->getValue()['totalQuantity'] ?? 'ASC');
×
38
    }
39

40
    /**
41
     * @return array<string, mixed>
42
     */
43
    public function getSchema(Parameter $parameter): array
44
    {
NEW
45
        return ['type' => 'string', 'enum' => ['asc', 'desc']];
×
46
    }
47
}
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

© 2026 Coveralls, Inc