• 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/DenormalizeProviderTest.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\DenormalizeProvider;
18
use ApiPlatform\Metadata\GraphQl\Mutation;
19
use ApiPlatform\Metadata\GraphQl\Query;
20
use ApiPlatform\State\ProviderInterface;
21
use PHPUnit\Framework\TestCase;
22
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
23

24
class DenormalizeProviderTest extends TestCase
25
{
26
    public function testProvide(): void
27
    {
28
        $objectToPopulate = null;
×
29
        $context = ['args' => ['input' => ['test']]];
×
NEW
30
        $operation = new Mutation(class: \stdClass::class);
×
31
        $serializerContext = ['resource_class' => $operation->getClass()];
×
32
        $decorated = $this->createMock(ProviderInterface::class);
×
33
        $decorated->expects($this->once())->method('provide')->willReturn($objectToPopulate);
×
34
        $denormalizer = $this->createMock(DenormalizerInterface::class);
×
35
        $serializerContextBuilder = $this->createMock(SerializerContextBuilderInterface::class);
×
36
        $serializerContextBuilder->expects($this->once())->method('create')->with($operation->getClass(), $operation, $context, false)->willReturn($serializerContext);
×
NEW
37
        $denormalizer->expects($this->once())->method('denormalize')->with(['test'], \stdClass::class, 'graphql', $serializerContext)->willReturn(new \stdClass());
×
38
        $provider = new DenormalizeProvider($decorated, $denormalizer, $serializerContextBuilder);
×
39
        $provider->provide($operation, [], $context);
×
40
    }
41

42
    public function testProvideWithObjectToPopulate(): void
43
    {
44
        $objectToPopulate = new \stdClass();
×
45
        $context = ['args' => ['input' => ['test']]];
×
NEW
46
        $operation = new Mutation(class: \stdClass::class);
×
47
        $serializerContext = ['resource_class' => $operation->getClass(), 'object_to_populate' => $objectToPopulate];
×
48
        $decorated = $this->createMock(ProviderInterface::class);
×
49
        $decorated->expects($this->once())->method('provide')->willReturn($objectToPopulate);
×
50
        $denormalizer = $this->createMock(DenormalizerInterface::class);
×
51
        $serializerContextBuilder = $this->createMock(SerializerContextBuilderInterface::class);
×
52
        $serializerContextBuilder->expects($this->once())->method('create')->with($operation->getClass(), $operation, $context, false)->willReturn($serializerContext);
×
NEW
53
        $denormalizer->expects($this->once())->method('denormalize')->with(['test'], \stdClass::class, 'graphql', $serializerContext)->willReturn(new \stdClass());
×
54
        $provider = new DenormalizeProvider($decorated, $denormalizer, $serializerContextBuilder);
×
55
        $provider->provide($operation, [], $context);
×
56
    }
57

58
    public function testProvideNotCalledWithQuery(): void
59
    {
60
        $objectToPopulate = new \stdClass();
×
61
        $context = ['args' => ['input' => ['test']]];
×
NEW
62
        $operation = new Query(class: \stdClass::class);
×
63
        $serializerContext = ['resource_class' => $operation->getClass()];
×
64
        $decorated = $this->createMock(ProviderInterface::class);
×
65
        $decorated->expects($this->once())->method('provide')->willReturn($objectToPopulate);
×
66
        $denormalizer = $this->createMock(DenormalizerInterface::class);
×
67
        $serializerContextBuilder = $this->createMock(SerializerContextBuilderInterface::class);
×
68
        $serializerContextBuilder->expects($this->never())->method('create')->with($operation->getClass(), $operation, $context, false)->willReturn($serializerContext);
×
NEW
69
        $denormalizer->expects($this->never())->method('denormalize')->with(['test'], \stdClass::class, 'graphql', $serializerContext)->willReturn(new \stdClass());
×
70
        $provider = new DenormalizeProvider($decorated, $denormalizer, $serializerContextBuilder);
×
71
        $provider->provide($operation, [], $context);
×
72
    }
73

74
    public function testProvideNotCalledWithoutDeserialize(): void
75
    {
76
        $objectToPopulate = new \stdClass();
×
77
        $context = ['args' => ['input' => ['test']]];
×
NEW
78
        $operation = new Query(class: \stdClass::class, deserialize: false);
×
79
        $serializerContext = ['resource_class' => $operation->getClass()];
×
80
        $decorated = $this->createMock(ProviderInterface::class);
×
81
        $decorated->expects($this->once())->method('provide')->willReturn($objectToPopulate);
×
82
        $denormalizer = $this->createMock(DenormalizerInterface::class);
×
83
        $serializerContextBuilder = $this->createMock(SerializerContextBuilderInterface::class);
×
84
        $serializerContextBuilder->expects($this->never())->method('create')->with($operation->getClass(), $operation, $context, false)->willReturn($serializerContext);
×
NEW
85
        $denormalizer->expects($this->never())->method('denormalize')->with(['test'], \stdClass::class, 'graphql', $serializerContext)->willReturn(new \stdClass());
×
86
        $provider = new DenormalizeProvider($decorated, $denormalizer, $serializerContextBuilder);
×
87
        $provider->provide($operation, [], $context);
×
88
    }
89
}
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