|
1
|
|
|
<?php |
|
2
|
|
|
namespace Naneau\FileGen\Test\Parameter; |
|
3
|
|
|
|
|
4
|
|
|
use Naneau\FileGen\Parameter\Set as ParameterSet; |
|
5
|
|
|
use Naneau\FileGen\Parameter\Parameter; |
|
6
|
|
|
|
|
7
|
|
|
class ParameterTest extends \PHPUnit\Framework\TestCase |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* Test description constructor |
|
11
|
|
|
* |
|
12
|
|
|
* @return void |
|
13
|
|
|
**/ |
|
14
|
|
|
public function testConstructDescription() |
|
15
|
|
|
{ |
|
16
|
|
|
$param = new Parameter('foo', 'bar'); |
|
17
|
|
|
$this->assertEquals( |
|
18
|
|
|
'foo', |
|
19
|
|
|
$param->getName() |
|
20
|
|
|
); |
|
21
|
|
|
$this->assertEquals( |
|
22
|
|
|
'bar', |
|
23
|
|
|
$param->getDescription() |
|
24
|
|
|
); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* no description given test |
|
29
|
|
|
* |
|
30
|
|
|
* @return void |
|
31
|
|
|
**/ |
|
32
|
|
|
public function testConstructWithoutDescription() |
|
33
|
|
|
{ |
|
34
|
|
|
$param = new Parameter('foo'); |
|
35
|
|
|
$this->assertEquals('foo', $param->getName()); |
|
36
|
|
|
$this->assertEquals('foo', $param->getDescription()); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* No default value |
|
41
|
|
|
* |
|
42
|
|
|
* @return void |
|
43
|
|
|
**/ |
|
44
|
|
|
public function testNoDefaultValue() |
|
45
|
|
|
{ |
|
46
|
|
|
$param = new Parameter('foo'); |
|
47
|
|
|
$this->assertFalse($param->hasDefaultValue()); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Default value |
|
52
|
|
|
* |
|
53
|
|
|
* @return void |
|
54
|
|
|
**/ |
|
55
|
|
|
public function testDefaultValue() |
|
56
|
|
|
{ |
|
57
|
|
|
$param = new Parameter('foo'); |
|
58
|
|
|
$param->setDefaultValue('bar'); |
|
59
|
|
|
|
|
60
|
|
|
$this->assertTrue($param->hasDefaultValue()); |
|
61
|
|
|
$this->assertEquals('bar', $param->getDefaultValue()); |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* Default value `null` |
|
66
|
|
|
* |
|
67
|
|
|
* @return void |
|
68
|
|
|
**/ |
|
69
|
|
|
public function testNullValue() |
|
70
|
|
|
{ |
|
71
|
|
|
$param = new Parameter('foo'); |
|
72
|
|
|
$param->setDefaultValue(null); |
|
73
|
|
|
|
|
74
|
|
|
$this->assertTrue($param->hasDefaultValue()); |
|
75
|
|
|
$this->assertEquals(null, $param->getDefaultValue()); |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|