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 ( fb8c31...1a99dd )
by Danger
02:38
created

WorkspaceTest::testDeleteWorkspace()   B

Complexity

Conditions 3
Paths 3

Size

Total Lines 27
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 27
rs 8.8571
cc 3
eloc 17
nc 3
nop 0
1
<?php
2
3
namespace Tests;
4
5
use Silex\WebTestCase;
6
use JsonSchema\Validator;
7
8
class WorkspaceTest extends WebTestCase
9
{
10
    use AbstractAppTest;
11
12
    /*Verifico che il Workspace si possa scaricare correttamente*/
13 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...
14
        $schema = __DIR__.'/../../../../api/schemas/workspace.json';
15
16
        $client = $this->createClient();
17
        $client = $this->logIn($client);
18
19
        $crawler = $client->request('GET', '/api/v1/workspace/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...
20
        $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...
21
        $data = $client->getResponse()->getContent();
22
        $validator = $this->askValidation($data,$schema);
23
24
        $assert = $this->evalValidation($validator);
25
        $this->assertTrue($assert);
26
27
        return $data;
28
    }
29
    /*Verifico che l'elenco dei workspace si possa scaricare correttamente*/
30 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...
31
        $schema = __DIR__.'/../../../../api/schemas/workspaceList.json';
32
33
        $client = $this->createClient();
34
        $client = $this->logIn($client);
35
36
        $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...
37
        $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...
38
39
        $data = $client->getResponse()->getContent();
40
        $validator = $this->askValidation($data,$schema);
41
42
        $assert = $this->evalValidation($validator);
43
        $this->assertTrue($assert);
44
        return $data;
45
    }
46
    /*verifico che si possa condividere il workspace */
47 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...
48
        $schema = __DIR__.'/../../../../api/schemas/workspaceShare.json';
49
50
        $client = $this->createClient();
51
        $client = $this->logIn($client);
52
53
        $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...
54
        $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...
55
56
        //print_r($response);
57
        $data = $client->getResponse()->getContent();
58
        $validator = $this->askValidation($data,$schema);
59
60
        $assert = $this->evalValidation($validator);
61
        $this->assertTrue($assert);
62
    }
63
64
    public function testPostWorkspace(){
65
        //$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...
66
67
        $client = $this->createClient();
68
        $client = $this->logIn($client);
69
70
        $wp ='{
71
              "title":"Sopraelevata",
72
              "description":"I Sarchiaponi sono pronti a lanciarsi nella costruzione di una sopraelevata",
73
              "environment": 22,
74
              "team": {
75
                  "patrol":"Sarchiaponi",
76
                  "group":"Bologna 18",
77
                  "unit": "Marco Polo"
78
              },
79
              "badges": [ 5, 38, 99]
80
          }';
81
82
        $client->request(
83
          'POST',
84
          '/api/v1/workspace/',
85
          [],
86
          [],
87
          ['CONTENT_TYPE' => 'application/json'],
88
          $wp);
89
90
        $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...
91
92
        $data = $client->getResponse()->getContent();
93
        $id = json_decode($data);
94
95
        $id=$id->id;
96
97
        $this->assertTrue(is_numeric($id));
98
99
        return $id;
100
    }
101
    public function testPutWorkspace(){
102
        //$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...
103
104
        $id = $this->testPostWorkspace();
105
        $wp ='{
106
              "id":'.$id.',
107
              "title":"Sopraelevata_EDIT",
108
              "description":"I Sarchiaponi sono pronti a lanciarsi nella costruzione di una sopraelevata",
109
              "environment": 25,
110
              "team": {
111
                  "patrol":"Sarchiaponini",
112
                  "group":"Bologna 17",
113
                  "unit": "Marco Polo2"
114
              },
115
              "badges": [ 5, 38, 99]
116
          }';
117
118
        $client = $this->createClient();
119
        $client = $this->logIn($client);
120
121
        //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...
122
        $client->request(
123
          'PUT',
124
          '/api/v1/workspace/'.$id.'',
125
          [],
126
          [],
127
          ['CONTENT_TYPE' => 'application/json'],
128
          $wp);
129
130
        $response = $client->getResponse();
131
        print($response);
132
        //$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...
133
        //$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...
134
135
        //$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...
136
137
        $this->assertTrue($response->isOk());
138
    }
139
    public function testDeleteWorkspace(){
140
        //$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...
141
        $id = $this->testPostWorkspace();
142
        $client = $this->createClient();
143
        $client = $this->logIn($client);
144
145
        $client->request(
146
          'DELETE',
147
          '/api/v1/workspace/'.$id.'',
148
          [],
149
          [],
150
          [],
151
          '');
152
153
        $response = $client->getResponse();
154
        $this->assertTrue($response->isOk());
155
156
        $data = $this->testGetWorkspaceList();
157
        $js= json_decode($data);
158
        $trovato = false;
159
        foreach($js as $w){
160
            if($w->id === $id){
161
                $trovato=true;
162
            }
163
        }
164
        $this->assertTrue(!$trovato);
165
    }
166
}
167