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

api-platform / core / 19799380020

30 Nov 2025 01:09PM UTC coverage: 0.0%. Remained the same
19799380020

push

github

soyuka
Merge 4.2

0 of 306 new or added lines in 35 files covered. (0.0%)

22 existing lines in 15 files now uncovered.

0 of 57173 relevant lines covered (0.0%)

0.0 hits per line

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

0.0
/src/Serializer/Tests/Mapping/Loader/PropertyMetadataLoaderTest.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\Serializer\Tests\Mapping\Loader;
15

16
use ApiPlatform\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface;
17
use ApiPlatform\Metadata\Property\PropertyNameCollection;
18
use ApiPlatform\Serializer\Mapping\Loader\PropertyMetadataLoader;
19
use ApiPlatform\Serializer\Tests\Fixtures\Model\HasRelation;
20
use ApiPlatform\Serializer\Tests\Fixtures\Model\Relation;
21
use PHPUnit\Framework\TestCase;
22
use Symfony\Component\Serializer\Mapping\ClassMetadata;
23

24
final class PropertyMetadataLoaderTest extends TestCase
25
{
26
    public function testCreateMappingForASetOfProperties(): void
27
    {
28
        $coll = $this->createStub(PropertyNameCollectionFactoryInterface::class);
×
29
        $coll->method('create')->willReturn(new PropertyNameCollection(['relation']));
×
30
        $loader = new PropertyMetadataLoader($coll);
×
31
        $classMetadata = new ClassMetadata(HasRelation::class);
×
32
        $loader->loadClassMetadata($classMetadata);
×
NEW
33
        if (method_exists($classMetadata, 'getAttributesMetadata')) { // @phpstan-ignore-line
×
NEW
34
            $attributesMetadata = $classMetadata->getAttributesMetadata();
×
35
        } else {
NEW
36
            $attributesMetadata = $classMetadata->attributesMetadata; // @phpstan-ignore-line
×
37
        }
38

NEW
39
        $this->assertArrayHasKey('relation', $attributesMetadata);
×
NEW
40
        $this->assertEquals(['read'], $attributesMetadata['relation']->getGroups());
×
41
    }
42

43
    public function testCreateMappingForAClass(): void
44
    {
45
        $coll = $this->createStub(PropertyNameCollectionFactoryInterface::class);
×
46
        $coll->method('create')->willReturn(new PropertyNameCollection(['name']));
×
47
        $loader = new PropertyMetadataLoader($coll);
×
48
        $classMetadata = new ClassMetadata(Relation::class);
×
49
        $loader->loadClassMetadata($classMetadata);
×
NEW
50
        if (method_exists($classMetadata, 'getAttributesMetadata')) { // @phpstan-ignore-line
×
NEW
51
            $attributesMetadata = $classMetadata->getAttributesMetadata();
×
52
        } else {
NEW
53
            $attributesMetadata = $classMetadata->attributesMetadata; // @phpstan-ignore-line
×
54
        }
NEW
55
        $this->assertArrayHasKey('name', $attributesMetadata);
×
NEW
56
        $this->assertEquals(['read'], $attributesMetadata['name']->getGroups());
×
57
    }
58
}
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

© 2025 Coveralls, Inc