|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Doctrine\Tests\Annotations\Assembler\Acceptor; |
|
6
|
|
|
|
|
7
|
|
|
use Doctrine\Annotations\Assembler\Acceptor\InternalAcceptor; |
|
8
|
|
|
use Doctrine\Annotations\Metadata\InternalAnnotations; |
|
9
|
|
|
use Doctrine\Annotations\Parser\Ast\Reference; |
|
10
|
|
|
use Doctrine\Tests\Annotations\Parser\Reference\IdentifierPassingReferenceResolver; |
|
11
|
|
|
use Doctrine\Tests\Annotations\Parser\Reference\NotResolvableReferenceResolver; |
|
12
|
|
|
use Doctrine\Tests\Annotations\Parser\ScopeMother; |
|
13
|
|
|
use PHPUnit\Framework\TestCase; |
|
14
|
|
|
|
|
15
|
|
|
class InternalAcceptorTest extends TestCase |
|
16
|
|
|
{ |
|
17
|
|
|
public function testNotAcceptsNotResolvedReference() : void |
|
18
|
|
|
{ |
|
19
|
|
|
$reference = new Reference('Foo', false); |
|
20
|
|
|
$scope = ScopeMother::example(); |
|
21
|
|
|
$acceptor = new InternalAcceptor(new NotResolvableReferenceResolver()); |
|
22
|
|
|
|
|
23
|
|
|
$result = $acceptor->accepts($reference, $scope); |
|
24
|
|
|
|
|
25
|
|
|
$this->assertFalse($result); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @dataProvider internalAnnotationsProvider |
|
30
|
|
|
*/ |
|
31
|
|
|
public function testAcceptsInternalAnnotations(string $name) : void |
|
32
|
|
|
{ |
|
33
|
|
|
$reference = new Reference($name, true); |
|
34
|
|
|
$scope = ScopeMother::example(); |
|
35
|
|
|
$acceptor = new InternalAcceptor(new IdentifierPassingReferenceResolver()); |
|
36
|
|
|
|
|
37
|
|
|
$result = $acceptor->accepts($reference, $scope); |
|
38
|
|
|
|
|
39
|
|
|
$this->assertTrue($result); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
public function testNotAcceptsNonInternalAnnotations() : void |
|
43
|
|
|
{ |
|
44
|
|
|
$reference = new Reference('Foo', false); |
|
45
|
|
|
$scope = ScopeMother::example(); |
|
46
|
|
|
$acceptor = new InternalAcceptor(new IdentifierPassingReferenceResolver()); |
|
47
|
|
|
|
|
48
|
|
|
$result = $acceptor->accepts($reference, $scope); |
|
49
|
|
|
|
|
50
|
|
|
$this->assertFalse($result); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @return string[] |
|
55
|
|
|
*/ |
|
56
|
|
|
public function internalAnnotationsProvider() : iterable |
|
57
|
|
|
{ |
|
58
|
|
|
foreach (InternalAnnotations::getNames() as $name) { |
|
59
|
|
|
yield [$name]; |
|
|
|
|
|
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
} |
|
63
|
|
|
|