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 ListCommandTest extends TestCase |
13
|
|
|
{ |
14
|
|
|
protected function setUp() |
15
|
|
|
{ |
16
|
|
|
if (!is_dir(getcwd() . '/bower_components/')) { |
17
|
|
|
mkdir(getcwd() . '/bower_components/'); |
18
|
|
|
} |
19
|
|
|
mkdir(getcwd() . '/bower_components/bootstrap/'); |
20
|
|
|
mkdir(getcwd() . '/bower_components/jquery/'); |
21
|
|
|
file_put_contents(getcwd() . '/bower.json', '{"name":"project","requirements":{"jquery":"*"}}'); |
22
|
|
|
file_put_contents(getcwd() . '/bower_components/bootstrap/.bower.json', '{"name":"bootstrap","version":"3"}'); |
23
|
|
|
file_put_contents(getcwd() . '/bower_components/jquery/.bower.json', '{"name":"jquery","version":"1"}'); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function testExecute() |
27
|
|
|
{ |
28
|
|
|
$application = new Application(); |
29
|
|
|
$commandTester = new CommandTester($command = $application->get('list')); |
30
|
|
|
$commandTester->execute(['command' => $command->getName()], ['decorated' => false]); |
31
|
|
|
$this->assertRegExp('/bootstrap#3 extraneous/', $commandTester->getDisplay()); |
32
|
|
|
$this->assertRegExp('/jquery#1/', $commandTester->getDisplay()); // TODO check is NOT extraneous |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
protected function tearDown() |
36
|
|
|
{ |
37
|
|
|
unlink(getcwd() . '/bower.json'); |
38
|
|
|
unlink(getcwd() . '/bower_components/bootstrap/.bower.json'); |
39
|
|
|
unlink(getcwd() . '/bower_components/jquery/.bower.json'); |
40
|
|
|
rmdir(getcwd() . '/bower_components/bootstrap/'); |
41
|
|
|
rmdir(getcwd() . '/bower_components/jquery/'); |
42
|
|
|
rmdir(getcwd() . '/bower_components/'); |
43
|
|
|
} |
44
|
|
|
} |
45
|
|
|
|