1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
/* |
5
|
|
|
* This file is part of the curl-library package. |
6
|
|
|
* |
7
|
|
|
* (c) 2017 WEBEWEB |
8
|
|
|
* |
9
|
|
|
* For the full copyright and license information, please view the LICENSE |
10
|
|
|
* file that was distributed with this source code. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace WBW\Library\CURL\Tests\Request; |
14
|
|
|
|
15
|
|
|
use WBW\Library\CURL\Request\CURLPatchRequest; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* cURL PATCH request test. |
19
|
|
|
* |
20
|
|
|
* @author webeweb <https://github.com/webeweb/> |
21
|
|
|
* @package WBW\Library\CURL\Tests\Request |
22
|
|
|
* @final |
23
|
|
|
*/ |
24
|
|
|
final class CURLPatchRequestTest extends AbstractCURLRequestTest { |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Tests __construct() method. |
28
|
|
|
* |
29
|
|
|
* @return void |
30
|
|
|
*/ |
31
|
|
|
public function testConstruct() { |
32
|
|
|
|
33
|
|
|
$obj = new CURLPatchRequest($this->configuration, self::RESOURCE_PATH); |
34
|
|
|
|
35
|
|
|
$this->assertSame($this->configuration, $obj->getConfiguration()); |
36
|
|
|
$this->assertEquals([], $obj->getHeaders()); |
37
|
|
|
$this->assertEquals(CURLPatchRequest::HTTP_METHOD_PATCH, $obj->getMethod()); |
38
|
|
|
$this->assertEquals([], $obj->getPostData()); |
39
|
|
|
$this->assertEquals([], $obj->getQueryData()); |
40
|
|
|
$this->assertEquals("testCall.php", $obj->getResourcePath()); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Tests call() method. |
45
|
|
|
* |
46
|
|
|
* @return void |
47
|
|
|
*/ |
48
|
|
|
public function testCall() { |
49
|
|
|
|
50
|
|
|
$obj = new CURLPatchRequest($this->configuration, self::RESOURCE_PATH); |
51
|
|
|
|
52
|
|
|
$obj->addHeader("header", "header"); |
53
|
|
|
$obj->addQueryData("queryData", "queryData"); |
54
|
|
|
|
55
|
|
|
$res = $obj->call(); |
56
|
|
|
|
57
|
|
|
$this->assertContains("header: header", $res->getRequestHeader()); |
58
|
|
|
$this->assertContains("queryData=queryData", $res->getRequestURL()); |
59
|
|
|
$this->assertEquals(CURLPatchRequest::HTTP_METHOD_PATCH, json_decode($res->getResponseBody(), true)["method"]); |
60
|
|
|
$this->assertEquals(200, $res->getResponseInfo()["http_code"]); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
} |
64
|
|
|
|