Completed
Push — master ( bd558f...6391f6 )
by WEBEWEB
02:19
created

CURLHeadRequestTest::testConstruct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 0
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