SearchCommandTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A shouldExecute() 0 9 1
A shouldWriteNoResultWhenNoPackageFound() 0 8 1
A shouldThrowExceptionWhenNoPackagePass() 0 5 1
1
<?php
2
3
namespace Bowerphp\Test\Command;
4
5
use Bowerphp\Factory\CommandFactory;
6
use PHPUnit\Framework\TestCase;
7
8
/**
9
 * @group functional
10
 */
11
class SearchCommandTest extends TestCase
12
{
13
    /**
14
     * @test
15
     */
16
    public function shouldExecute()
17
    {
18
        //when
19
        $commandTester = CommandFactory::tester('search', ['name' => 'smart']);
20
21
        //then
22
        $this->assertRegExp('/Search results/', $commandTester->getDisplay());
23
        $this->assertRegExp('/js-geo.git/', $commandTester->getDisplay());
24
    }
25
26
    /**
27
     * @test
28
     */
29
    public function shouldWriteNoResultWhenNoPackageFound()
30
    {
31
        //when
32
        $commandTester = CommandFactory::tester('search', ['name' => 'unexistant']);
33
34
        //then
35
        $this->assertRegExp('/No results/', $commandTester->getDisplay());
36
    }
37
38
    /**
39
     * @expectedException \RuntimeException
40
     * @expectedExceptionMessage Not enough arguments
41
     */
42
    public function shouldThrowExceptionWhenNoPackagePass()
43
    {
44
        //when
45
        CommandFactory::tester('search');
46
    }
47
}
48