1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Franjid\ApiWrapperBundle\Tests\Api; |
4
|
|
|
|
5
|
|
|
use Franjid\ApiWrapperBundle\Api\ApiRequest; |
6
|
|
|
use Franjid\ApiWrapperBundle\Api\ApiRequestInterface; |
7
|
|
|
|
8
|
|
|
class ApiRequestTest extends \PHPUnit_Framework_TestCase |
9
|
|
|
{ |
10
|
|
|
const METHOD = 'GET'; |
11
|
|
|
const URI = 'test-uri'; |
12
|
|
|
|
13
|
|
|
/** @var ApiRequestInterface apiRequest */ |
14
|
|
|
protected $apiRequest; |
15
|
|
|
|
16
|
|
|
public function setUp() |
17
|
|
|
{ |
18
|
|
|
$this->apiRequest = new ApiRequest(static::METHOD, static::URI); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
public function testGetMethod() |
22
|
|
|
{ |
23
|
|
|
$this->assertSame(static::METHOD, $this->apiRequest->getMethod()); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function testSetMethod() |
27
|
|
|
{ |
28
|
|
|
$this->apiRequest->setMethod('POST'); |
29
|
|
|
$this->assertSame('POST', $this->apiRequest->getMethod()); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function testGetHeaders() |
33
|
|
|
{ |
34
|
|
|
$expectedHeaders = [ |
35
|
|
|
'testHeader1' => [1], |
36
|
|
|
'testHeader2' => [2], |
37
|
|
|
'testHeader3' => [3], |
38
|
|
|
]; |
39
|
|
|
|
40
|
|
|
$this->apiRequest->setHeader('testHeader1', 1); |
41
|
|
|
$this->apiRequest->setHeaders([ |
42
|
|
|
'testHeader2' => 2, |
43
|
|
|
'testHeader3' => 3 |
44
|
|
|
]); |
45
|
|
|
|
46
|
|
|
$this->assertEquals($expectedHeaders, $this->apiRequest->getHeaders()); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function testGetUri() |
50
|
|
|
{ |
51
|
|
|
$this->assertSame(static::URI, $this->apiRequest->getUri()); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function testSetUri() |
55
|
|
|
{ |
56
|
|
|
$this->apiRequest->setUri('other-test-uri'); |
57
|
|
|
$this->assertSame('other-test-uri', $this->apiRequest->getUri()); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function testGetBody() |
61
|
|
|
{ |
62
|
|
|
$testBody = 'some test body'; |
63
|
|
|
$this->apiRequest->setBody($testBody); |
64
|
|
|
$this->assertSame($testBody, $this->apiRequest->getBody()); |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|