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 ( 1c3add...d596d4 )
by Tupichenkov
03:10
created

StubHandlerTest::testHistoryByIndex()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 9
nc 1
nop 0
dl 0
loc 14
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
namespace Alekseytupichenkov\GuzzleStub\Tests\Functional;
4
5
use Alekseytupichenkov\GuzzleStub\Tests\Functional\Stub\TestClientStub;
6
use PHPUnit\Framework\TestCase;
7
8
class StubHandlerTest extends TestCase
9
{
10
    /** @var TestClientStub */
11
    private $client;
12
13
    public function setUp()
14
    {
15
        $this->client = new TestClientStub();
16
    }
17
18
    public function testSuccess()
19
    {
20
        $response = $this->client->post('/foo/bar', [
21
            'headers' => [
22
                'token' => '123'
23
            ],
24
            'body' => '{"data":"test"}'
25
        ]);
26
27
        $this->assertEquals(200, $response->getStatusCode());
28
        $this->assertEquals('{"result":"ok"}', $response->getBody()->__toString());
29
        $this->assertEquals(1, $this->client->getHistoryCount());
30
        $this->assertEquals($response, $this->client->getLatestHistoryResponse());
31
    }
32
33
    public function testUnsuccess()
34
    {
35
        $response = $this->client->post('/foo/baz', [
36
            'headers' => [
37
                'token' => '123'
38
            ],
39
            'body' => '{"data":"test"}'
40
        ]);
41
42
        $this->assertEquals(200, $response->getStatusCode());
43
        $this->assertEquals('{"result":"error"}', $response->getBody()->__toString());
44
        $this->assertEquals(1, $this->client->getHistoryCount());
45
        $this->assertEquals($response, $this->client->getLatestHistoryResponse());
46
    }
47
48
    /**
49
     * @expectedException \Alekseytupichenkov\GuzzleStub\Exception\GuzzleStubException
50
     * @expectedExceptionMessageRegExp "Can`t find suitable response for request .*"
51
     */
52
    public function testCantFindSuitableResponseException()
53
    {
54
        $this->client->post('/without/fixture');
55
    }
56
57
    public function testHistory()
58
    {
59
        $this->client->post('/foo/bar', [
60
            'headers' => [
61
                'token' => '123'
62
            ],
63
            'body' => '{"data":"test"}'
64
        ]);
65
66
        $history = $this->client->getHistoryList();
67
        $this->assertCount(1, $history);
68
        $this->assertEquals($this->client->getLatestHistoryRequest(), $history[0]['request']);
69
        $this->assertEquals($this->client->getLatestHistoryResponse(), $history[0]['response']);
70
        $this->assertEquals(null, $history[0]['error']);
71
        $this->assertArrayHasKey('options', $history[0]);
72
    }
73
74
    public function testHistoryByIndex()
75
    {
76
        $this->client->post('/foo/bar', [
77
            'headers' => [
78
                'token' => '123'
79
            ],
80
            'body' => '{"data":"test"}'
81
        ]);
82
83
        $history = $this->client->getHistory(0);
84
        $this->assertEquals($this->client->getLatestHistoryRequest(), $history['request']);
85
        $this->assertEquals($this->client->getLatestHistoryResponse(), $history['response']);
86
        $this->assertEquals(null, $history['error']);
87
        $this->assertArrayHasKey('options', $history);
88
    }
89
90
    /**
91
     * @expectedException \Alekseytupichenkov\GuzzleStub\Exception\GuzzleStubException
92
     * @expectedExceptionMessage Can`t found history with index 1
93
     */
94
    public function testCantFoundHistoryWithIndexException()
95
    {
96
        $this->client->getHistory(1);
97
    }
98
}
99