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-2018 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\Reflection\Php; |
14
|
|
|
|
15
|
|
|
use phpDocumentor\Reflection\Types\Mixed_; |
16
|
|
|
use phpDocumentor\Reflection\Types\String_; |
17
|
|
|
use PHPUnit\Framework\TestCase; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Tests the functionality for the Argument class. |
21
|
|
|
* @coversDefaultClass \phpDocumentor\Reflection\Php\Argument |
22
|
|
|
*/ |
23
|
|
|
class ArgumentTest extends TestCase |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* @covers ::getType |
27
|
|
|
*/ |
28
|
|
|
public function testGetTypes() |
29
|
|
|
{ |
30
|
|
|
$argument = new Argument('myArgument', null, 'myDefaultValue', true, true); |
31
|
|
|
$this->assertInstanceOf(Mixed_::class, $argument->getType()); |
32
|
|
|
|
33
|
|
|
$argument = new Argument( |
34
|
|
|
'myArgument', |
35
|
|
|
new String_(), |
36
|
|
|
'myDefaultValue', |
37
|
|
|
true, |
38
|
|
|
true |
39
|
|
|
); |
40
|
|
|
$this->assertEquals(new String_(), $argument->getType()); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @covers ::__construct |
45
|
|
|
* @covers ::getName |
46
|
|
|
*/ |
47
|
|
|
public function testGetName() |
48
|
|
|
{ |
49
|
|
|
$argument = new Argument('myArgument', null, true, true); |
50
|
|
|
$this->assertEquals('myArgument', $argument->getName()); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @covers ::__construct |
55
|
|
|
* @covers ::getDefault |
56
|
|
|
*/ |
57
|
|
|
public function testGetDefault() |
58
|
|
|
{ |
59
|
|
|
$argument = new Argument('myArgument', null, 'myDefaultValue', true, true); |
60
|
|
|
$this->assertEquals('myDefaultValue', $argument->getDefault()); |
61
|
|
|
|
62
|
|
|
$argument = new Argument('myArgument', null, null, true, true); |
63
|
|
|
$this->assertNull($argument->getDefault()); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @covers ::__construct |
68
|
|
|
* @covers ::isByReference |
69
|
|
|
*/ |
70
|
|
|
public function testGetWhetherArgumentIsPassedByReference() |
71
|
|
|
{ |
72
|
|
|
$argument = new Argument('myArgument', null, 'myDefaultValue', true, true); |
73
|
|
|
$this->assertTrue($argument->isByReference()); |
74
|
|
|
|
75
|
|
|
$argument = new Argument('myArgument', null, null, false, true); |
76
|
|
|
$this->assertFalse($argument->isByReference()); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @covers ::__construct |
81
|
|
|
* @covers ::isVariadic |
82
|
|
|
*/ |
83
|
|
|
public function testGetWhetherArgumentisVariadic() |
84
|
|
|
{ |
85
|
|
|
$argument = new Argument('myArgument', null, 'myDefaultValue', true, true); |
86
|
|
|
$this->assertTrue($argument->isVariadic()); |
87
|
|
|
|
88
|
|
|
$argument = new Argument('myArgument', null, 'myDefaultValue', true, false); |
89
|
|
|
$this->assertFalse($argument->isVariadic()); |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|