1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of CaptainHook |
5
|
|
|
* |
6
|
|
|
* (c) Sebastian Feldmann <[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 CaptainHook\App\Console; |
13
|
|
|
|
14
|
|
|
use PHPUnit\Framework\TestCase; |
15
|
|
|
use Symfony\Component\Console\Input\ArrayInput; |
16
|
|
|
use Symfony\Component\Console\Output\NullOutput; |
17
|
|
|
|
18
|
|
|
class ApplicationTest extends TestCase |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* Tests Cli::run |
22
|
|
|
* |
23
|
|
|
* @throws \Exception |
24
|
|
|
*/ |
25
|
|
|
public function testVersionOutput(): void |
26
|
|
|
{ |
27
|
|
|
$input = new ArrayInput(['--version' => true]); |
28
|
|
|
$output = $this->getMockBuilder(NullOutput::class) |
29
|
|
|
->disableOriginalConstructor() |
30
|
|
|
->getMock(); |
31
|
|
|
|
32
|
|
|
$output->expects($this->once())->method('writeLn'); |
33
|
|
|
|
34
|
|
|
|
35
|
|
|
$app = new Application('captainhook'); |
36
|
|
|
$app->setAutoExit(false); |
37
|
|
|
$app->run($input, $output); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Tests Cli::run |
43
|
|
|
* |
44
|
|
|
* @throws \Exception |
45
|
|
|
*/ |
46
|
|
|
public function testExecuteDefaultHelp(): void |
47
|
|
|
{ |
48
|
|
|
$input = new ArrayInput(['--help' => true]); |
49
|
|
|
$output = $this->getMockBuilder(NullOutput::class) |
50
|
|
|
->disableOriginalConstructor() |
51
|
|
|
->getMock(); |
52
|
|
|
|
53
|
|
|
$app = new Application('captainhook'); |
54
|
|
|
$app->setAutoExit(false); |
55
|
|
|
|
56
|
|
|
$this->assertEquals(0, $app->run($input, $output)); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Tests Cli::run |
61
|
|
|
* |
62
|
|
|
* @throws \Exception |
63
|
|
|
*/ |
64
|
|
|
public function testExecuteList(): void |
65
|
|
|
{ |
66
|
|
|
$input = new ArrayInput(['command' => 'list']); |
67
|
|
|
$output = $this->getMockBuilder(NullOutput::class) |
68
|
|
|
->disableOriginalConstructor() |
69
|
|
|
->getMock(); |
70
|
|
|
|
71
|
|
|
$app = new Application('captainhook'); |
72
|
|
|
$app->setAutoExit(false); |
73
|
|
|
|
74
|
|
|
$this->assertEquals(0, $app->run($input, $output)); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|