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

ConstructorTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 14
dl 0
loc 42
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testCreatesAnnotation() 0 9 1
A setUp() 0 6 1
A validProvider() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Tests\Annotations\Constructor;
6
7
use Doctrine\Annotations\Constructor\Constructor;
8
use Doctrine\Annotations\Constructor\Instantiator\ConstructorInstantiatorStrategy;
9
use Doctrine\Annotations\Constructor\Instantiator\Instantiator;
10
use Doctrine\Annotations\Constructor\Instantiator\PropertyInstantiatorStrategy;
11
use Doctrine\Annotations\Metadata\AnnotationMetadata;
12
use Doctrine\Annotations\Parser\Scope;
13
use Doctrine\Tests\Annotations\Fixtures\AnnotationWithConstructor;
14
use Doctrine\Tests\Annotations\Fixtures\Metadata\AnnotationWithConstructorMetadata;
15
use Doctrine\Tests\Annotations\Parser\ScopeMother;
16
use PHPUnit\Framework\TestCase;
17
18
final class ConstructorTest extends TestCase
19
{
20
    /** @var Constructor */
21
    private $constructor;
22
23
    public function setUp() : void
24
    {
25
        $this->constructor = new Constructor(
26
            new Instantiator(
27
                new ConstructorInstantiatorStrategy(),
28
                new PropertyInstantiatorStrategy()
29
            )
30
        );
31
    }
32
33
    /**
34
     * @param mixed[] $parameters
35
     *
36
     * @dataProvider validProvider
37
     */
38
    public function testCreatesAnnotation(
39
        AnnotationMetadata $annotationMetadata,
40
        Scope $scope,
41
        iterable $parameters,
42
        callable $asserter
43
    ) : void {
44
        $result = $this->constructor->construct($annotationMetadata, $scope, $parameters);
45
46
        $asserter($result);
47
    }
48
49
    /**
50
     * @return mixed[]
51
     */
52
    public function validProvider() : iterable
53
    {
54
        yield 'with constructor' => [
0 ignored issues
show
Bug Best Practice introduced by
The expression yield 'with constructor'...ion(...) { /* ... */ }) returns the type Generator which is incompatible with the documented return type array<mixed,mixed>.
Loading history...
55
            AnnotationWithConstructorMetadata::get(),
56
            ScopeMother::example(),
57
            ['value' => 'foo'],
58
            static function (AnnotationWithConstructor $result) : void {
59
                self::assertSame('foo', $result->getValue());
60
            },
61
        ];
62
    }
63
}
64