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

CURLPatchRequestTest::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
  /*
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