CommandIntegration   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 5
dl 0
loc 42
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A unauthorized() 0 20 1
A success() 0 16 1
1
<?php
2
3
namespace DeGraciaMathieu\Clike\Tests;
4
5
use Mockery;
6
use PHPUnit\Framework\TestCase;
7
use DeGraciaMathieu\Clike\Command;
8
9
class CommandIntegration extends TestCase {
10
11
    /** @test */
12
    public function success()
13
    {
14
        $command = new Command();
15
16
        $result = $command->execute(new Clear());
17
18
        $expectedArray = [
19
            [
20
                'type' => 'info',
21
                'content' => 'Output text...',
22
            ]
23
        ];
24
25
        $this->assertNotNull($result['timestamp']);
26
        $this->assertEquals($expectedArray, $result['lines']);
27
    }
28
29
    /** @test */
30
    public function unauthorized()
31
    {
32
        $command = new Command();
33
34
        $clear = Mockery::mock(new Clear())->makePartial();
35
36
        $clear->shouldReceive('authorized')->andReturn(false);
37
38
        $result = $command->execute($clear);
39
40
        $expectedArray = [
41
            [
42
                'type' => 'error',
43
                'content' => '/clear is an unauthorized command.',
44
            ]
45
        ];
46
47
        $this->assertNotNull($result['timestamp']);
48
        $this->assertEquals($expectedArray, $result['lines']);
49
    }
50
}
51