Skip to content

Commit fda3c6e

Browse files
committed
Bug with post upload.
1 parent 7bdc952 commit fda3c6e

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

tests/CurlTest.php

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function testPostMultidimensionalData() {
7676
$this->curl->post($this->test_url . 'post_multidimensional.php', $data);
7777

7878
$this->assertEquals(
79-
'test=post_multidimensional&key=file&file%5B0%5D=wibble&file%5B1%5D=wubble&file%5B2%5D=wobble',
79+
'key=file&file%5B0%5D=wibble&file%5B1%5D=wubble&file%5B2%5D=wobble',
8080
$this->curl->response);
8181

8282
}
@@ -86,7 +86,14 @@ public function testPostFilePathUpload() {
8686

8787
$data = array(
8888
'key' => 'image',
89-
'image' => '@' . $file_path,
89+
'image' => "@" . $file_path,
90+
);
91+
92+
$image = file_get_contents($file_path);
93+
94+
$data = array(
95+
'key' => 'image',
96+
'image' => $image,
9097
);
9198

9299
$this->curl->post($this->test_url . 'post_file_path_upload.php', $data);
@@ -97,7 +104,7 @@ public function testPostFilePathUpload() {
97104
'key' => 'image',
98105
'mime_content_type' => 'image/png'
99106
),
100-
json_decode($this->curl->response));
107+
json_decode($this->curl->response, true));
101108

102109
unlink($file_path);
103110
}
@@ -146,7 +153,8 @@ public function testDelete() {
146153

147154
public function testBasicHttpAuth() {
148155

149-
$data = array();
156+
$data = array();
157+
150158
$this->curl->get($this->test_url . 'http_basic_auth.php', $data);
151159

152160
$this->assertEquals('canceled', $this->curl->response);
@@ -156,9 +164,11 @@ public function testBasicHttpAuth() {
156164

157165
$this->curl->setBasicAuthentication($username, $password);
158166

159-
$json = json_decode($this->curl->response);
160-
$this->assertTrue($json->username === $username);
161-
$this->assertTrue($json->password === $password);
167+
$this->curl->get($this->test_url . 'http_basic_auth.php', $data);
168+
169+
$this->assertEquals(
170+
'{"username":"myusername","password":"mypassword"}',
171+
$this->curl->response);
162172
}
163173

164174
public function testReferrer() {

tests/data/test.png

2.79 KB
Loading

0 commit comments

Comments
 (0)