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

api-platform / core / 17729190580

15 Sep 2025 09:57AM UTC coverage: 22.227% (-0.4%) from 22.578%
17729190580

push

github

web-flow
fix(metadata): compute isWritable during updates (#7383)

fixes #7382

4 of 532 new or added lines in 16 files covered. (0.75%)

167 existing lines in 22 files now uncovered.

11127 of 50061 relevant lines covered (22.23%)

23.49 hits per line

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

0.0
/src/Hal/Tests/Serializer/EntrypointNormalizerTest.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\Hal\Serializer;
15

16
use ApiPlatform\Documentation\Entrypoint;
17
use ApiPlatform\Hal\Serializer\EntrypointNormalizer;
18
use ApiPlatform\Metadata\ApiResource;
19
use ApiPlatform\Metadata\GetCollection;
20
use ApiPlatform\Metadata\IriConverterInterface;
21
use ApiPlatform\Metadata\Operations;
22
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
23
use ApiPlatform\Metadata\Resource\ResourceMetadataCollection;
24
use ApiPlatform\Metadata\Resource\ResourceNameCollection;
25
use ApiPlatform\Metadata\UrlGeneratorInterface;
26
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\Dummy;
27
use PHPUnit\Framework\TestCase;
28

29
/**
30
 * @author Kévin Dunglas <dunglas@gmail.com>
31
 */
32
class EntrypointNormalizerTest extends TestCase
33
{
34
    public function testSupportNormalization(): void
35
    {
36
        $collection = new ResourceNameCollection();
×
37
        $entrypoint = new Entrypoint($collection);
×
38

NEW
39
        $factoryMock = $this->createMock(ResourceMetadataCollectionFactoryInterface::class);
×
NEW
40
        $iriConverterMock = $this->createMock(IriConverterInterface::class);
×
NEW
41
        $urlGeneratorMock = $this->createMock(UrlGeneratorInterface::class);
×
42

NEW
43
        $normalizer = new EntrypointNormalizer($factoryMock, $iriConverterMock, $urlGeneratorMock);
×
44

45
        $this->assertTrue($normalizer->supportsNormalization($entrypoint, EntrypointNormalizer::FORMAT));
×
46
        $this->assertFalse($normalizer->supportsNormalization($entrypoint, 'json'));
×
47
        $this->assertFalse($normalizer->supportsNormalization(new \stdClass(), EntrypointNormalizer::FORMAT));
×
48

49
        $this->assertEmpty($normalizer->getSupportedTypes('json'));
×
50
        $this->assertSame([Entrypoint::class => true], $normalizer->getSupportedTypes($normalizer::FORMAT));
×
51
    }
52

53
    public function testNormalize(): void
54
    {
55
        $collection = new ResourceNameCollection([Dummy::class]);
×
56
        $entrypoint = new Entrypoint($collection);
×
NEW
57
        $factoryMock = $this->createMock(ResourceMetadataCollectionFactoryInterface::class);
×
58
        $operation = (new GetCollection())->withShortName('Dummy')->withClass(Dummy::class);
×
NEW
59
        $factoryMock->expects($this->once())->method('create')->with(Dummy::class)->willReturn(new ResourceMetadataCollection('Dummy', [
×
60
            (new ApiResource('Dummy'))
×
61
                ->withShortName('Dummy')
×
62
                ->withOperations(new Operations([
×
63
                    'get' => $operation,
×
64
                ])),
×
NEW
65
        ]));
×
66

NEW
67
        $iriConverterMock = $this->createMock(IriConverterInterface::class);
×
NEW
68
        $iriConverterMock->expects($this->once())->method('getIriFromResource')->with(Dummy::class, UrlGeneratorInterface::ABS_PATH, $operation)->willReturn('/api/dummies');
×
69

NEW
70
        $urlGeneratorMock = $this->createMock(UrlGeneratorInterface::class);
×
NEW
71
        $urlGeneratorMock->expects($this->once())->method('generate')->with('api_entrypoint')->willReturn('/api');
×
72

NEW
73
        $normalizer = new EntrypointNormalizer($factoryMock, $iriConverterMock, $urlGeneratorMock);
×
74

75
        $expected = [
×
76
            '_links' => [
×
77
                'self' => [
×
78
                    'href' => '/api',
×
79
                ],
×
80
                'dummy' => [
×
81
                    'href' => '/api/dummies',
×
82
                ],
×
83
            ],
×
84
        ];
×
85
        $this->assertSame($expected, $normalizer->normalize($entrypoint, EntrypointNormalizer::FORMAT));
×
86
    }
87
}
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