Failed Conditions
Push — new-parser-ast-metadata ( 6127e0...5a4a16 )
by Michael
12s
created

testNotAcceptsNonInternalAnnotations()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 9
rs 10
c 0
b 0
f 0
cc 1
nc 1
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\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];
0 ignored issues
show
Bug Best Practice introduced by
The expression yield array($name) returns the type Generator which is incompatible with the documented return type string[].
Loading history...
60
        }
61
    }
62
}
63