1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of Fabrica. |
5
|
|
|
* |
6
|
|
|
* (c) Alexandre Salomé <[email protected]> |
7
|
|
|
* (c) Julien DIDIER <[email protected]> |
8
|
|
|
* |
9
|
|
|
* This source file is subject to the GPL license that is bundled |
10
|
|
|
* with this source code in the file LICENSE. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace Fabrica\Bundle\CoreBundle\Tests\Command; |
14
|
|
|
|
15
|
|
|
use Fabrica\Bundle\CoreBundle\Test\CommandTestCase; |
16
|
|
|
|
17
|
|
|
class ConfigShowCommandTest extends CommandTestCase |
18
|
|
|
{ |
19
|
|
|
protected $client; |
20
|
|
|
|
21
|
|
|
protected function setUp(): void |
22
|
|
|
{ |
23
|
|
|
$this->client = self::createClient(); |
24
|
|
|
$this->client->startIsolation(); |
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public function tearDown(): void |
28
|
|
|
{ |
29
|
|
|
$this->client->stopIsolation(); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function testNoParameter() |
33
|
|
|
{ |
34
|
|
|
list($statusCode ,$output) = $this->runCommand($this->client, "fabrica:config:show"); |
|
|
|
|
35
|
|
|
|
36
|
|
|
$this->assertContains('repository_path '.$this->getRepositoryPath(), $output); |
37
|
|
|
$this->assertRegexp('/\n$/', $output, 'Ends with an empty line'); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function testCorrectParameter() |
41
|
|
|
{ |
42
|
|
|
list($statusCode ,$output) = $this->runCommand($this->client, "fabrica:config:show repository_path"); |
|
|
|
|
43
|
|
|
|
44
|
|
|
$this->assertEquals($this->getRepositoryPath()."\n", $output); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function testIncorrectParameter() |
48
|
|
|
{ |
49
|
|
|
list($statusCode ,$output) = $this->runCommand($this->client, "fabrica:config:show foobarbaz"); |
|
|
|
|
50
|
|
|
|
51
|
|
|
$this->assertNotEquals(0, $statusCode); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
private function getRepositoryPath() |
55
|
|
|
{ |
56
|
|
|
return self::createClient()->getKernel()->getContainer()->getParameter('repository_path'); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
This checks looks for assignemnts to variables using the
list(...)
function, where not all assigned variables are subsequently used.Consider the following code example.
Only the variables
$a
and$c
are used. There was no need to assign$b
.Instead, the list call could have been.