Skip to content

Commit fe0de9e

Browse files
committed
Add post_multidimentional server file
1 parent 20e9855 commit fe0de9e

File tree

3 files changed

+22
-33
lines changed

3 files changed

+22
-33
lines changed

tests/CurlTest.php

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
class CurlTest extends \PHPUnit_Framework_TestCase {
66

77
const TEST_URL = 'http://php-curl-test.anezi.net/tests/server.php';
8-
8+
99
var $test_url = 'http://php-curl-test.anezi.net/tests/server/';
1010

1111
/**
@@ -63,17 +63,22 @@ public function testPostData() {
6363
}
6464

6565
public function testPostMultidimensionalData() {
66+
67+
$data = array(
68+
'key' => 'file',
69+
'file' => array(
70+
'wibble',
71+
'wubble',
72+
'wobble',
73+
),
74+
);
75+
76+
$this->curl->post($this->test_url . 'post_multidimensional.php', $data);
77+
6678
$this->assertEquals(
6779
'test=post_multidimensional&key=file&file%5B0%5D=wibble&file%5B1%5D=wubble&file%5B2%5D=wobble',
68-
$this->server('POST', array(
69-
'test' => 'post_multidimensional',
70-
'key' => 'file',
71-
'file' => array(
72-
'wibble',
73-
'wubble',
74-
'wobble',
75-
),
76-
)));
80+
$this->curl->response);
81+
7782
}
7883

7984
public function testPostFilePathUpload() {
@@ -131,10 +136,10 @@ public function testDelete() {
131136
}
132137

133138
public function testBasicHttpAuth() {
134-
139+
135140
$data = array();
136141
$this->curl->get($this->test_url . 'http_basic_auth.php', $data);
137-
142+
138143
$this->assertEquals('canceled', $this->curl->response);
139144

140145
$username = 'myusername';

tests/server.php

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,7 @@
44
$test = isset($data_values['test']) ? $data_values['test'] : '';
55
$key = isset($data_values['key']) ? $data_values['key'] : '';
66

7-
if ($test == 'http_basic_auth') {
8-
if (!isset($_SERVER['PHP_AUTH_USER'])) {
9-
header('WWW-Authenticate: Basic realm="My Realm"');
10-
header('HTTP/1.0 401 Unauthorized');
11-
echo 'canceled';
12-
exit;
13-
}
14-
15-
header('Content-Type: application/json');
16-
echo json_encode(array(
17-
'username' => $_SERVER['PHP_AUTH_USER'],
18-
'password' => $_SERVER['PHP_AUTH_PW'],
19-
));
20-
exit;
21-
}
22-
else if ($test === 'post_multidimensional') {
23-
$http_raw_post_data = file_get_contents('php://input');
24-
echo $http_raw_post_data;
25-
exit;
26-
}
27-
else if ($test === 'post_file_path_upload') {
7+
if ($test === 'post_file_path_upload') {
288
echo mime_content_type($_FILES[$key]['tmp_name']);
299
exit;
3010
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
3+
$http_raw_post_data = file_get_contents('php://input');
4+
echo $http_raw_post_data;

0 commit comments

Comments
 (0)