Completed
Pull Request — master (#26)
by Stepan
05:53
created

VersionsCommandTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testConfigure() 0 5 1
A testExecute() 0 15 2
A testExecuteWithPackage() 0 14 1
1
<?php
2
3
namespace PackageVersionsTest;
4
5
use PackageVersions\Versions;
6
use PackageVersions\VersionsCommand;
7
use Symfony\Component\Console\Application;
8
use Symfony\Component\Console\Tester\CommandTester;
9
10
/**
11
 * Class VersionsCommandTest
12
 */
13
class VersionsCommandTest extends \PHPUnit_Framework_TestCase
14
{
15
    public function testConfigure()
16
    {
17
        $command = new VersionsCommand();
18
        static::assertEquals('versions', $command->getName());
19
    }
20
21
    public function testExecute()
22
    {
23
        $application = new Application();
24
        $application->add(new VersionsCommand());
25
26
        $command = $application->find('versions');
27
        $commandTester = new CommandTester($command);
28
        $commandTester->execute(array('command' => $command->getName()));
29
        $display = $commandTester->getDisplay();
30
31
        foreach (Versions::VERSIONS as $packageName => $version) {
32
            list($version, ) = explode('@', $version);
33
            static::assertContains($packageName.': '.$version, $display);
34
        }
35
    }
36
37
    public function testExecuteWithPackage()
38
    {
39
        $application = new Application();
40
        $application->add(new VersionsCommand());
41
42
        $command = $application->find('versions');
43
        $commandTester = new CommandTester($command);
44
        $commandTester->execute(array('command' => $command->getName(), 'package' => 'ocramius/package-versions'));
45
46
        list($version, ) = explode('@', Versions::VERSIONS['ocramius/package-versions']);
47
48
        static::assertContains('ocramius/package-versions', $commandTester->getDisplay());
49
        static::assertContains($version, $commandTester->getDisplay());
50
    }
51
}
52