Completed
Push — master ( 06ed76...0f3f4f )
by WEBEWEB
06:00 queued 14s
created

CURLPatchRequestTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 40
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
  /*
5
 * This file is part of the curl-library package.
6
 *
7
 * (c) 2017 NdC/WBW
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 NdC/WBW <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 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