1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Bowerphp\Test\Command; |
4
|
|
|
|
5
|
|
|
use Bowerphp\Console\Application; |
6
|
|
|
use PHPUnit\Framework\TestCase; |
7
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
8
|
|
|
use Symfony\Component\Console\Tester\CommandTester; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @group functional |
12
|
|
|
*/ |
13
|
|
|
class HomeCommandTest extends TestCase |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @expectedException \RuntimeException |
17
|
|
|
*/ |
18
|
|
|
public function testExecuteNotFound() |
19
|
|
|
{ |
20
|
|
|
$application = new Application(); |
21
|
|
|
$commandTester = new CommandTester($command = $application->get('home')); |
22
|
|
|
$commandTester->execute(['command' => $command->getName(), 'package' => 'nonexistante'], ['decorated' => false]); |
23
|
|
|
$this->assertRegExp('/zzzz/', $commandTester->getDisplay()); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function testExecuteVerbose() |
27
|
|
|
{ |
28
|
|
|
$application = new Application(); |
29
|
|
|
$commandTester = new CommandTester($command = $application->get('home')); |
30
|
|
|
$commandTester->execute(['command' => $command->getName(), 'package' => 'jquery'], ['decorated' => false, 'verbosity' => OutputInterface::VERBOSITY_DEBUG]); |
31
|
|
|
$this->assertRegExp('/"name":"jquery"/', $commandTester->getDisplay()); |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function testExecuteNonVerbose() |
35
|
|
|
{ |
36
|
|
|
$application = new Application(); |
37
|
|
|
$commandTester = new CommandTester($command = $application->get('home')); |
38
|
|
|
$commandTester->execute(['command' => $command->getName(), 'package' => 'jquery'], ['decorated' => false, 'verbosity' => OutputInterface::VERBOSITY_NORMAL]); |
39
|
|
|
$this->assertRegExp('/\s/', $commandTester->getDisplay()); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @expectedException \RuntimeException |
44
|
|
|
* @expectedExceptionMessage Not enough arguments |
45
|
|
|
*/ |
46
|
|
|
public function testExecuteWithoutPackage() |
47
|
|
|
{ |
48
|
|
|
$application = new Application(); |
49
|
|
|
$commandTester = new CommandTester($command = $application->get('home')); |
50
|
|
|
$commandTester->execute([], ['decorated' => false]); |
51
|
|
|
$this->assertRegExp('/zzzz/', $commandTester->getDisplay()); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|