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 ( cdfa32...ae8f96 )
by Stefano
02:21
created

PartTest::testPostWorkspacePart()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 45
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 1
Metric Value
c 4
b 0
f 1
dl 0
loc 45
rs 8.8571
cc 1
eloc 16
nc 1
nop 0
1
<?php
2
3
namespace Tests;
4
5
class PartTest extends WorkspaceTest
6
{
7
    /*verifico che una parte si possa scaricare correttamente*/
8
    public function testGetWorkspacePart()
9
    {
10
        $schema = __DIR__.'/../../../../api/schemas/part.json';
11
12
        $client = $this->createClient();
13
        $client = $this->logIn($client);
14
15
        $blob = $this->testPostWorkspacePart();
16
        $id = $blob[0];
17
        $part_id = $blob[1];
18
19
        $crawler = $client->request('GET', '/api/v1/workspace/'.$id.'/part/'.$part_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...
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
22
        //print_r($response);
23
        $data = $client->getResponse()->getContent();
24
        $validator = $this->askValidation($data, $schema);
25
26
        $assert = $this->evalValidation($validator);
27
        $this->assertTrue($assert);
28
    }
29
30
    public function testPostWorkspacePart()
31
    {
32
        //$schema = __DIR__.'/../../../../api/schemas/part.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...
33
34
        $client = $this->createClient();
35
        $client = $this->logIn($client);
36
37
        $id = $this->testPostWorkspace();
38
        $part = '{"part":[
39
                {
40
                    "type": "image",
41
                    "ref": "afaifnanabnawnfawba",
42
                    "hash":"'.hash('md5', $id.'prova0').'"
43
                },
44
                {
45
                    "type": "image",
46
                    "ref": "awfaowapaegbgepng",
47
                    "hash":"'.hash('md5', $id.'prova1').'"
48
                },
49
                {
50
                    "type": "text",
51
                    "ref": "afaafaafafafifnanabnawnfawba",
52
                    "hash":"'.hash('md5', $id.'prova2').'"
53
                },
54
                {
55
                    "type": "video",
56
                    "ref": "aaafawafaggagaagegaa",
57
                    "hash":"'.hash('md5', $id.'prova3').'"
58
                }
59
            ],
60
            "badges":[13,28]}';
61
62
        $client->request('POST', '/api/v1/workspace/'.$id.'/part', [], [], ['CONTENT_TYPE' => 'application/json'], $part);
63
64
        $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...
65
66
        $data = $client->getResponse()->getContent();
67
        $part_id = json_decode($data);
68
69
        $part_id = $part_id->id;
70
71
        $this->assertTrue(is_numeric($id));
72
73
        return [$id, $part_id];
74
    }
75
76
    public function testPutWorkspacePart()
77
    {
78
        $client = $this->createClient();
79
        $client = $this->logIn($client);
80
81
        $blob = $this->testPostWorkspacePart();
82
        $id = $blob[0];
83
        $part_id = $blob[1];
84
        $part = '{
85
                "id":'.$part_id.',
86
                "part":[
87
                {
88
                    "type": "image",
89
                    "ref": "afaifnanabnawnfawba",
90
                    "hash":"'.hash('md5', $id.'prova0').'"
91
                },
92
                {
93
                    "type": "image",
94
                    "ref": "awfaowapaegbgepng",
95
                    "hash":"'.hash('md5', $id.'prova1').'"
96
                },
97
                {
98
                    "type": "text",
99
                    "ref": "blablablablabla",
100
                    "hash":"'.hash('md5', $id.'prova2').'"
101
                }
102
            ],
103
            "badges":[13,30]}';
104
105
        $client->request('PUT', '/api/v1/workspace/'.$id.'/part/'.$part_id.'', [], [], ['CONTENT_TYPE' => 'application/json'], $part);
106
107
        $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...
108
        $data = $client->getResponse()->getContent();
109
        $id = json_decode($data);
110
111
        $res_id = $id->id;
112
113
        $this->assertEquals($part_id, $res_id);
114
    }
115
116
    public function testDeleteWorkspacePart()
117
    {
118
        $client = $this->createClient();
119
        $client = $this->logIn($client);
120
121
        $blob = $this->testPostWorkspacePart();
122
        $id = $blob[0];
123
        $part_id = $blob[1];
124
125
        $client->request('DELETE', '/api/v1/workspace/'.$id.'/part/'.$part_id.'', [], [], [], '');
126
127
        $response = $client->getResponse();
128
        $this->assertTrue($response->isOk());
129
130
        $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...
131
132
        //print_r($client->getResponse());
0 ignored issues
show
Unused Code Comprehensibility introduced by
78% 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
        $data = $client->getResponse()->getContent();
134
135
        $js = json_decode($data);
136
137
        //var_dump($data);
138
        $trovato = false;
139
140
        foreach ($js->parts as $w) {
141
            if ($w === $part_id) {
142
                $trovato = true;
143
            }
144
        }
145
        $this->assertTrue(!$trovato);
146
    }
147
}
148