Failed Conditions
Pull Request — new-parser-ast-metadata (#2)
by
unknown
02:41
created

internalAnnotationsProvider()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
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\Annotation\Parser\Reference\IdentifierPassingReferenceResolver;
11
use Doctrine\Tests\Annotations\Annotation\Parser\Reference\NotResolvableReferenceResolver;
12
use Doctrine\Tests\Annotations\Annotation\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
    public function internalAnnotationsProvider() : iterable
54
    {
55
        foreach (InternalAnnotations::getNames() as $name) {
56
            yield [$name];
57
        }
58
    }
59
}
60