Completed
Push — develop ( 496f9a...efa997 )
by Jaap
08:42
created

TraitAssemblerTest::testAssembleTraitWithMethod()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 15
nc 1
nop 0
dl 0
loc 20
rs 9.4285
c 1
b 0
f 0
1
<?php
2
/**
3
 * This file is part of phpDocumentor.
4
 *
5
 *  For the full copyright and license information, please view the LICENSE
6
 *  file that was distributed with this source code.
7
 *
8
 *  @copyright 2010-2017 Mike van Riel<[email protected]>
9
 *  @license   http://www.opensource.org/licenses/mit-license.php MIT
10
 *  @link      http://phpdoc.org
11
 */
12
13
namespace phpDocumentor\Descriptor\Builder\Reflector;
14
15
use phpDocumentor\Descriptor\MethodDescriptor;
16
use phpDocumentor\Descriptor\ProjectDescriptorBuilder;
17
use phpDocumentor\Reflection\Fqsen;
18
use phpDocumentor\Reflection\Php\Method;
19
use phpDocumentor\Reflection\Php\Trait_;
20
use PHPUnit\Framework\TestCase;
21
use Mockery as m;
22
23
/**
24
 * @coversDefaultClass \phpDocumentor\Descriptor\Builder\Reflector\TraitAssembler
25
 * @covers ::<private>
26
 */
27
class TraitAssemblerTest extends TestCase
28
{
29
    /**
30
     * @covers ::create
31
     */
32
    public function testAssembleTraitWithMethod()
33
    {
34
        $method = new MethodDescriptor();
35
        $method->setName('method');
36
        $builder = m::mock(ProjectDescriptorBuilder::class);
37
        $builder->shouldReceive('buildDescriptor')->andReturn($method);
38
39
        $traitFqsen = new Fqsen('\My\Space\MyTrait');
40
        $trait = new Trait_($traitFqsen);
41
        $trait->addMethod(new Method(new Fqsen('\My\Space\MyTrait::method()')));
42
        $assembler = new TraitAssembler();
43
        $assembler->setBuilder($builder);
44
45
        $result = $assembler->create($trait);
46
47
        static::assertEquals('\My\Space', $result->getNamespace());
48
        static::assertSame($traitFqsen, $result->getFullyQualifiedStructuralElementName());
49
        static::assertEquals('MyTrait', $result->getName());
50
        static::assertInstanceOf(MethodDescriptor::class,  $result->getMethods()->get('method', false));
0 ignored issues
show
Coding Style introduced by
Expected 1 space instead of 2 after comma in function call.
Loading history...
51
    }
52
}
53