1 | <?php |
||
24 | final class CURLPatchRequestTest extends AbstractCURLRequestTest { |
||
25 | |||
26 | /** |
||
27 | * Tests __construct() method. |
||
28 | * |
||
29 | * @return void |
||
30 | */ |
||
31 | public function testConstructor() { |
||
32 | |||
33 | $obj = new CURLPatchRequest($this->configuration, self::RESOURCE_PATH); |
||
34 | |||
35 | $this->assertEquals($this->configuration, $obj->getConfiguration()); |
||
36 | $this->assertEquals([], $obj->getHeaders()); |
||
37 | $this->assertEquals(CURLPatchRequest::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::METHOD_PATCH, json_decode($res->getResponseBody(), true)["method"]); |
||
60 | $this->assertEquals(200, $res->getResponseInfo()["http_code"]); |
||
61 | } |
||
62 | |||
63 | } |
||
64 |