Skip to content

Commit 7256a71

Browse files
committed
Fix missing body in DELETE tests
1 parent 29a1047 commit 7256a71

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

tests/PHPCurlClass/PHPCurlClassTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public function testSetUrlInConstructor()
155155
$curl->setHeader('X-DEBUG-TEST', 'delete_with_body');
156156
$curl->delete($data, array('wibble' => 'wubble'));
157157
$this->assertEquals(Test::TEST_URL, $curl->base_url);
158-
$this->assertEquals('{"get":{"key":"value"},"post":{"wibble":"wubble"}}', $curl->raw_response);
158+
$this->assertEquals('{"get":{"key":"value"},"delete":{"wibble":"wubble"}}', $curl->raw_response);
159159

160160
$curl = new Curl(Test::TEST_URL);
161161
$curl->setHeader('X-DEBUG-TEST', 'get');
@@ -428,7 +428,7 @@ public function testDelete()
428428

429429
$test = new Test();
430430
$test->server('delete_with_body', 'DELETE', array('foo' => 'bar'), array('wibble' => 'wubble'));
431-
$this->assertEquals('{"get":{"foo":"bar"},"post":{"wibble":"wubble"}}', $test->curl->raw_response);
431+
$this->assertEquals('{"get":{"foo":"bar"},"delete":{"wibble":"wubble"}}', $test->curl->raw_response);
432432
}
433433

434434
public function testHeadRequestMethod()

tests/PHPCurlClass/PHPMultiCurlClassTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1735,7 +1735,7 @@ public function testSetUrlInConstructor()
17351735
$multi_curl->setHeader('X-DEBUG-TEST', 'delete_with_body');
17361736
$multi_curl->addDelete($data, array('wibble' => 'wubble'))->complete(function($instance) {
17371737
PHPUnit_Framework_Assert::assertEquals(Test::TEST_URL, $instance->base_url);
1738-
PHPUnit_Framework_Assert::assertEquals('{"get":{"key":"value"},"post":{"wibble":"wubble"}}',
1738+
PHPUnit_Framework_Assert::assertEquals('{"get":{"key":"value"},"delete":{"wibble":"wubble"}}',
17391739
$instance->raw_response);
17401740
});
17411741
$multi_curl->start();

tests/PHPCurlClass/server.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
$http_raw_post_data = file_get_contents('php://input');
77
$_PUT = array();
88
$_PATCH = array();
9+
$_DELETE = array();
910

1011
$request_method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : '';
1112
if (!array_key_exists('CONTENT_TYPE', $_SERVER) && array_key_exists('HTTP_CONTENT_TYPE', $_SERVER)) {
@@ -25,6 +26,11 @@
2526
parse_str($http_raw_post_data, $_PATCH);
2627
$data_values = $_PATCH;
2728
}
29+
} elseif ($request_method === 'DELETE') {
30+
if (strpos($content_type, 'application/x-www-form-urlencoded') === 0) {
31+
parse_str($http_raw_post_data, $_DELETE);
32+
$data_values = $_DELETE;
33+
}
2834
}
2935

3036
$test = isset($_SERVER['HTTP_X_DEBUG_TEST']) ? $_SERVER['HTTP_X_DEBUG_TEST'] : '';
@@ -227,7 +233,7 @@
227233
header('Content-Type: application/json');
228234
echo json_encode(array(
229235
'get' => $_GET,
230-
'post' => $_POST,
236+
'delete' => $_DELETE,
231237
));
232238
exit;
233239
}

0 commit comments

Comments
 (0)