1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the curl-library package. |
5
|
|
|
* |
6
|
|
|
* (c) 2017 WEBEWEB |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace WBW\Library\CURL\Tests\Request; |
13
|
|
|
|
14
|
|
|
use WBW\Library\CURL\Request\CURLHeadRequest; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* cURL HEAD request test. |
18
|
|
|
* |
19
|
|
|
* @author webeweb <https://github.com/webeweb/> |
20
|
|
|
* @package WBW\Library\CURL\Tests\Request |
21
|
|
|
* @final |
22
|
|
|
*/ |
23
|
|
|
final class CURLHeadRequestTest extends AbstractCURLRequestTest { |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Tests __construct() method. |
27
|
|
|
* |
28
|
|
|
* @return void |
29
|
|
|
*/ |
30
|
|
|
public function testConstruct() { |
31
|
|
|
|
32
|
|
|
$obj = new CURLHeadRequest($this->configuration, self::RESOURCE_PATH); |
33
|
|
|
|
34
|
|
|
$this->assertSame($this->configuration, $obj->getConfiguration()); |
35
|
|
|
$this->assertEquals([], $obj->getHeaders()); |
36
|
|
|
$this->assertEquals(CURLHeadRequest::HTTP_METHOD_HEAD, $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 CURLHeadRequest($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->assertNull(json_decode($res->getResponseBody(), true)["method"]); |
59
|
|
|
$this->assertEquals(200, $res->getResponseInfo()["http_code"]); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
} |
63
|
|
|
|