GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 37b2fb...37b2fb )
by Danger
02:22
created

UserTest::testDeleteBadge()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 11

Duplication

Lines 18
Ratio 100 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 18
loc 18
rs 9.4285
cc 1
eloc 11
nc 1
nop 0
1
<?php
2
3
namespace Tests;
4
5
use Silex\WebTestCase;
6
use JsonSchema\Validator;
7
8
class UserTest extends WebTestCase
9
{
10
    use AbstractAppTest;
11
12 View Code Duplication
    public function testGetUser(){
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...
13
        $schema = __DIR__.'/../../../../api/schemas/userInfo.json';
14
15
        $client = $this->createClient();
16
        $client = $this->logIn($client);
17
18
        $crawler = $client->request('GET', '/api/v1/user/1');
0 ignored issues
show
Unused Code introduced by
$crawler is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
19
        $response = $client->getResponse();
0 ignored issues
show
Unused Code introduced by
$response is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
20
21
        //print_r($response);
22
        $data = $client->getResponse()->getContent();
23
        $validator = $this->askValidation($data, $schema);
24
25
        $assert = $this->evalValidation($validator);
26
        $this->assertTrue($assert);
27
    }
28
29
    public function testPostBadge(){
30
        $client = $this->createClient();
31
        $client = $this->logIn($client);
32
33
        $badge_id=5;
34
35
        $badge = '{
36
              "id": '.$badge_id.'
37
          }';
38
39
        $client->request(
40
            'POST',
41
            '/api/v1/user/1/badge',
42
            [],
43
            [],
44
            ['CONTENT_TYPE' => 'application/json'],
45
            $badge);
46
47
        $response = $client->getResponse();
48
        $this->assertEquals(200,$response->getStatusCode());
49
        return $badge_id;
50
    }
51
    public function testGetBadge(){
52
        $schema = __DIR__.'/../../../../api/schemas/badgeUser.json';
53
54
        $badge_id = $this->testPostBadge();
55
        $client = $this->createClient();
56
        $client = $this->logIn($client);
57
58
        $crawler = $client->request('GET', '/api/v1/user/1/badge/'.$badge_id);
0 ignored issues
show
Unused Code introduced by
$crawler is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
59
        $response = $client->getResponse();
0 ignored issues
show
Unused Code introduced by
$response is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
60
61
        //print_r($response);
62
        $data = $client->getResponse()->getContent();
63
64
        print_r($data);
65
        $validator = $this->askValidation($data, $schema);
66
67
        $assert = $this->evalValidation($validator);
68
        $this->assertTrue($assert);
69
    }
70
71 View Code Duplication
    public function testDeleteBadge(){
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...
72
        $client = $this->createClient();
73
        $client = $this->logIn($client);
74
75
        $badge_id = $this->testPostBadge();
76
77
        $client->request(
78
            'DELETE',
79
            '/api/v1/user/1/badge/'.$badge_id.'',
80
            [],
81
            [],
82
            [],
83
            '');
84
85
        $response = $client->getResponse();
86
        $this->assertEquals(204,$response->getStatusCode());
87
        return $badge_id;
88
    }
89
90 View Code Duplication
    public function testPostBadgeCompleted(){
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...
91
        $client = $this->createClient();
92
        $client = $this->logIn($client);
93
94
        $badge_id = $this->testPostBadge();
95
96
        $client->request(
97
            'PATCH',
98
            '/api/v1/user/1/badge/'.$badge_id.'/completed',
99
            [],
100
            [],
101
            [],
102
            '');
103
104
        $response = $client->getResponse();
105
        $this->assertEquals(204,$response->getStatusCode());
106
        return $badge_id;
107
    }
108
109 View Code Duplication
    public function testGetUserTicket(){
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...
110
        $schema = __DIR__.'/../../../../api/schemas/ticketList.json';
111
112
        $client = $this->createClient();
113
        $client = $this->logIn($client);
114
115
        $crawler = $client->request('GET', '/api/v1/user/1/ticket');
0 ignored issues
show
Unused Code introduced by
$crawler is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
116
        $response = $client->getResponse();
0 ignored issues
show
Unused Code introduced by
$response is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
117
118
        //print_r($response);
119
        $data = $client->getResponse()->getContent();
120
        $validator = $this->askValidation($data, $schema);
121
122
        $assert = $this->evalValidation($validator);
123
        $this->assertTrue($assert);
124
    }
125
}
126