1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the CLIFramework package. |
5
|
|
|
* |
6
|
|
|
* (c) Arnaud VEBER <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace CLIFramework; |
13
|
|
|
|
14
|
|
|
use CLIFramework\Application; |
15
|
|
|
use CLIFramework\Kernel; |
16
|
|
|
|
17
|
|
|
class ApplicationTest extends \PHPUnit_Framework_TestCase |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* kernel. |
21
|
|
|
* |
22
|
|
|
* @var \CLIFramework\Kernel |
23
|
|
|
*/ |
24
|
|
|
private $kernel = null; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* set up |
28
|
|
|
*/ |
29
|
|
|
public function setUp() |
30
|
|
|
{ |
31
|
|
|
$this->kernel = new Kernel('dev', true); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* tear down |
36
|
|
|
*/ |
37
|
|
|
public function tearDown() |
38
|
|
|
{ |
39
|
|
|
$this->kernel = null; |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* test construct |
44
|
|
|
*/ |
45
|
|
|
public function testConstruct() |
46
|
|
|
{ |
47
|
|
|
// create application |
48
|
|
|
$application = new Application($this->kernel); |
49
|
|
|
|
50
|
|
|
// get definition |
51
|
|
|
$definition = $application->getDefinition(); |
52
|
|
|
|
53
|
|
|
// get options |
54
|
|
|
$options = $definition->getOptions(); |
55
|
|
|
|
56
|
|
|
// assert |
57
|
|
|
$this->assertTrue(in_array('env', array_keys($options))); |
58
|
|
|
$this->assertTrue(in_array('no-debug', array_keys($options))); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* test get kernel. |
63
|
|
|
*/ |
64
|
|
|
public function testGetKernel() |
65
|
|
|
{ |
66
|
|
|
// create application |
67
|
|
|
$application = new Application($this->kernel); |
68
|
|
|
|
69
|
|
|
// assert |
70
|
|
|
$this->assertEquals($this->kernel, $application->getKernel()); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* test do run |
75
|
|
|
*/ |
76
|
|
|
public function testDoRun() |
77
|
|
|
{ |
78
|
|
|
// create application |
79
|
|
|
$application = new Application($this->kernel); |
80
|
|
|
|
81
|
|
|
// create input & output |
82
|
|
|
$input = new \Symfony\Component\Console\Input\ArrayInput(array('command' => 'list')); |
|
|
|
|
83
|
|
|
$output = new \Symfony\Component\Console\Output\BufferedOutput(); |
84
|
|
|
|
85
|
|
|
// run command |
86
|
|
|
$code = $application->doRun($input, $output); |
87
|
|
|
|
88
|
|
|
// assert |
89
|
|
|
$this->assertEquals(0, $code); |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.