1 | <?php |
||
23 | final class CURLPutRequestTest extends AbstractCURLRequestTest { |
||
24 | |||
25 | /** |
||
26 | * Tests __construct() method. |
||
27 | * |
||
28 | * @return void |
||
29 | */ |
||
30 | public function testConstructor() { |
||
31 | |||
32 | $obj = new CURLPutRequest($this->configuration, self::RESOURCE_PATH); |
||
33 | |||
34 | $this->assertEquals($this->configuration, $obj->getConfiguration()); |
||
35 | $this->assertEquals([], $obj->getHeaders()); |
||
36 | $this->assertEquals(CURLPutRequest::METHOD_PUT, $obj->getMethod()); |
||
37 | $this->assertEquals([], $obj->getPostData()); |
||
38 | $this->assertEquals([], $obj->getQueryData()); |
||
39 | $this->assertEquals("testCall.php", $obj->getResourcePath()); |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * Tests call() method. |
||
44 | * |
||
45 | * @return void |
||
46 | */ |
||
47 | public function testCall() { |
||
48 | |||
49 | $obj = new CURLPutRequest($this->configuration, self::RESOURCE_PATH); |
||
50 | |||
51 | $obj->addHeader("header", "header"); |
||
52 | $obj->addQueryData("queryData", "queryData"); |
||
53 | |||
54 | $res = $obj->call(); |
||
55 | |||
56 | $this->assertContains("header: header", $res->getRequestHeader()); |
||
57 | $this->assertContains("queryData=queryData", $res->getRequestURL()); |
||
58 | $this->assertEquals(CURLPutRequest::METHOD_PUT, json_decode($res->getResponseBody(), true)["method"]); |
||
59 | $this->assertEquals(200, $res->getResponseInfo()["http_code"]); |
||
60 | } |
||
61 | |||
62 | } |
||
63 |