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.

WorkspaceTest::testGetWorkSpace()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 12

Duplication

Lines 18
Ratio 100 %

Importance

Changes 3
Bugs 1 Features 0
Metric Value
c 3
b 1
f 0
dl 18
loc 18
rs 9.4285
cc 1
eloc 12
nc 1
nop 0
1
<?php
2
3
namespace Tests;
4
5
use Silex\WebTestCase;
6
7
class WorkspaceTest extends WebTestCase
8
{
9
    use AbstractAppTest;
10
11
    /*Verifico che il Workspace si possa scaricare correttamente*/
12 View Code Duplication
    public function testGetWorkSpace() {
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/workspace.json';
14
15
        $client = $this->createClient();
16
        $client = $this->logIn($client);
17
18
        $id = $this->testPostWorkspace();
19
20
        $crawler = $client->request('GET', '/api/v1/workspace/'.$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...
21
        $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...
22
        $data = $client->getResponse()->getContent();
23
        $validator = $this->askValidation($data, $schema);
24
25
        $assert = $this->evalValidation($validator);
26
        $this->assertTrue($assert);
27
28
        return $data;
29
    }
30
    /*Verifico che l'elenco dei workspace si possa scaricare correttamente*/
31
32
    /**
33
     * @return string
34
     */
35 View Code Duplication
    public function testGetWorkspaceList(){
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...
36
        $schema = __DIR__.'/../../../../api/schemas/workspaceList.json';
37
38
        $client = $this->createClient();
39
        $client = $this->logIn($client);
40
41
        $crawler = $client->request('GET', '/api/v1/workspace/');
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...
42
        $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...
43
44
        $data = $client->getResponse()->getContent();
45
        $validator = $this->askValidation($data, $schema);
46
47
        $assert = $this->evalValidation($validator);
48
        $this->assertTrue($assert);
49
        return $data;
50
    }
51
    /*verifico che si possa condividere il workspace */
52 View Code Duplication
    public function testGetWorkspaceShare() {
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...
53
        $schema = __DIR__.'/../../../../api/schemas/workspaceShare.json';
54
55
        $client = $this->createClient();
56
        $client = $this->logIn($client);
57
58
        $crawler = $client->request('GET', '/api/v1/workspace/1/share');
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
        $validator = $this->askValidation($data, $schema);
64
65
        $assert = $this->evalValidation($validator);
66
        $this->assertTrue($assert);
67
    }
68
69
    public function testPostWorkspace() {
70
        //$schema = __DIR__.'/../../../../api/schemas/workspace.json';
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
71
72
        $client = $this->createClient();
73
        $client = $this->logIn($client);
74
75
        $wp = '{
76
              "title":"Sopraelevata",
77
              "description":"I Sarchiaponi sono pronti a lanciarsi nella costruzione di una sopraelevata",
78
              "environment": 22,
79
              "team": {
80
                  "patrol":"Sarchiaponi",
81
                  "group":"Bologna 18",
82
                  "unit": "Marco Polo"
83
              },
84
              "badges": [ 5, 38, 99]
85
          }';
86
87
        $client->request(
88
            'POST',
89
            '/api/v1/workspace/',
90
            [],
91
            [],
92
            ['CONTENT_TYPE' => 'application/json'],
93
            $wp);
94
95
        $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...
96
97
        $data = $client->getResponse()->getContent();
98
        $id = json_decode($data);
99
100
        $id = $id->id;
101
102
        $this->assertTrue(is_numeric($id));
103
104
        return $id;
105
    }
106
    public function testPutWorkspace() {
107
        //$schema = __DIR__.'/../../../../api/schemas/workspace.json';
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
108
109
        $id = $this->testPostWorkspace();
110
        $wp = '{
111
              "id":'.$id.',
112
              "title":"Sopraelevata_EDIT",
113
              "description":"I Sarchiaponi sono pronti a lanciarsi nella costruzione di una sopraelevata",
114
              "environment": 25,
115
              "team": {
116
                  "patrol":"Sarchiaponini",
117
                  "group":"Bologna 17",
118
                  "unit": "Marco Polo2"
119
              },
120
              "badges": [ 5, 38, 99]
121
          }';
122
123
        $client = $this->createClient();
124
        $client = $this->logIn($client);
125
126
        //print_r("\nID: ".$id."\n");
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
127
        $client->request(
128
            'PUT',
129
            '/api/v1/workspace/'.$id.'',
130
            [],
131
            [],
132
            ['CONTENT_TYPE' => 'application/json'],
133
            $wp);
134
135
        $response = $client->getResponse();
136
        print($response);
137
        //$data = $client->getResponse()->getContent();
0 ignored issues
show
Unused Code Comprehensibility introduced by
65% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
138
        //$id = json_decode($data);
0 ignored issues
show
Unused Code Comprehensibility introduced by
56% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
139
140
        //$id=$id->id;
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
141
142
        $this->assertTrue($response->isOk());
143
    }
144
    public function testDeleteWorkspace() {
145
        //$schema = __DIR__.'/../../../../api/schemas/workspace.json';
0 ignored issues
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
146
        $id = $this->testPostWorkspace();
147
        $client = $this->createClient();
148
        $client = $this->logIn($client);
149
150
        $client->request(
151
            'DELETE',
152
            '/api/v1/workspace/'.$id.'',
153
            [],
154
            [],
155
            [],
156
            '');
157
158
        $response = $client->getResponse();
159
        $this->assertTrue($response->isOk());
160
161
        $data = $this->testGetWorkspaceList();
162
        $js = json_decode($data);
163
        $trovato = false;
164
        foreach ($js as $w) {
165
            if ($w->id === $id) {
166
                $trovato = true;
167
            }
168
        }
169
        $this->assertTrue(!$trovato);
170
    }
171
}
172