InitCommandTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
cbo 4
dl 0
loc 22
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testExecute() 0 11 1
A tearDown() 0 7 2
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 InitCommandTest extends TestCase
13
{
14
    public function testExecute()
15
    {
16
        $application = new Application();
17
        $commandTester = new CommandTester($command = $application->get('init'));
18
        $commandTester->execute(['command' => $command->getName()], ['interactive' => false, 'decorated' => false]);
19
20
        $json = json_decode(file_get_contents(getcwd() . '/bower.json'), true);
21
        $this->assertArrayHasKey('name', $json);
22
        $this->assertArrayHasKey('authors', $json);
23
        $this->assertArrayHasKey('dependencies', $json);
24
    }
25
26
    protected function tearDown()
27
    {
28
        $file = getcwd() . '/bower.json';
29
        if (is_file($file)) {
30
            unlink($file);
31
        }
32
    }
33
}
34