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

api-platform / core / 6067528200

04 Sep 2023 12:12AM UTC coverage: 36.875% (-21.9%) from 58.794%
6067528200

Pull #5791

github

web-flow
Merge 64157e578 into d09cfc9d2
Pull Request #5791: fix: strip down any sql function name

3096 of 3096 new or added lines in 205 files covered. (100.0%)

9926 of 26918 relevant lines covered (36.87%)

6.5 hits per line

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

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

16
use ApiPlatform\GraphQl\Serializer\SerializerContextBuilderInterface;
17
use ApiPlatform\GraphQl\State\Processor\NormalizeProcessor;
18
use ApiPlatform\Metadata\GraphQl\Mutation;
19
use ApiPlatform\Metadata\GraphQl\Query;
20
use ApiPlatform\Metadata\GraphQl\QueryCollection;
21
use ApiPlatform\Metadata\GraphQl\Subscription;
22
use ApiPlatform\State\Pagination\ArrayPaginator;
23
use ApiPlatform\State\Pagination\Pagination;
24
use PHPUnit\Framework\TestCase;
25
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
26

27
class NormalizeProcessorTest extends TestCase
28
{
29
    /**
30
     * @dataProvider processItems
31
     */
32
    public function testProcess($body, $operation): void
33
    {
34
        $context = ['args' => []];
×
35
        $serializerContext = ['resource_class' => $operation->getClass()];
×
36
        $normalizer = $this->createMock(NormalizerInterface::class);
×
37
        $serializerContextBuilder = $this->createMock(SerializerContextBuilderInterface::class);
×
38
        $serializerContextBuilder->expects($this->once())->method('create')->with($operation->getClass(), $operation, $context, normalization: true)->willReturn($serializerContext);
×
39
        $normalizer->expects($this->once())->method('normalize')->with($body, 'graphql', $serializerContext);
×
40
        $processor = new NormalizeProcessor($normalizer, $serializerContextBuilder, new Pagination());
×
41
        $processor->process($body, $operation, [], $context);
×
42
    }
43

44
    public function processItems(): array
45
    {
46
        return [
×
47
            [new \stdClass(), new Query(class: 'foo')],
×
48
            [new \stdClass(), new Mutation(class: 'foo', shortName: 'Foo')],
×
49
            [new \stdClass(), new Subscription(class: 'foo', shortName: 'Foo')],
×
50
        ];
×
51
    }
52

53
    /**
54
     * @dataProvider processCollection
55
     */
56
    public function testProcessCollection($body, $operation): void
57
    {
58
        $context = ['args' => []];
×
59
        $serializerContext = ['resource_class' => $operation->getClass()];
×
60
        $normalizer = $this->createMock(NormalizerInterface::class);
×
61
        $serializerContextBuilder = $this->createMock(SerializerContextBuilderInterface::class);
×
62
        $serializerContextBuilder->expects($this->once())->method('create')->with($operation->getClass(), $operation, $context, normalization: true)->willReturn($serializerContext);
×
63
        foreach ($body as $v) {
×
64
            $normalizer->expects($this->once())->method('normalize')->with($v, 'graphql', $serializerContext);
×
65
        }
66

67
        $processor = new NormalizeProcessor($normalizer, $serializerContextBuilder, new Pagination());
×
68
        $processor->process($body, $operation, [], $context);
×
69
    }
70

71
    public function processCollection(): array
72
    {
73
        return [
×
74
            [new ArrayPaginator([new \stdClass()], 0, 1), new QueryCollection(class: 'foo')],
×
75
        ];
×
76
    }
77
}
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