|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Bowerphp\Test\Command; |
|
4
|
|
|
|
|
5
|
|
|
use Bowerphp\Console\Application; |
|
6
|
|
|
use PHPUnit\Framework\TestCase; |
|
7
|
|
|
use Symfony\Component\Console\Tester\ApplicationTester; |
|
8
|
|
|
use Symfony\Component\Console\Tester\CommandTester; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* @group functional |
|
12
|
|
|
*/ |
|
13
|
|
|
class CommandListCommandTest extends TestCase |
|
14
|
|
|
{ |
|
15
|
|
|
public function testExecute() |
|
16
|
|
|
{ |
|
17
|
|
|
$application = new Application(); |
|
18
|
|
|
$commandTester = new CommandTester($command = $application->get('list-commands')); |
|
19
|
|
|
$commandTester->execute(['command' => $command->getName()], ['decorated' => false]); |
|
20
|
|
|
|
|
21
|
|
|
$this->assertRegExp('/Available commands/', $commandTester->getDisplay()); |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
public function testProfile() |
|
25
|
|
|
{ |
|
26
|
|
|
$application = new Application(); |
|
27
|
|
|
$application->setAutoExit(false); |
|
28
|
|
|
$application->setCatchExceptions(false); |
|
29
|
|
|
|
|
30
|
|
|
$tester = new ApplicationTester($application); |
|
31
|
|
|
$tester->run(['-d' => '/', '--profile' => ''], ['decorated' => false]); |
|
32
|
|
|
$this->assertRegExp('/Memory usage/', $tester->getDisplay()); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
public function testWorkingDir() |
|
36
|
|
|
{ |
|
37
|
|
|
$application = new Application(); |
|
38
|
|
|
$application->setAutoExit(false); |
|
39
|
|
|
$application->setCatchExceptions(false); |
|
40
|
|
|
|
|
41
|
|
|
$tester = new ApplicationTester($application); |
|
42
|
|
|
$tester->run(['-d' => '/'], ['decorated' => false]); |
|
43
|
|
|
$this->assertRegExp('/Usage/', $tester->getDisplay()); |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @expectedException \RuntimeException |
|
48
|
|
|
* @expectedExceptionMessage Invalid working directory specified. |
|
49
|
|
|
*/ |
|
50
|
|
|
public function testWrongWorkingDir() |
|
51
|
|
|
{ |
|
52
|
|
|
$application = new Application(); |
|
53
|
|
|
$application->setAutoExit(false); |
|
54
|
|
|
$application->setCatchExceptions(false); |
|
55
|
|
|
|
|
56
|
|
|
$tester = new ApplicationTester($application); |
|
57
|
|
|
$tester->run(['-d' => '/thisDirDoesNotExist'], ['decorated' => false]); |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|