• 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/Metadata/Tests/Util/PropertyInfoToTypeInfoHelperTest.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
/*
15
 * This file is part of the Symfony package.
16
 *
17
 * (c) Fabien Potencier <fabien@symfony.com>
18
 *
19
 * For the full copyright and license information, please view the LICENSE
20
 * file that was distributed with this source code.
21
 */
22

23
namespace ApiPlatform\Metadata\Tests\Util;
24

25
use ApiPlatform\Metadata\Util\PropertyInfoToTypeInfoHelper;
26
use PHPUnit\Framework\TestCase;
27
use Symfony\Component\PropertyInfo\Type as LegacyType;
28
use Symfony\Component\TypeInfo\Type;
29
use Symfony\Component\TypeInfo\TypeIdentifier;
30

31
class PropertyInfoToTypeInfoHelperTest extends TestCase
32
{
33
    public function testConvertLegacyTypesToType(): void
34
    {
NEW
35
        if (!class_exists(LegacyType::class)) {
×
NEW
36
            $this->markTestSkipped();
×
37
        }
38

NEW
39
        $type = Type::collection(Type::builtin(TypeIdentifier::ARRAY), Type::int(), Type::string()); // @phpstan-ignore-line
×
40

NEW
41
        $tests = [
×
NEW
42
            [null, null],
×
NEW
43
            [Type::null(), [new LegacyType('null')]],
×
44
            // [Type::void(), [new LegacyType('void')]],
NEW
45
            [Type::int(), [new LegacyType('int')]],
×
NEW
46
            [Type::object(\stdClass::class), [new LegacyType('object', false, \stdClass::class)]],
×
NEW
47
            [
×
NEW
48
                Type::generic(Type::object(\stdClass::class), Type::string(), Type::int()),
×
NEW
49
                [new LegacyType('object', false, 'stdClass', false, [new LegacyType('string')], new LegacyType('int'))],
×
NEW
50
            ],
×
NEW
51
            [Type::nullable(Type::int()), [new LegacyType('int', true)]],
×
NEW
52
            [Type::union(Type::int(), Type::string()), [new LegacyType('int'), new LegacyType('string')]],
×
NEW
53
            [
×
NEW
54
                Type::union(Type::int(), Type::string(), Type::null()),
×
NEW
55
                [new LegacyType('int', true), new LegacyType('string', true)],
×
NEW
56
            ],
×
NEW
57
            [$type, [new LegacyType('array', false, null, true, [new LegacyType('string')], new LegacyType('int'))]],
×
UNCOV
58
        ];
×
59

NEW
60
        foreach ($tests as [$expected, $legacyTypes]) {
×
NEW
61
            $this->assertEquals($expected, PropertyInfoToTypeInfoHelper::convertLegacyTypesToType($legacyTypes));
×
62
        }
63
    }
64

65
    public function testConvertTypeToLegacyTypes(): void
66
    {
NEW
67
        if (!class_exists(LegacyType::class)) {
×
NEW
68
            $this->markTestSkipped();
×
69
        }
70

NEW
71
        $tests = [
×
NEW
72
            [null, null],
×
NEW
73
            [null, Type::mixed()],
×
NEW
74
            [null, Type::never()],
×
NEW
75
            [[new LegacyType('null')], Type::null()],
×
NEW
76
            [[new LegacyType('null')], Type::void()],
×
NEW
77
            [[new LegacyType('int')], Type::int()],
×
NEW
78
            [[new LegacyType('object', false, \stdClass::class)], Type::object(\stdClass::class)],
×
NEW
79
            [
×
NEW
80
                [new LegacyType('object', false, \Traversable::class, true, null, new LegacyType('int'))],
×
NEW
81
                Type::generic(Type::object(\Traversable::class), Type::int()),
×
NEW
82
            ],
×
NEW
83
            [
×
NEW
84
                [new LegacyType('array', false, null, true, new LegacyType('int'), new LegacyType('string'))],
×
NEW
85
                Type::generic(Type::builtin(TypeIdentifier::ARRAY), Type::int(), Type::string()), // @phpstan-ignore-line
×
NEW
86
            ],
×
NEW
87
            [
×
NEW
88
                [new LegacyType('array', false, null, true, new LegacyType('int'), new LegacyType('string'))],
×
NEW
89
                Type::collection(Type::builtin(TypeIdentifier::ARRAY), Type::string(), Type::int()), // @phpstan-ignore-line
×
NEW
90
            ],
×
NEW
91
            [[new LegacyType('int', true)], Type::nullable(Type::int())],
×
NEW
92
            [[new LegacyType('int'), new LegacyType('string')], Type::union(Type::int(), Type::string())],
×
NEW
93
            [
×
NEW
94
                [new LegacyType('int', true), new LegacyType('string', true)],
×
NEW
95
                Type::union(Type::int(), Type::string(), Type::null()),
×
NEW
96
            ],
×
NEW
97
            [[new LegacyType('object', false, \Stringable::class), new LegacyType('object', false, \Traversable::class)], Type::intersection(Type::object(\Traversable::class), Type::object(\Stringable::class))],
×
98
        ];
×
99

NEW
100
        foreach ($tests as [$expected, $type]) {
×
NEW
101
            $this->assertEquals($expected, PropertyInfoToTypeInfoHelper::convertTypeToLegacyTypes($type));
×
102
        }
103
    }
104
}
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