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

api-platform / core / 20545070147

27 Dec 2025 10:15PM UTC coverage: 28.855% (+3.7%) from 25.192%
20545070147

push

github

soyuka
ci: upgrade to phpunit 12

Remove soyuka/phpunit fork from all composer.json files and upgrade to
PHPUnit 12.2. Update CI workflow to install PHPUnit before other steps
and configure MongoDB conditional execution. Migrate tests from Prophecy
to PHPUnit native mocking in FieldsBuilderTest and Symfony event listener
tests. Remove unused dataprovider and fix warnings.

0 of 84 new or added lines in 8 files covered. (0.0%)

534 existing lines in 34 files now uncovered.

16760 of 58083 relevant lines covered (28.86%)

78.25 hits per line

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

95.83
/src/Symfony/EventListener/ReadListener.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\Symfony\EventListener;
15

16
use ApiPlatform\Metadata\Exception\InvalidIdentifierException;
17
use ApiPlatform\Metadata\Exception\InvalidUriVariableException;
18
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
19
use ApiPlatform\Metadata\UriVariablesConverterInterface;
20
use ApiPlatform\Metadata\Util\CloneTrait;
21
use ApiPlatform\State\ProviderInterface;
22
use ApiPlatform\State\UriVariablesResolverTrait;
23
use ApiPlatform\State\Util\OperationRequestInitiatorTrait;
24
use ApiPlatform\State\Util\RequestAttributesExtractor;
25
use Symfony\Component\HttpKernel\Event\RequestEvent;
26
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
27

28
/**
29
 * Retrieves data from the applicable data provider and sets it as a request parameter called data.
30
 *
31
 * @author Kévin Dunglas <dunglas@gmail.com>
32
 */
33
final class ReadListener
34
{
35
    use CloneTrait;
36
    use OperationRequestInitiatorTrait;
37
    use UriVariablesResolverTrait;
38

39
    /**
40
     * @param ProviderInterface<object> $provider
41
     */
42
    public function __construct(
43
        private readonly ProviderInterface $provider,
44
        ?ResourceMetadataCollectionFactoryInterface $resourceMetadataCollectionFactory = null,
45
        ?UriVariablesConverterInterface $uriVariablesConverter = null,
46
        private readonly ?ProviderInterface $parameterProvider = null,
47
    ) {
UNCOV
48
        $this->resourceMetadataCollectionFactory = $resourceMetadataCollectionFactory;
378✔
UNCOV
49
        $this->uriVariablesConverter = $uriVariablesConverter;
378✔
50
    }
51

52
    /**
53
     * Calls the data provider and sets the data attribute.
54
     *
55
     * @throws NotFoundHttpException
56
     */
57
    public function onKernelRequest(RequestEvent $event): void
58
    {
UNCOV
59
        $request = $event->getRequest();
378✔
60

UNCOV
61
        if (!($attributes = RequestAttributesExtractor::extractAttributes($request)) || !$attributes['receive']) {
378✔
UNCOV
62
            return;
52✔
63
        }
64

UNCOV
65
        $operation = $this->initializeOperation($request);
331✔
UNCOV
66
        if (!$operation) {
331✔
67
            return;
×
68
        }
69

UNCOV
70
        if (null === $operation->canRead()) {
331✔
UNCOV
71
            $operation = $operation->withRead($operation->getUriVariables() || $request->isMethodSafe());
330✔
72
        }
73

UNCOV
74
        $uriVariables = [];
331✔
UNCOV
75
        if (!$request->attributes->has('exception')) {
331✔
76
            try {
UNCOV
77
                $uriVariables = $this->getOperationUriVariables($operation, $request->attributes->all(), $operation->getClass());
324✔
UNCOV
78
            } catch (InvalidIdentifierException|InvalidUriVariableException $e) {
1✔
UNCOV
79
                if ($operation->canRead()) {
1✔
UNCOV
80
                    throw new NotFoundHttpException('Invalid identifier value or configuration.', $e);
1✔
81
                }
82
            }
83
        }
84

UNCOV
85
        $request->attributes->set('_api_uri_variables', $uriVariables);
331✔
UNCOV
86
        $context = [
331✔
UNCOV
87
            'request' => $request,
331✔
UNCOV
88
            'uri_variables' => $uriVariables,
331✔
UNCOV
89
            'resource_class' => $operation->getClass(),
331✔
UNCOV
90
        ];
331✔
UNCOV
91
        $this->parameterProvider?->provide($operation, $uriVariables, $context);
331✔
UNCOV
92
        $this->provider->provide($operation, $uriVariables, $context);
331✔
93
    }
94
}
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