Skip to content

Commit 19d161c

Browse files
committed
Merge pull request php-curl-class#232 from zachborboa/master
Add test for PATCHing a multidimensional array (php-curl-class#205)
2 parents 46d412f + f10ca99 commit 19d161c

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

tests/PHPCurlClass/PHPCurlClassTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,22 @@ public function testPatchRequestMethod()
409409
$this->assertEquals('PATCH', $test->server('request_method', 'PATCH'));
410410
}
411411

412+
public function testPatchRequestMethodWithMultidimArray()
413+
{
414+
$data = array(
415+
'data' => array(
416+
'foo' => 'bar',
417+
'wibble' => 'wubble',
418+
),
419+
);
420+
421+
$curl = new Curl();
422+
$curl->setHeader('X-DEBUG-TEST', 'data_values');
423+
$curl->patch(Test::TEST_URL, $data);
424+
$this->assertEquals('{"data":{"foo":"bar","wibble":"wubble"}}', $curl->rawResponse);
425+
$this->assertEquals(json_decode(json_encode($data), false), $curl->response);
426+
}
427+
412428
public function testDeleteRequestMethod()
413429
{
414430
$test = new Test();

tests/PHPCurlClass/server.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,10 @@
236236
'delete' => $_DELETE,
237237
));
238238
exit;
239+
} elseif ($test === 'data_values') {
240+
header('Content-Type: application/json');
241+
echo json_encode($data_values);
242+
exit;
239243
}
240244

241245
header('Content-Type: text/plain');

0 commit comments

Comments
 (0)