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.
Failed Conditions
Push — master ( 37a03c...579a75 )
by Casper
03:44 queued 01:41
created

TestCase::getClientWithMockedDelete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 9
rs 10
1
<?php
2
3
namespace NStack\Tests;
4
5
use GuzzleHttp\Client;
6
use GuzzleHttp\Psr7\Response;
7
use NStack\Config;
8
9
class TestCase extends \PHPUnit\Framework\TestCase
10
{
11
    /**
12
     * getMockAsArray
13
     *
14
     * @param string $fileName
15
     * @return array
16
     * @author Casper Rasmussen <[email protected]>
17
     */
18
    protected function getMockAsArray(string $fileName): array
19
    {
20
        $content = file_get_contents(getcwd() . '/tests/mocks/' . $fileName);
21
22
        return json_decode($content, true);
23
    }
24
25
    /**
26
     * getClientWithMockedGet
27
     *
28
     * @param string $filename
29
     * @return \GuzzleHttp\Client
30
     * @author Casper Rasmussen <[email protected]>
31
     */
32
    protected function getClientWithMockedGet(string $filename): Client
33
    {
34
        $response = new Response(200, ['Content-Type' => 'application/json'],
35
            $this->getMockAsString($filename));
36
37
        $guzzle = \Mockery::mock(\GuzzleHttp\Client::class);
38
        $guzzle->shouldReceive('get')->once()->andReturn($response);
39
40
        return $guzzle;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $guzzle returns the type Mockery\LegacyMockInterface|Mockery\MockInterface which is incompatible with the type-hinted return GuzzleHttp\Client.
Loading history...
41
    }
42
43
    /**
44
     * getClientWithMockedPost
45
     *
46
     * @param string $filename
47
     * @return Client
48
     * @author Tiago Araujo <[email protected]>
49
     */
50
    protected function getClientWithMockedPost(string $filename): Client
51
    {
52
        $response = new Response(200, ['Content-Type' => 'application/json'],
53
            $this->getMockAsString($filename));
54
55
        $guzzle = \Mockery::mock(Client::class);
56
        $guzzle->shouldReceive('post')->once()->andReturn($response);
57
58
        return $guzzle;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $guzzle returns the type Mockery\LegacyMockInterface|Mockery\MockInterface which is incompatible with the type-hinted return GuzzleHttp\Client.
Loading history...
59
    }
60
61
    /**
62
     * getClientWithMockedDelete
63
     *
64
     * @param string $filename
65
     * @return Client
66
     * @author Tiago Araujo <[email protected]>
67
     */
68
    protected function getClientWithMockedDelete(string $filename): Client
69
    {
70
        $response = new Response(200, ['Content-Type' => 'application/json'],
71
            $this->getMockAsString($filename));
72
73
        $guzzle = \Mockery::mock(Client::class);
74
        $guzzle->shouldReceive('delete')->once()->andReturn($response);
75
76
        return $guzzle;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $guzzle returns the type Mockery\LegacyMockInterface|Mockery\MockInterface which is incompatible with the type-hinted return GuzzleHttp\Client.
Loading history...
77
    }
78
79
    /**
80
     * getMockAsString
81
     *
82
     * @param string $fileName
83
     * @return string
84
     * @author Casper Rasmussen <[email protected]>
85
     */
86
    protected function getMockAsString(string $fileName): string
87
    {
88
        return file_get_contents(getcwd() . '/tests/mocks/' . $fileName);
89
    }
90
91
    /**
92
     * getConfig
93
     *
94
     * @return \NStack\Config
95
     * @author Casper Rasmussen <[email protected]>
96
     */
97
    public function getConfig(): Config
98
    {
99
        return new Config('', '');
100
    }
101
}
102