1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* phpDocumentor |
4
|
|
|
* |
5
|
|
|
* PHP Version 5.5 |
6
|
|
|
* |
7
|
|
|
* @copyright 2010-2015 Mike van Riel / Naenius (http://www.naenius.com) |
8
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php MIT |
9
|
|
|
* @link http://phpdoc.org |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace phpDocumentor\Reflection\Php\Factory; |
13
|
|
|
|
14
|
|
|
use Mockery as m; |
15
|
|
|
use phpDocumentor\Reflection\Php\Argument as ArgumentDescriptor; |
16
|
|
|
use phpDocumentor\Reflection\Php\ProjectFactoryStrategies; |
17
|
|
|
use phpDocumentor\Reflection\PrettyPrinter; |
18
|
|
|
use PhpParser\Node\Param; |
19
|
|
|
use PhpParser\Node\Scalar\String_; |
20
|
|
|
use stdClass; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Class ArgumentTest |
24
|
|
|
* @coversDefaultClass \phpDocumentor\Reflection\Php\Factory\Argument |
25
|
|
|
* @covers ::__construct |
26
|
|
|
* @covers ::<!public> |
27
|
|
|
*/ |
28
|
|
|
class ArgumentTest extends TestCase |
29
|
|
|
{ |
30
|
|
|
protected function setUp() |
31
|
|
|
{ |
32
|
|
|
$this->fixture = new Argument(new PrettyPrinter()); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
protected function tearDown() |
36
|
|
|
{ |
37
|
|
|
m::close(); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @covers ::matches |
42
|
|
|
*/ |
43
|
|
|
public function testMatches() |
44
|
|
|
{ |
45
|
|
|
$this->assertFalse($this->fixture->matches(new stdClass())); |
46
|
|
|
$this->assertTrue($this->fixture->matches(m::mock(Param::class))); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @covers ::create |
51
|
|
|
*/ |
52
|
|
|
public function testCreate() |
53
|
|
|
{ |
54
|
|
|
$factory = new ProjectFactoryStrategies(array()); |
55
|
|
|
|
56
|
|
|
$argMock = m::mock(Param::class); |
57
|
|
|
$argMock->name = 'myArgument'; |
58
|
|
|
$argMock->default = new String_('MyDefault'); |
59
|
|
|
$argMock->byRef = true; |
60
|
|
|
$argMock->variadic = true; |
61
|
|
|
|
62
|
|
|
$argument = $this->fixture->create($argMock, $factory); |
63
|
|
|
|
64
|
|
|
$this->assertInstanceOf(ArgumentDescriptor::class, $argument); |
65
|
|
|
$this->assertEquals('myArgument', $argument->getName()); |
66
|
|
|
$this->assertTrue($argument->isByReference()); |
67
|
|
|
$this->assertTrue($argument->isVariadic()); |
68
|
|
|
$this->assertEquals('MyDefault', $argument->getDefault()); |
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|