1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* This file is part of phpDocumentor. |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
* |
11
|
|
|
* @link http://phpdoc.org |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace phpDocumentor\Reflection; |
15
|
|
|
|
16
|
|
|
use phpDocumentor\Reflection\Types\Context; |
17
|
|
|
use PHPUnit\Framework\TestCase; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @coversDefaultClass \phpDocumentor\Reflection\FqsenResolver |
21
|
|
|
* @covers ::<private> |
22
|
|
|
*/ |
23
|
|
|
final class FqsenResolverTest extends TestCase |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* @covers ::resolve |
27
|
|
|
*/ |
28
|
|
|
public function testResolveFqsen() : void |
29
|
|
|
{ |
30
|
|
|
$fqsenResolver = new FqsenResolver(); |
31
|
|
|
|
32
|
|
|
$context = new Context('', []); |
33
|
|
|
|
34
|
|
|
$result = $fqsenResolver->resolve('\DocBlock', $context); |
35
|
|
|
static::assertSame('\DocBlock', (string) $result); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @covers ::resolve |
40
|
|
|
*/ |
41
|
|
|
public function testResolveFqsenWithEmoji() : void |
42
|
|
|
{ |
43
|
|
|
$fqsenResolver = new FqsenResolver(); |
44
|
|
|
|
45
|
|
|
$context = new Context('', []); |
46
|
|
|
|
47
|
|
|
$result = $fqsenResolver->resolve('\My😁DocBlock', $context); |
48
|
|
|
static::assertSame('\My😁DocBlock', (string) $result); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
/** |
52
|
|
|
* @covers ::resolve |
53
|
|
|
*/ |
54
|
|
|
public function testResolveWithoutContext() : void |
55
|
|
|
{ |
56
|
|
|
$fqsenResolver = new FqsenResolver(); |
57
|
|
|
|
58
|
|
|
$result = $fqsenResolver->resolve('\DocBlock'); |
59
|
|
|
static::assertSame('\DocBlock', (string) $result); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @covers ::resolve |
64
|
|
|
*/ |
65
|
|
|
public function testResolveFromAlias() : void |
66
|
|
|
{ |
67
|
|
|
$fqsenResolver = new FqsenResolver(); |
68
|
|
|
|
69
|
|
|
$context = new Context('somens', ['ns' => 'some\other\ns']); |
70
|
|
|
|
71
|
|
|
$result = $fqsenResolver->resolve('ns', $context); |
72
|
|
|
static::assertSame('\some\other\ns', (string) $result); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @covers ::resolve |
77
|
|
|
*/ |
78
|
|
|
public function testResolveFromPartialAlias() : void |
79
|
|
|
{ |
80
|
|
|
$fqsenResolver = new FqsenResolver(); |
81
|
|
|
|
82
|
|
|
$context = new Context('somens', ['other' => 'some\other']); |
83
|
|
|
|
84
|
|
|
$result = $fqsenResolver->resolve('other\ns', $context); |
85
|
|
|
static::assertSame('\some\other\ns', (string) $result); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
public function testResolveThrowsExceptionWhenGarbageInputIsPassed() : void |
89
|
|
|
{ |
90
|
|
|
$this->expectException('InvalidArgumentException'); |
91
|
|
|
$fqsenResolver = new FqsenResolver(); |
92
|
|
|
|
93
|
|
|
$context = new Context('', []); |
94
|
|
|
|
95
|
|
|
$fqsenResolver->resolve('this is complete garbage', $context); |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|