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)); |
|
|
|
|
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|