RequestTest::testGetPath()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Postpay\Tests\Http;
4
5
use PHPUnit\Framework\TestCase;
6
use Postpay\Http\Request;
7
use Postpay\Postpay;
8
9
class RequestTest extends TestCase
10
{
11
    public function testGetMethod()
12
    {
13
        $request = new Request('get');
14
        self::assertSame('GET', $request->getMethod());
15
    }
16
17
    public function testGetPath()
18
    {
19
        $request = new Request('GET', '/');
20
        self::assertSame('/', $request->getPath());
21
    }
22
23
    public function testAuth()
24
    {
25
        $request = new Request('GET');
26
        $auth = ['user', 'password'];
27
        $request->setAuth($auth);
28
29
        self::assertSame($auth, $request->getAuth());
30
    }
31
32 View Code Duplication
    public function testHeaders()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
33
    {
34
        $request = new Request('GET');
35
        $headers = ['header' => true];
36
        $request->setHeaders($headers);
37
38
        self::assertSame(
39
            array_intersect($headers, $request->getHeaders()),
40
            $headers
41
        );
42
    }
43
44 View Code Duplication
    public function testParams()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
45
    {
46
        $request = new Request('GET');
47
        $params = ['param' => true];
48
        $request->setParams($params);
49
50
        self::assertSame(
51
            array_intersect($params, $request->getParams()),
52
            $params
53
        );
54
    }
55
56
    public function testJson()
57
    {
58
        $request = new Request('GET');
59
        $params = ['test' => true];
60
61
        $request->setParams($params);
62
        self::assertEmpty($request->json());
63
64
        $request->setMethod('POST');
65
        self::assertNotEmpty($request->json());
66
    }
67
68
    public function testApiVersion()
69
    {
70
        $request = new Request('GET');
71
        $version = 'v1';
72
        $request->setApiVersion($version);
73
74
        self::assertSame($version, $request->getApiVersion());
75
    }
76
77
    public function testIsGraphQL()
78
    {
79
        $request = new Request('GET');
80
        self::assertFalse($request->isGraphQL());
81
82
        $request->setApiVersion(Postpay::GRAPHQL_VERSION);
83
        self::assertTrue($request->isGraphQL());
84
    }
85
86
    public function testGetUrl()
87
    {
88
        $path = '/test';
89
        $request = new Request('GET', $path);
90
91
        self::assertStringEndsWith($path, $request->getUrl());
92
    }
93
}
94