From f10ca99e590a5e958e6dab915def2621ae9967c6 Mon Sep 17 00:00:00 2001 From: Zach Borboa Date: Thu, 20 Aug 2015 00:44:28 -0700 Subject: [PATCH] Add test for PATCHing a multidimensional array (#205) --- tests/PHPCurlClass/PHPCurlClassTest.php | 16 ++++++++++++++++ tests/PHPCurlClass/server.php | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/tests/PHPCurlClass/PHPCurlClassTest.php b/tests/PHPCurlClass/PHPCurlClassTest.php index 3ca79ca..6337d86 100644 --- a/tests/PHPCurlClass/PHPCurlClassTest.php +++ b/tests/PHPCurlClass/PHPCurlClassTest.php @@ -409,6 +409,22 @@ class CurlTest extends PHPUnit_Framework_TestCase $this->assertEquals('PATCH', $test->server('request_method', 'PATCH')); } + public function testPatchRequestMethodWithMultidimArray() + { + $data = array( + 'data' => array( + 'foo' => 'bar', + 'wibble' => 'wubble', + ), + ); + + $curl = new Curl(); + $curl->setHeader('X-DEBUG-TEST', 'data_values'); + $curl->patch(Test::TEST_URL, $data); + $this->assertEquals('{"data":{"foo":"bar","wibble":"wubble"}}', $curl->rawResponse); + $this->assertEquals(json_decode(json_encode($data), false), $curl->response); + } + public function testDeleteRequestMethod() { $test = new Test(); diff --git a/tests/PHPCurlClass/server.php b/tests/PHPCurlClass/server.php index 0fe6f21..eb569bb 100644 --- a/tests/PHPCurlClass/server.php +++ b/tests/PHPCurlClass/server.php @@ -236,6 +236,10 @@ if ($test == 'http_basic_auth') { 'delete' => $_DELETE, )); exit; +} elseif ($test === 'data_values') { + header('Content-Type: application/json'); + echo json_encode($data_values); + exit; } header('Content-Type: text/plain');