|
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
|
|
|
|