CommandIntegration::unauthorized()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 9.6
c 0
b 0
f 0
cc 1
nc 1
nop 0
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