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.

DeleteResourceControllerTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 6
dl 0
loc 47
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 10 1
A testDelete() 0 11 1
A testDeleteError() 0 17 1
1
<?php
2
3
namespace JDesrosiers\Resourceful\Controller\Test;
4
5
use JDesrosiers\Resourceful\Controller\DeleteResourceController;
6
use PHPUnit_Framework_TestCase;
7
use Silex\Application;
8
use Symfony\Component\HttpFoundation\Response;
9
use Symfony\Component\HttpKernel\Client;
10
11
class DeleteResourceControllerTest extends PHPUnit_Framework_TestCase
12
{
13
    private $app;
14
    private $service;
15
    private $client;
16
17
    public function setUp()
18
    {
19
        $this->app = new Application();
20
        $this->app["debug"] = true;
21
22
        $this->service = $this->getMockBuilder("Doctrine\Common\Cache\Cache")->getMock();
23
        $this->app->delete("/foo/{id}", new DeleteResourceController($this->service));
24
25
        $this->client = new Client($this->app);
26
    }
27
28
    public function testDelete()
29
    {
30
        $headers = [
31
            "HTTP_ACCEPT" => "application/json",
32
        ];
33
        $this->client->request("DELETE", "/foo/4ee8e29d45851", [], [], $headers);
34
        $response = $this->client->getResponse();
35
36
        $this->assertEquals(Response::HTTP_NO_CONTENT, $response->getStatusCode());
37
        $this->assertEquals("", $response->getContent());
38
    }
39
40
    public function testDeleteError()
41
    {
42
        $this->service->method("delete")
43
            ->willReturn(false);
44
45
        $this->app->error(function (\Exception $e, $code) {
0 ignored issues
show
Unused Code introduced by
The parameter $code is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
46
            $this->assertEquals("Failed to delete resource", $e->getMessage());
47
        });
48
49
        $headers = [
50
            "HTTP_ACCEPT" => "application/json",
51
        ];
52
        $this->client->request("DELETE", "/foo/4ee8e29d45851", [], [], $headers);
53
        $response = $this->client->getResponse();
54
55
        $this->assertEquals(Response::HTTP_SERVICE_UNAVAILABLE, $response->getStatusCode());
56
    }
57
}
58