InfoCommandTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 4

Importance

Changes 0
Metric Value
wmc 5
cbo 4
dl 0
loc 54
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testExecute() 0 13 1
A testExecuteNoVersionsFound() 0 8 1
A testExecuteWithRenamedRepo() 0 8 1
A testExecuteWithSlashedVersion() 0 8 1
A testExecuteWithoutPackage() 0 6 1
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\CommandTester;
8
9
/**
10
 * @group functional
11
 */
12
class InfoCommandTest extends TestCase
13
{
14
    public function testExecute()
15
    {
16
        $application = new Application();
17
        $commandTester = new CommandTester($command = $application->get('info'));
18
        $commandTester->execute(['command' => $command->getName(), 'package' => 'colorbox'], ['decorated' => false]);
19
20
        $this->assertRegExp('/name: \'jquery-colorbox\'/', $commandTester->getDisplay());
21
        $this->assertRegExp('/Available versions:/', $commandTester->getDisplay());
22
23
        $commandTester->execute(['command' => $command->getName(), 'package' => 'colorbox', 'property' => 'main'], ['decorated' => false]);
24
25
        $this->assertEquals('"jquery.colorbox.js"' . PHP_EOL, $commandTester->getDisplay());
26
    }
27
28
    public function testExecuteNoVersionsFound()
29
    {
30
        $application = new Application();
31
        $commandTester = new CommandTester($command = $application->get('info'));
32
        $commandTester->execute(['command' => $command->getName(), 'package' => 'restio'], ['decorated' => false]);
33
34
        $this->assertRegExp('/No versions available/', $commandTester->getDisplay());
35
    }
36
37
    public function testExecuteWithRenamedRepo()
38
    {
39
        $application = new Application();
40
        $commandTester = new CommandTester($command = $application->get('info'));
41
        $commandTester->execute(['command' => $command->getName(), 'package' => 'jquery-hammerjs'], ['decorated' => false]);
42
43
        $this->assertRegExp('/jquery-hammerjs/', $commandTester->getDisplay());
44
    }
45
46
    public function testExecuteWithSlashedVersion()
47
    {
48
        $application = new Application();
49
        $commandTester = new CommandTester($command = $application->get('info'));
50
        $commandTester->execute(['command' => $command->getName(), 'package' => 'ckeditor#full/4.5.2'], ['decorated' => false]);
51
52
        $this->assertRegExp('/name: \'ckeditor\'/', $commandTester->getDisplay());
53
    }
54
55
    /**
56
     * @expectedException        \RuntimeException
57
     * @expectedExceptionMessage Not enough arguments
58
     */
59
    public function testExecuteWithoutPackage()
60
    {
61
        $application = new Application();
62
        $commandTester = new CommandTester($command = $application->get('info'));
63
        $commandTester->execute([], ['decorated' => false]);
64
    }
65
}
66