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