Completed
Push — master ( 1a146d...3fc9a0 )
by Tobias
35s queued 17s
created

ErrorTest::testNotFound()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Tests\Unit\Model;
6
7
use Happyr\JsonApiResponseFactory\Model\Error;
8
use PHPUnit\Framework\TestCase;
9
10
/**
11
 * @author Radoje Albijanic <[email protected]>
12
 */
13
class ErrorTest extends TestCase
14
{
15
    public function testError(): void
16
    {
17
        $error = Error::error('someTitle', 400);
18
        self::assertEquals(
19
            [
20
                'status' => 400,
21
                'title' => 'someTitle'
22
            ],
23
            $error->getErrorData()
24
        );
25
    }
26
27 View Code Duplication
    public function testServerError(): void
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
28
    {
29
        $error = Error::serverError('someTitle');
30
        self::assertEquals(
31
            [
32
                'status' => 500,
33
                'title' => 'someTitle'
34
            ],
35
            $error->getErrorData()
36
        );
37
    }
38
39 View Code Duplication
    public function testForbidden(): void
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
40
    {
41
        $error = Error::forbidden('someTitle');
42
        self::assertEquals(
43
            [
44
                'status' => 403,
45
                'title' => 'someTitle'
46
            ],
47
            $error->getErrorData()
48
        );
49
    }
50
51 View Code Duplication
    public function testNotFound(): void
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
52
    {
53
        $error = Error::notFound('someTitle');
54
        self::assertEquals(
55
            [
56
                'status' => 404,
57
                'title' => 'someTitle'
58
            ],
59
            $error->getErrorData()
60
        );
61
    }
62
63 View Code Duplication
    public function testUnauthorized(): void
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
64
    {
65
        $error = Error::unauthorized('someTitle');
66
        self::assertEquals(
67
            [
68
                'status' => 401,
69
                'title' => 'someTitle'
70
            ],
71
            $error->getErrorData()
72
        );
73
    }
74
75 View Code Duplication
    public function testInvalid(): void
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
76
    {
77
        $error = Error::invalid('someTitle');
78
        self::assertEquals(
79
            [
80
                'status' => 400,
81
                'title' => 'someTitle'
82
            ],
83
            $error->getErrorData()
84
        );
85
    }
86
}
87