TestCaseUserController::testPatchUserById()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 11
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
3
namespace Tests;
4
5
use PHPUnit\Framework\TestCase;
6
use Preetender\Routing\Testing\HttpInteraction;
7
8
/**
9
 * Class TestCaseUserController
10
 * @package Tests
11
 */
12
class TestCaseUserController extends TestCase
13
{
14
    use HttpInteraction;
15
16
    /**
17
     * @inheritdoc
18
     */
19 View Code Duplication
    public function testListUsers()
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...
20
    {
21
        $http = $this->http->get('users');
22
        $output = $http->getBody()->getContents();
23
        $this->assertEquals(200, $http->getStatusCode());
24
        $this->assertEquals('list all users', $output);
25
    }
26
27
    /**
28
     * @inheritdoc
29
     */
30 View Code Duplication
    public function testUserById()
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...
31
    {
32
        $http = $this->http->get('users/1');
33
        $output = $http->getBody()->getContents();
34
        $this->assertEquals(200, $http->getStatusCode());
35
        $this->assertEquals('show user by id 1', $output);
36
    }
37
38
    /**
39
     * @inheritdoc
40
     */
41 View Code Duplication
    public function testCreateUserView()
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...
42
    {
43
       $http = $this->http->get('users/create');
44
       $output = $http->getBody()->getContents();
45
       $this->assertEquals(200, $http->getStatusCode());
46
       $this->assertEquals('view create user', $output);
47
    }
48
49
    /**
50
     * @inheritdoc
51
     */
52
    public function testStoreUser()
53
    {
54
        $http = $this->http->post('users', [
55
            'form_params' => [
56
                'name' => 'test',
57
                'email' => '[email protected]'
58
            ]
59
        ]);
60
        $this->assertEquals(201, $http->getStatusCode());
61
    }
62
63
    /**
64
     * @inheritdoc
65
     */
66
    public function testPatchUserById()
67
    {
68
        $http = $this->http->patch('users/edit/1', [
69
            'form_params' => [
70
                'name' => 'test'
71
            ]
72
        ]);
73
        $output = $http->getBody()->getContents();
74
        $this->assertEquals(200, $http->getStatusCode());
75
        $this->assertEquals('{"body":"update part of user 1","data":{"name":"test"}}', $output);
76
    }
77
78
    /**
79
     * @inheritdoc
80
     */
81 View Code Duplication
    public function testDeleteUserById()
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...
82
    {
83
        $http = $this->http->delete('users/1');
84
        $output = $http->getBody()->getContents();
85
        $this->assertEquals(200, $http->getStatusCode());
86
        $this->assertEquals('delete user by id 1', $output);
87
    }
88
}