HomeCommandTest::testExecuteNonVerbose()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
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