/
ArgumentsTest.php
98 lines (92 loc) · 2.88 KB
/
ArgumentsTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
/**
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
* @link https://cakephp.org CakePHP(tm) Project
* @since 3.6.0
* @license https://opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Test\TestSuite\Console;
use Cake\Console\Arguments;
use Cake\TestSuite\TestCase;
/**
* Arguments test case.
*/
class ArgumentsTest extends TestCase
{
/**
* Get all arguments
*
* @return void
*/
public function testGetArguments()
{
$values = ['big', 'brown', 'bear'];
$args = new Arguments($values, [], []);
$this->assertSame($values, $args->getArguments());
}
/**
* Get arguments by index
*
* @return void
*/
public function testGetArgumentAt()
{
$values = ['big', 'brown', 'bear'];
$args = new Arguments($values, [], []);
$this->assertSame($values[0], $args->getArgumentAt(0));
$this->assertSame($values[1], $args->getArgumentAt(1));
$this->assertNull($args->getArgumentAt(3));
}
/**
* check arguments by index
*
* @return void
*/
public function testHasArgumentAt()
{
$values = ['big', 'brown', 'bear'];
$args = new Arguments($values, [], []);
$this->assertTrue($args->hasArgumentAt(0));
$this->assertTrue($args->hasArgumentAt(1));
$this->assertFalse($args->hasArgumentAt(3));
$this->assertFalse($args->hasArgumentAt(-1));
}
/**
* check arguments by name
*
* @return void
*/
public function testHasArgument()
{
$values = ['big', 'brown', 'bear'];
$names = ['size', 'color', 'species', 'odd'];
$args = new Arguments($values, [], $names);
$this->assertTrue($args->hasArgument('size'));
$this->assertTrue($args->hasArgument('color'));
$this->assertFalse($args->hasArgument('hair'));
$this->assertFalse($args->hasArgument('Hair'), 'casing matters');
$this->assertFalse($args->hasArgument('odd'));
}
/**
* get arguments by name
*
* @return void
*/
public function testGetArgument()
{
$values = ['big', 'brown', 'bear'];
$names = ['size', 'color', 'species', 'odd'];
$args = new Arguments($values, [], $names);
$this->assertSame($values[0], $args->getArgument('size'));
$this->assertSame($values[1], $args->getArgument('color'));
$this->assertNull($args->getArgument('Color'));
$this->assertNull($args->getArgument('hair'));
}
}