mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-09-05 23:38:22 +00:00
Fix missing body in DELETE tests
This commit is contained in:
@@ -155,7 +155,7 @@ class CurlTest extends PHPUnit_Framework_TestCase
|
||||
$curl->setHeader('X-DEBUG-TEST', 'delete_with_body');
|
||||
$curl->delete($data, array('wibble' => 'wubble'));
|
||||
$this->assertEquals(Test::TEST_URL, $curl->base_url);
|
||||
$this->assertEquals('{"get":{"key":"value"},"post":{"wibble":"wubble"}}', $curl->raw_response);
|
||||
$this->assertEquals('{"get":{"key":"value"},"delete":{"wibble":"wubble"}}', $curl->raw_response);
|
||||
|
||||
$curl = new Curl(Test::TEST_URL);
|
||||
$curl->setHeader('X-DEBUG-TEST', 'get');
|
||||
@@ -428,7 +428,7 @@ class CurlTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
$test = new Test();
|
||||
$test->server('delete_with_body', 'DELETE', array('foo' => 'bar'), array('wibble' => 'wubble'));
|
||||
$this->assertEquals('{"get":{"foo":"bar"},"post":{"wibble":"wubble"}}', $test->curl->raw_response);
|
||||
$this->assertEquals('{"get":{"foo":"bar"},"delete":{"wibble":"wubble"}}', $test->curl->raw_response);
|
||||
}
|
||||
|
||||
public function testHeadRequestMethod()
|
||||
|
||||
@@ -1735,7 +1735,7 @@ class MultiCurlTest extends PHPUnit_Framework_TestCase
|
||||
$multi_curl->setHeader('X-DEBUG-TEST', 'delete_with_body');
|
||||
$multi_curl->addDelete($data, array('wibble' => 'wubble'))->complete(function($instance) {
|
||||
PHPUnit_Framework_Assert::assertEquals(Test::TEST_URL, $instance->base_url);
|
||||
PHPUnit_Framework_Assert::assertEquals('{"get":{"key":"value"},"post":{"wibble":"wubble"}}',
|
||||
PHPUnit_Framework_Assert::assertEquals('{"get":{"key":"value"},"delete":{"wibble":"wubble"}}',
|
||||
$instance->raw_response);
|
||||
});
|
||||
$multi_curl->start();
|
||||
|
||||
@@ -6,6 +6,7 @@ use \Helper\Test;
|
||||
$http_raw_post_data = file_get_contents('php://input');
|
||||
$_PUT = array();
|
||||
$_PATCH = array();
|
||||
$_DELETE = array();
|
||||
|
||||
$request_method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : '';
|
||||
if (!array_key_exists('CONTENT_TYPE', $_SERVER) && array_key_exists('HTTP_CONTENT_TYPE', $_SERVER)) {
|
||||
@@ -25,6 +26,11 @@ if ($request_method === 'POST') {
|
||||
parse_str($http_raw_post_data, $_PATCH);
|
||||
$data_values = $_PATCH;
|
||||
}
|
||||
} elseif ($request_method === 'DELETE') {
|
||||
if (strpos($content_type, 'application/x-www-form-urlencoded') === 0) {
|
||||
parse_str($http_raw_post_data, $_DELETE);
|
||||
$data_values = $_DELETE;
|
||||
}
|
||||
}
|
||||
|
||||
$test = isset($_SERVER['HTTP_X_DEBUG_TEST']) ? $_SERVER['HTTP_X_DEBUG_TEST'] : '';
|
||||
@@ -227,7 +233,7 @@ if ($test == 'http_basic_auth') {
|
||||
header('Content-Type: application/json');
|
||||
echo json_encode(array(
|
||||
'get' => $_GET,
|
||||
'post' => $_POST,
|
||||
'delete' => $_DELETE,
|
||||
));
|
||||
exit;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user