-
-
Notifications
You must be signed in to change notification settings - Fork 589
/
DocBlockTypeResolverTest.php
42 lines (36 loc) · 1.26 KB
/
DocBlockTypeResolverTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
declare(strict_types=1);
namespace JMS\Serializer\Tests\Metadata\Driver;
use JMS\Serializer\Metadata\Driver\DocBlockDriver\DocBlockTypeResolver;
use JMS\Serializer\Tests\Fixtures\ObjectWithPhpDocProperty;
use PHPUnit\Framework\TestCase;
use ReflectionProperty;
final class DocBlockTypeResolverTest extends TestCase
{
public function testGetPropertyDocblockTypeHintDoesNotCrash(): void
{
// It crashed on PHP 7.3 and less because of array_merge(...[])
$resolver = new DocBlockTypeResolver();
self::assertNull(
$resolver->getPropertyDocblockTypeHint(
new ReflectionProperty(ObjectWithPhpDocProperty::class, 'emptyBlock'),
),
);
}
public function testGetPropertyDocblockTypeHintDoesNotCrashWhenUnionType(): void
{
$resolver = new DocBlockTypeResolver();
self::assertSame(
'string',
$resolver->getPropertyDocblockTypeHint(
new ReflectionProperty(ObjectWithPhpDocProperty::class, 'firstname'),
),
);
self::assertSame(
'string',
$resolver->getPropertyDocblockTypeHint(
new ReflectionProperty(ObjectWithPhpDocProperty::class, 'lastname'),
),
);
}
}