Completed
Push — master ( c534b9...fcc0ff )
by Mahmoud
04:08
created

LogoutTest::testLogout_()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 6

Duplication

Lines 13
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 13
loc 13
rs 9.4285
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
namespace App\Containers\ApiAuthentication\UI\API\Tests\Functional;
4
5
use App\Port\Tests\PHPUnit\Abstracts\TestCase;
6
7
/**
8
 * Class LogoutEndpointTest.
9
 *
10
 * @author Mahmoud Zalt <[email protected]>
11
 */
12
class LogoutTest extends TestCase
13
{
14
15
    private $endpoint = '/logout';
16
17 View Code Duplication
    public function testLogout_()
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...
18
    {
19
        // send the HTTP request
20
        $response = $this->apiCall($this->endpoint, 'post');
21
22
        // assert response status is correct
23
        $this->assertEquals($response->getStatusCode(), '202');
24
25
        // assert message is correct
26
        $this->assertResponseContainKeyValue([
27
            'message' => 'User Logged Out Successfully.',
28
        ], $response);
29
    }
30
31 View Code Duplication
    public function testLogoutWithGetRequest()
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...
32
    {
33
        // send the HTTP request
34
        $response = $this->apiCall($this->endpoint, 'get');
35
36
        // assert response status is correct
37
        $this->assertEquals($response->getStatusCode(), '405');
38
39
        // assert message is correct
40
        $this->assertResponseContainKeyValue([
41
            'message' => '405 Method Not Allowed',
42
        ], $response);
43
    }
44
45 View Code Duplication
    public function testLogoutWithoutToken()
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...
46
    {
47
        // send the HTTP request
48
        $response = $this->apiCall($this->endpoint, 'post', [], false);
49
50
        // assert response status is correct
51
        $this->assertEquals($response->getStatusCode(), '401');
52
53
        // assert message is correct
54
        $this->assertResponseContainKeyValue([
55
            'message' => 'Failed to authenticate because of bad credentials or an invalid authorization header.',
56
        ], $response);
57
    }
58
}
59