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

api-platform / core / 16414261225

21 Jul 2025 10:14AM UTC coverage: 21.806% (-0.2%) from 22.039%
16414261225

Pull #7307

github

web-flow
Merge 92df6bf50 into d3b4b7b40
Pull Request #7307: Use class-string param type for Metadata::getClass

0 of 191 new or added lines in 19 files covered. (0.0%)

44 existing lines in 2 files now uncovered.

11408 of 52317 relevant lines covered (21.81%)

11.64 hits per line

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

0.0
/src/GraphQl/Tests/State/Provider/ReadProviderTest.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\GraphQl\Tests\State\Provider;
15

16
use ApiPlatform\GraphQl\Serializer\SerializerContextBuilderInterface;
17
use ApiPlatform\GraphQl\State\Provider\ReadProvider;
18
use ApiPlatform\Metadata\Exception\ItemNotFoundException;
19
use ApiPlatform\Metadata\GraphQl\Query;
20
use ApiPlatform\Metadata\GraphQl\QueryCollection;
21
use ApiPlatform\Metadata\IriConverterInterface;
22
use ApiPlatform\State\ProviderInterface;
23
use GraphQL\Type\Definition\ResolveInfo;
24
use PHPUnit\Framework\TestCase;
25

26
class ReadProviderTest extends TestCase
27
{
28
    public function testProvide(): void
29
    {
30
        $context = ['args' => ['id' => '/dummy/1']];
×
NEW
31
        $operation = new Query(class: \stdClass::class);
×
32
        $decorated = $this->createMock(ProviderInterface::class);
×
33
        $iriConverter = $this->createMock(IriConverterInterface::class);
×
34
        $iriConverter->expects($this->once())->method('getResourceFromIri')->with('/dummy/1');
×
35
        $serializerContextBuilder = $this->createMock(SerializerContextBuilderInterface::class);
×
36
        $provider = new ReadProvider($decorated, $iriConverter, $serializerContextBuilder, '.');
×
37
        $provider->provide($operation, [], $context);
×
38
    }
39

40
    /**
41
     * Tests that provider returns null if resource is not found.
42
     *
43
     * @see https://github.com/api-platform/core/issues/6072
44
     */
45
    public function testProvideNotExistedResource(): void
46
    {
47
        $context = ['args' => ['id' => '/dummy/1']];
×
NEW
48
        $operation = new Query(class: \stdClass::class);
×
49
        $decorated = $this->createMock(ProviderInterface::class);
×
50
        $iriConverter = $this->createMock(IriConverterInterface::class);
×
51
        $iriConverter->expects($this->once())->method('getResourceFromIri')->with('/dummy/1');
×
52
        $iriConverter->method('getResourceFromIri')->willThrowException(new ItemNotFoundException());
×
53
        $serializerContextBuilder = $this->createMock(SerializerContextBuilderInterface::class);
×
54
        $provider = new ReadProvider($decorated, $iriConverter, $serializerContextBuilder, '.');
×
55
        $result = $provider->provide($operation, [], $context);
×
56

57
        $this->assertNull($result);
×
58
    }
59

60
    public function testProvideCollection(): void
61
    {
62
        $info = $this->createMock(ResolveInfo::class);
×
63
        $info->fieldName = '';
×
NEW
64
        $context = ['root_class' => \stdClass::class, 'source' => [], 'info' => $info, 'filters' => []];
×
NEW
65
        $operation = new QueryCollection(class: \stdClass::class);
×
66
        $decorated = $this->createMock(ProviderInterface::class);
×
67
        $decorated->expects($this->once())->method('provide')->with($operation, [], ['a'] + $context);
×
68
        $iriConverter = $this->createMock(IriConverterInterface::class);
×
69
        $serializerContextBuilder = $this->createMock(SerializerContextBuilderInterface::class);
×
70
        $serializerContextBuilder->expects($this->once())->method('create')->willReturn(['a']);
×
71
        $provider = new ReadProvider($decorated, $iriConverter, $serializerContextBuilder, '.');
×
72
        $provider->provide($operation, [], $context);
×
73
    }
74
}
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