Test Setup Failed
Push — master ( 553e74...c78a38 )
by Carsten
06:57
created

RequestTest::testMissingPostPath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Lenius\Economic\Tests;
4
5
use Lenius\Economic\API\Client;
6
use Lenius\Economic\API\Request;
7
use Lenius\Economic\API\Response;
8
use PHPUnit\Framework\TestCase;
9
10
class RequestTest extends TestCase
11
{
12
    /** @var Request */
13
    protected $request;
14
15
    public function setUp()
16
    {
17
        $client = new Client('demo', 'demo');
18
        $this->request = new Request($client);
19
    }
20
21
    /**
22
     * @expectedException InvalidArgumentException
23
     */
24
    public function testMissingGetPath()
25
    {
26
        $this->request->get('');
27
    }
28
29
    /**
30
     * @expectedException InvalidArgumentException
31
     */
32
    public function testMissingPostPath()
33
    {
34
        $this->request->post('');
35
    }
36
37
    /**
38
     * @expectedException InvalidArgumentException
39
     */
40
    public function testMissingPutPath()
41
    {
42
        $this->request->put('');
43
    }
44
45
    /**
46
     * @expectedException InvalidArgumentException
47
     */
48
    public function testMissingPatchPath()
49
    {
50
        $this->request->patch('');
51
    }
52
53
    /**
54
     * @expectedException InvalidArgumentException
55
     */
56
    public function testMissingDeletePath()
57
    {
58
        $this->request->delete('');
59
    }
60
61
    public function testResponseInstance()
62
    {
63
        $getResponse = $this->request->get('/');
64
        $this->assertTrue(($getResponse instanceof Response));
65
    }
66
67
    public function testBadAuthentication()
68
    {
69
        $client = new Client('foo', 'foo');
70
        $request = new Request($client);
71
72
        $response = $request->get('/units', ['demo' => 'true']);
73
74
        $this->assertEquals(401, $response->httpStatus());
75
    }
76
77
    public function testSuccessfullGetResponse()
78
    {
79
        $response = $this->request->get('/units', ['demo' => 'true']);
80
81
        $this->assertTrue($response->isSuccess());
82
    }
83
84
    public function testFailedGetResponse()
85
    {
86
        $pingResponse = $this->request->get('/notfound');
87
88
        $this->assertFalse($pingResponse->isSuccess());
89
    }
90
}
91