Skip to content

Commit 76f3a76

Browse files
committed
added some basic syntax tests
1 parent a5707d1 commit 76f3a76

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

src/Curl/Curl.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ private function init()
172172
$this->setOpt(CURLINFO_HEADER_OUT, true);
173173
$this->setOpt(CURLOPT_HEADER, false);
174174
$this->setOpt(CURLOPT_RETURNTRANSFER, true);
175-
175+
176176
return $this;
177177
}
178178

@@ -582,7 +582,7 @@ public function getOpt($option)
582582

583583
/**
584584
* Return the all options for current curl ressource
585-
*
585+
*
586586
* To see a full list of options: http://php.net/curl_getinfo
587587
*
588588
* @see http://php.net/curl_getinfo

tests/CurlTest.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@ public function testPutJsonData()
8888
$resp->reset();
8989
}
9090

91+
public function testPutJsonNotAsJsonData()
92+
{
93+
$resp = $this->curl->put(self::TEST_URL.'/server.php', ['foo' => 'bar'], true, false);
94+
$this->assertTrue($resp->isSuccess());
95+
$this->assertArrayHasKey('x-powered-by', $resp->getResponseHeaders());
96+
// syntax error check
97+
$resp->reset();
98+
}
99+
91100
public function testPatchJsonData()
92101
{
93102
$resp = $this->curl->patch(self::TEST_URL.'/server.php', ['foo' => 'bar'], true, true);
@@ -96,6 +105,14 @@ public function testPatchJsonData()
96105
// syntax error check
97106
$resp->reset();
98107
}
108+
public function testPatchJsonNotAsJsonData()
109+
{
110+
$resp = $this->curl->patch(self::TEST_URL.'/server.php', ['foo' => 'bar'], true, false);
111+
$this->assertTrue($resp->isSuccess());
112+
$this->assertArrayHasKey('x-powered-by', $resp->getResponseHeaders());
113+
// syntax error check
114+
$resp->reset();
115+
}
99116

100117
public function testPurge()
101118
{
@@ -194,6 +211,22 @@ public function testDelete()
194211
)) === 'delete');
195212
}
196213

214+
public function testDeleteWithPayload()
215+
{
216+
$this->curl->setVerbose();
217+
$resp = $this->curl->delete(self::TEST_URL.'/server.php', ['foo' => 'bar'], true);
218+
$this->assertTrue($resp->isSuccess());
219+
$this->assertFalse($resp->isInfo());
220+
$this->assertFalse($resp->isRedirect());
221+
$this->assertFalse($resp->isClientError());
222+
$this->assertFalse($resp->isServerError());
223+
$this->assertSame('http://localhost:1234/server.php', $resp->getEndpoint());
224+
225+
$this->assertSame('Error.', $resp->getResponse());
226+
$this->assertSame('localhost:1234', $resp->getResponseHeaders('HOST'));
227+
unset($this->curl);
228+
}
229+
197230
public function testGetOpts()
198231
{
199232
$this->curl->get(self::TEST_URL . '/http_basic_auth.php');

0 commit comments

Comments
 (0)