|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the core-bundle package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) 2018 WEBEWEB |
|
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 WBW\Bundle\CoreBundle\Tests\Command; |
|
13
|
|
|
|
|
14
|
|
|
use Symfony\Bundle\FrameworkBundle\Console\Application; |
|
15
|
|
|
use Symfony\Component\Console\Helper\HelperSet; |
|
16
|
|
|
use Symfony\Component\Console\Style\StyleInterface; |
|
17
|
|
|
use WBW\Bundle\CoreBundle\Tests\AbstractCommandTestCase; |
|
18
|
|
|
use WBW\Bundle\CoreBundle\Tests\Fixtures\Command\TestAbstractCommand; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Abstract command test. |
|
22
|
|
|
* |
|
23
|
|
|
* @author webeweb <https://github.com/webeweb> |
|
24
|
|
|
* @package WBW\Bundle\CoreBundle\Tests\Command |
|
25
|
|
|
*/ |
|
26
|
|
|
class AbstractCommandTest extends AbstractCommandTestCase { |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Test displayHeader() |
|
30
|
|
|
* |
|
31
|
|
|
* @return void |
|
32
|
|
|
*/ |
|
33
|
|
|
public function testDisplayHeader(): void { |
|
34
|
|
|
|
|
35
|
|
|
$obj = new TestAbstractCommand(); |
|
36
|
|
|
|
|
37
|
|
|
$this->assertNull($obj->displayHeader($this->style, "")); |
|
|
|
|
|
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Test displayTitle() |
|
42
|
|
|
* |
|
43
|
|
|
* @return void |
|
44
|
|
|
*/ |
|
45
|
|
|
public function testDisplayTitle(): void { |
|
46
|
|
|
|
|
47
|
|
|
$obj = new TestAbstractCommand(); |
|
48
|
|
|
|
|
49
|
|
|
$this->assertNull($obj->displayTitle($this->style, "")); |
|
|
|
|
|
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Test getCheckbox() |
|
54
|
|
|
* |
|
55
|
|
|
* @return void |
|
56
|
|
|
*/ |
|
57
|
|
|
public function testGetCheckbox(): void { |
|
58
|
|
|
|
|
59
|
|
|
$obj = new TestAbstractCommand(); |
|
60
|
|
|
|
|
61
|
|
|
// Determines the operating system. |
|
62
|
|
|
if ("\\" !== DIRECTORY_SEPARATOR) { |
|
63
|
|
|
|
|
64
|
|
|
$this->assertEquals("<fg=green;options=bold>\xE2\x9C\x94</>", $obj->getCheckbox(true)); |
|
65
|
|
|
$this->assertEquals("<fg=yellow;options=bold>!</>", $obj->getCheckbox(false)); |
|
66
|
|
|
} else { |
|
67
|
|
|
|
|
68
|
|
|
$this->assertEquals("<fg=green;options=bold>OK</>", $obj->getCheckbox(true)); |
|
69
|
|
|
$this->assertEquals("<fg=yellow;options=bold>WARNING</>", $obj->getCheckbox(false)); |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* Test getKernel() |
|
75
|
|
|
* |
|
76
|
|
|
* @return void |
|
77
|
|
|
*/ |
|
78
|
|
|
public function testGetKernel(): void { |
|
79
|
|
|
|
|
80
|
|
|
// Set a Helper set mock. |
|
81
|
|
|
$helperSet = $this->getMockBuilder(HelperSet::class)->disableOriginalConstructor()->getMock(); |
|
82
|
|
|
|
|
83
|
|
|
// Set an Application mock. |
|
84
|
|
|
$application = $this->getMockBuilder(Application::class)->disableOriginalConstructor()->getMock(); |
|
85
|
|
|
$application->expects($this->any())->method("getHelperSet")->willReturn($helperSet); |
|
86
|
|
|
$application->expects($this->any())->method("getKernel")->willReturn($this->kernel); |
|
87
|
|
|
|
|
88
|
|
|
$obj = new TestAbstractCommand(); |
|
89
|
|
|
$obj->setApplication($application); |
|
90
|
|
|
|
|
91
|
|
|
$this->assertSame($this->kernel, $obj->getKernel()); |
|
92
|
|
|
} |
|
93
|
|
|
|
|
94
|
|
|
/** |
|
95
|
|
|
* Test newStyle() |
|
96
|
|
|
* |
|
97
|
|
|
* @return void |
|
98
|
|
|
*/ |
|
99
|
|
|
public function testNewStyle(): void { |
|
100
|
|
|
|
|
101
|
|
|
$obj = new TestAbstractCommand(); |
|
102
|
|
|
|
|
103
|
|
|
$res = $obj->newStyle($this->input, $this->output); |
|
104
|
|
|
$this->assertInstanceOf(StyleInterface::class, $res); |
|
105
|
|
|
|
|
106
|
|
|
$this->assertNotNull($res); |
|
107
|
|
|
} |
|
108
|
|
|
} |
|
109
|
|
|
|
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.