Skip to content

Commit c894fed

Browse files
committed
Add test cases for the SEARCH method
1 parent dcbc962 commit c894fed

File tree

3 files changed

+305
-16
lines changed

3 files changed

+305
-16
lines changed

tests/PHPCurlClass/PHPCurlClassTest.php

Lines changed: 64 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ public function testUrl()
124124
$test->server('server', 'PATCH', $data);
125125
$this->assertEquals(Test::TEST_URL, $test->curl->url);
126126

127+
// curl -v --request SEARCH "http://127.0.0.1:8000/" --data "foo=bar"
128+
$test = new Test();
129+
$test->server('server', 'SEARCH', $data);
130+
$this->assertEquals(Test::TEST_URL, $test->curl->url);
131+
127132
// curl -v --request DELETE "http://127.0.0.1:8000/?foo=bar"
128133
$test = new Test();
129134
$test->server('server', 'DELETE', $data);
@@ -183,6 +188,11 @@ public function testSetUrlInConstructor()
183188
$curl->setHeader('X-DEBUG-TEST', 'put');
184189
$curl->put($data);
185190
$this->assertEquals('key=value', $curl->response);
191+
192+
$curl = new Curl(Test::TEST_URL);
193+
$curl->setHeader('X-DEBUG-TEST', 'search');
194+
$curl->search($data);
195+
$this->assertEquals('key=value', $curl->response);
186196
}
187197

188198
public function testSetUrl()
@@ -230,6 +240,12 @@ public function testSetUrl()
230240
$curl->put($data);
231241
$this->assertEquals('PUT / HTTP/1.1', $curl->requestHeaders['Request-Line']);
232242
$this->assertEquals(Test::TEST_URL, $curl->effectiveUrl);
243+
244+
$curl = new Curl();
245+
$curl->setUrl(Test::TEST_URL);
246+
$curl->search($data);
247+
$this->assertEquals('SEARCH / HTTP/1.1', $curl->requestHeaders['Request-Line']);
248+
$this->assertEquals(Test::TEST_URL, $curl->effectiveUrl);
233249
}
234250

235251
public function testEffectiveUrl()
@@ -995,6 +1011,7 @@ public function testResponseBody()
9951011
'POST' => 'OK',
9961012
'PUT' => 'OK',
9971013
'PATCH' => 'OK',
1014+
'SEARCH' => 'OK',
9981015
'DELETE' => 'OK',
9991016
'HEAD' => '',
10001017
'OPTIONS' => 'OK',
@@ -1267,6 +1284,8 @@ public function testRequestUrl()
12671284
$test = new Test();
12681285
$this->assertFalse(substr($test->server('request_uri', 'PATCH'), -1) === '?');
12691286
$test = new Test();
1287+
$this->assertFalse(substr($test->server('request_uri', 'SEARCH'), -1) === '?');
1288+
$test = new Test();
12701289
$this->assertFalse(substr($test->server('request_uri', 'DELETE'), -1) === '?');
12711290
}
12721291

@@ -3025,6 +3044,7 @@ public function testRequestMethodSuccessiveGetRequests()
30253044
$test->chainRequests('GET', 'DELETE');
30263045
$test->chainRequests('GET', 'HEAD');
30273046
$test->chainRequests('GET', 'OPTIONS');
3047+
$test->chainRequests('GET', 'SEARCH');
30283048
$test->chainRequests('GET', 'GET');
30293049

30303050
$test = new Test();
@@ -3034,7 +3054,8 @@ public function testRequestMethodSuccessiveGetRequests()
30343054
$test->chainRequests('GET', 'DELETE', array('d' => '4444'));
30353055
$test->chainRequests('GET', 'HEAD', array('e' => '55555'));
30363056
$test->chainRequests('GET', 'OPTIONS', array('f' => '666666'));
3037-
$test->chainRequests('GET', 'GET', array('g' => '7777777'));
3057+
$test->chainRequests('GET', 'SEARCH', array('h' => '7777777'));
3058+
$test->chainRequests('GET', 'GET', array('g' => '88888888'));
30383059
}
30393060

30403061
public function testRequestMethodSuccessivePostRequests()
@@ -3046,6 +3067,7 @@ public function testRequestMethodSuccessivePostRequests()
30463067
$test->chainRequests('POST', 'DELETE');
30473068
$test->chainRequests('POST', 'HEAD');
30483069
$test->chainRequests('POST', 'OPTIONS');
3070+
$test->chainRequests('POST', 'SEARCH');
30493071
$test->chainRequests('POST', 'POST');
30503072

30513073
$test = new Test();
@@ -3055,7 +3077,8 @@ public function testRequestMethodSuccessivePostRequests()
30553077
$test->chainRequests('POST', 'DELETE', array('d' => '4444'));
30563078
$test->chainRequests('POST', 'HEAD', array('e' => '55555'));
30573079
$test->chainRequests('POST', 'OPTIONS', array('f' => '666666'));
3058-
$test->chainRequests('POST', 'POST', array('g' => '7777777'));
3080+
$test->chainRequests('POST', 'SEARCH', array('g' => '7777777'));
3081+
$test->chainRequests('POST', 'POST', array('g' => '88888888'));
30593082
}
30603083

30613084
public function testRequestMethodSuccessivePutRequests()
@@ -3067,6 +3090,7 @@ public function testRequestMethodSuccessivePutRequests()
30673090
$test->chainRequests('PUT', 'DELETE');
30683091
$test->chainRequests('PUT', 'HEAD');
30693092
$test->chainRequests('PUT', 'OPTIONS');
3093+
$test->chainRequests('PUT', 'SEARCH');
30703094
$test->chainRequests('PUT', 'PUT');
30713095

30723096
$test = new Test();
@@ -3076,7 +3100,8 @@ public function testRequestMethodSuccessivePutRequests()
30763100
$test->chainRequests('PUT', 'DELETE', array('d' => '4444'));
30773101
$test->chainRequests('PUT', 'HEAD', array('e' => '55555'));
30783102
$test->chainRequests('PUT', 'OPTIONS', array('f' => '666666'));
3079-
$test->chainRequests('PUT', 'PUT', array('g' => '7777777'));
3103+
$test->chainRequests('PUT', 'SEARCH', array('f' => '7777777'));
3104+
$test->chainRequests('PUT', 'PUT', array('g' => '88888888'));
30803105
}
30813106

30823107
public function testRequestMethodSuccessivePatchRequests()
@@ -3088,6 +3113,7 @@ public function testRequestMethodSuccessivePatchRequests()
30883113
$test->chainRequests('PATCH', 'DELETE');
30893114
$test->chainRequests('PATCH', 'HEAD');
30903115
$test->chainRequests('PATCH', 'OPTIONS');
3116+
$test->chainRequests('PATCH', 'SEARCH');
30913117
$test->chainRequests('PATCH', 'PATCH');
30923118

30933119
$test = new Test();
@@ -3097,7 +3123,8 @@ public function testRequestMethodSuccessivePatchRequests()
30973123
$test->chainRequests('PATCH', 'DELETE', array('d' => '4444'));
30983124
$test->chainRequests('PATCH', 'HEAD', array('e' => '55555'));
30993125
$test->chainRequests('PATCH', 'OPTIONS', array('f' => '666666'));
3100-
$test->chainRequests('PATCH', 'PATCH', array('g' => '7777777'));
3126+
$test->chainRequests('PATCH', 'SEARCH', array('f' => '7777777'));
3127+
$test->chainRequests('PATCH', 'PATCH', array('g' => '88888888'));
31013128
}
31023129

31033130
public function testRequestMethodSuccessiveDeleteRequests()
@@ -3109,6 +3136,7 @@ public function testRequestMethodSuccessiveDeleteRequests()
31093136
$test->chainRequests('DELETE', 'PATCH');
31103137
$test->chainRequests('DELETE', 'HEAD');
31113138
$test->chainRequests('DELETE', 'OPTIONS');
3139+
$test->chainRequests('DELETE', 'SEARCH');
31123140
$test->chainRequests('DELETE', 'DELETE');
31133141

31143142
$test = new Test();
@@ -3118,7 +3146,8 @@ public function testRequestMethodSuccessiveDeleteRequests()
31183146
$test->chainRequests('DELETE', 'PATCH', array('d' => '4444'));
31193147
$test->chainRequests('DELETE', 'HEAD', array('e' => '55555'));
31203148
$test->chainRequests('DELETE', 'OPTIONS', array('f' => '666666'));
3121-
$test->chainRequests('DELETE', 'DELETE', array('g' => '7777777'));
3149+
$test->chainRequests('DELETE', 'SEARCH', array('f' => '7777777'));
3150+
$test->chainRequests('DELETE', 'DELETE', array('g' => '88888888'));
31223151
}
31233152

31243153
public function testRequestMethodSuccessiveHeadRequests()
@@ -3130,6 +3159,7 @@ public function testRequestMethodSuccessiveHeadRequests()
31303159
$test->chainRequests('HEAD', 'PATCH');
31313160
$test->chainRequests('HEAD', 'DELETE');
31323161
$test->chainRequests('HEAD', 'OPTIONS');
3162+
$test->chainRequests('HEAD', 'SEARCH');
31333163
$test->chainRequests('HEAD', 'HEAD');
31343164

31353165
$test = new Test();
@@ -3139,7 +3169,8 @@ public function testRequestMethodSuccessiveHeadRequests()
31393169
$test->chainRequests('HEAD', 'PATCH', array('d' => '4444'));
31403170
$test->chainRequests('HEAD', 'DELETE', array('e' => '55555'));
31413171
$test->chainRequests('HEAD', 'OPTIONS', array('f' => '666666'));
3142-
$test->chainRequests('HEAD', 'HEAD', array('g' => '7777777'));
3172+
$test->chainRequests('HEAD', 'SEARCH', array('g' => '7777777'));
3173+
$test->chainRequests('HEAD', 'HEAD', array('g' => '88888888'));
31433174
}
31443175

31453176
public function testRequestMethodSuccessiveOptionsRequests()
@@ -3150,6 +3181,7 @@ public function testRequestMethodSuccessiveOptionsRequests()
31503181
$test->chainRequests('OPTIONS', 'PUT');
31513182
$test->chainRequests('OPTIONS', 'PATCH');
31523183
$test->chainRequests('OPTIONS', 'DELETE');
3184+
$test->chainRequests('OPTIONS', 'SEARCH');
31533185
$test->chainRequests('OPTIONS', 'HEAD');
31543186
$test->chainRequests('OPTIONS', 'OPTIONS');
31553187

@@ -3159,8 +3191,32 @@ public function testRequestMethodSuccessiveOptionsRequests()
31593191
$test->chainRequests('OPTIONS', 'PUT', array('c' => '333'));
31603192
$test->chainRequests('OPTIONS', 'PATCH', array('d' => '4444'));
31613193
$test->chainRequests('OPTIONS', 'DELETE', array('e' => '55555'));
3162-
$test->chainRequests('OPTIONS', 'HEAD', array('f' => '666666'));
3163-
$test->chainRequests('OPTIONS', 'OPTIONS', array('g' => '7777777'));
3194+
$test->chainRequests('OPTIONS', 'SEARCH', array('g' => '666666'));
3195+
$test->chainRequests('OPTIONS', 'HEAD', array('f' => '7777777'));
3196+
$test->chainRequests('OPTIONS', 'OPTIONS', array('g' => '88888888'));
3197+
}
3198+
3199+
public function testRequestMethodSuccessiveSearchRequests()
3200+
{
3201+
$test = new Test();
3202+
$test->chainRequests('SEARCH', 'GET');
3203+
$test->chainRequests('SEARCH', 'POST');
3204+
$test->chainRequests('SEARCH', 'PUT');
3205+
$test->chainRequests('SEARCH', 'PATCH');
3206+
$test->chainRequests('SEARCH', 'DELETE');
3207+
$test->chainRequests('SEARCH', 'HEAD');
3208+
$test->chainRequests('SEARCH', 'OPTIONS');
3209+
$test->chainRequests('SEARCH', 'SEARCH');
3210+
3211+
$test = new Test();
3212+
$test->chainRequests('SEARCH', 'GET', array('a' => '1'));
3213+
$test->chainRequests('SEARCH', 'POST', array('b' => '22'));
3214+
$test->chainRequests('SEARCH', 'PUT', array('c' => '333'));
3215+
$test->chainRequests('SEARCH', 'PATCH', array('d' => '4444'));
3216+
$test->chainRequests('SEARCH', 'DELETE', array('e' => '55555'));
3217+
$test->chainRequests('SEARCH', 'HEAD', array('f' => '666666'));
3218+
$test->chainRequests('SEARCH', 'OPTIONS', array('g' => '7777777'));
3219+
$test->chainRequests('SEARCH', 'SEARCH', array('g' => '88888888'));
31643220
}
31653221

31663222
public function testMemoryLeak()

0 commit comments

Comments
 (0)