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.

StubHandlerTest::testSuccessSimpleGet()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Alekseytupichenkov\GuzzleStub\Tests\Unit\Handler;
4
5
use Alekseytupichenkov\GuzzleStub\Handler\StubHandler;
6
use Alekseytupichenkov\GuzzleStub\Model\Fixture;
7
use GuzzleHttp\Psr7\Request;
8
use GuzzleHttp\Psr7\Response;
9
use PHPUnit\Framework\TestCase;
10
11
class StubHandlerTest extends TestCase
12
{
13
    /** @var Request */
14
    private $getRequest;
15
16
    /** @var Response */
17
    private $getResponse;
18
19
    /** @var Request */
20
    private $postRequest;
21
22
    /** @var Response */
23
    private $postResponse;
24
25
    /** @var StubHandler */
26
    private $handler;
27
28
    public function setUp()
29
    {
30
        $this->handler = new StubHandler();
31
32
        $this->getRequest = new Request('GET', '/foo/bar?test=1', ['foo' => 'bar']);
33
        $this->getResponse = new Response(200, ['baz' => 'POST'], '{"get": "ok"}');
34
        $this->postRequest = new Request('POST', '/foo/bar', ['foo' => 'bar'], 'SuperBody');
35
        $this->postResponse = new Response(200, ['baz' => 'POST'], '{"post": "ok"}');
36
37
        $this->handler->append(new Fixture($this->getRequest, $this->getResponse));
38
        $this->handler->append(new Fixture($this->postRequest, $this->postResponse));
39
    }
40
41
    public function testSuccessSimpleGet()
42
    {
43
        $promise = $this->handler->__invoke($this->getRequest, []);
44
45
        $this->assertEquals($this->getResponse, $promise->wait());
46
    }
47
48
    public function testSuccessSimplePost()
49
    {
50
        $promise = $this->handler->__invoke($this->postRequest, []);
51
52
        $this->assertEquals($this->postResponse, $promise->wait());
53
    }
54
55
    public function testSuccessParticleGet()
56
    {
57
        $request = new Request('GET', '/foo/bar?test=1');
58
        $response = new Response(200);
59
        $this->handler->append(new Fixture($request, $response));
60
61
        $promise = $this->handler->__invoke($this->getRequest, []);
62
63
        $this->assertEquals($response, $promise->wait());
64
    }
65
66
    public function testSuccessParticlePost()
67
    {
68
        $request = new Request('POST', '/foo/bar');
69
        $response = new Response(200);
70
        $this->handler->append(new Fixture($request, $response));
71
72
        $promise = $this->handler->__invoke($this->postRequest, []);
73
74
        $this->assertEquals($this->postResponse, $promise->wait());
75
    }
76
77
    public function testSuccessRegexGet()
78
    {
79
        $request = new Request('GET|POST', '\/foo\/.*', ['foo' => '.*']);
80
        $response = new Response(200);
81
        $this->handler->append(new Fixture($request, $response));
82
83
        $promise = $this->handler->__invoke($this->getRequest, []);
84
85
        $this->assertEquals($response, $promise->wait());
86
    }
87
88
    public function testSuccessRegexPost()
89
    {
90
        $request = new Request('GET|POST', '\/foo\/.*', ['foo' => '.*'], 'Super.*');
91
        $response = new Response(200);
92
        $this->handler->append(new Fixture($request, $response));
93
94
        $promise = $this->handler->__invoke($this->postRequest, []);
95
96
        $this->assertEquals($response, $promise->wait());
97
    }
98
99
    public function testReplaceResponseByExistingRequest()
100
    {
101
        $response = new Response(200);
102
        $this->handler->append(new Fixture($this->getRequest, $response));
103
104
        $promise = $this->handler->__invoke($this->getRequest, []);
105
106
        $this->assertEquals($response, $promise->wait());
107
    }
108
109
    /**
110
     * @expectedException \Alekseytupichenkov\GuzzleStub\Exception\GuzzleStubException
111
     * @expectedExceptionMessageRegExp "Can`t find suitable response for request .*"
112
     */
113
    public function testException()
114
    {
115
        $this->handler->__invoke(new Request('not', 'valid'), []);
116
    }
117
}
118