Passed
Pull Request — master (#126)
by David
05:59
created

AddTraitTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 8
dl 0
loc 20
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testConstruct() 0 4 1
A testGetName() 0 4 1
A testModifiers() 0 5 1
1
<?php
2
3
namespace TheCodingMachine\TDBM\Utils\Annotation;
4
5
use BadMethodCallException;
6
use PHPUnit\Framework\TestCase;
7
use TheCodingMachine\TDBM\Fixtures\Traits\TestUserTrait;
8
use TheCodingMachine\TDBM\Utils\GeneratorListenerInterface;
9
10
class AddTraitTest extends TestCase
11
{
12
13
    public function testConstruct(): void
14
    {
15
        $this->expectException(BadMethodCallException::class);
16
        new AddTrait(['foo' => 'bar']);
17
    }
18
19
    public function testGetName(): void
20
    {
21
        $trait = new AddTrait(['name' => TestUserTrait::class]);
22
        $this->assertSame('\\'.TestUserTrait::class, $trait->getName());
23
    }
24
25
    public function testModifiers(): void
26
    {
27
        $trait = new AddTrait(['name' => TestUserTrait::class, 'modifiers' => ['A::foo insteadof B', 'A::bar as baz']]);
28
        $this->assertSame(['A::foo' => 'B'], $trait->getInsteadOf());
29
        $this->assertSame(['A::bar' => 'baz'], $trait->getAs());
30
    }
31
}
32