Skip to content

Commit d1b43ef

Browse files
committed
:octocat:
1 parent 46d1c1e commit d1b43ef

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tests/HTTPClientTestAbstract.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,41 @@ public function testInvalidURLException(){
132132
$this->http->request('');
133133
}
134134

135+
136+
public function testCheckParams(){
137+
$data = ['foo' => 'bar', 'whatever' => null, 'nope' => '', 'true' => true, 'false' => false];
138+
139+
$this->assertSame(['foo' => 'bar', 'true' => '1', 'false' => '0'], $this->http->checkQueryParams($data));
140+
$this->assertSame(['foo' => 'bar', 'true' => 'true', 'false' => 'false'], $this->http->checkQueryParams($data, true));
141+
}
142+
143+
144+
public function rawurlencodeDataProvider(){
145+
return [
146+
['some test string!', 'some%20test%20string%21'],
147+
[['some other', 'test string', ['oh wait!', 'this', ['is an', 'array!']]], ['some%20other', 'test%20string', ['oh%20wait%21', 'this', ['is%20an', 'array%21']]]],
148+
];
149+
}
150+
151+
/**
152+
* @dataProvider rawurlencodeDataProvider
153+
*/
154+
public function testRawurlencode($data, $expected){
155+
$this->assertSame($expected, $this->http->rawurlencode($data));
156+
}
157+
158+
public function testBuildHttpQuery(){
159+
160+
$data = ['foo' => 'bar', 'whatever?' => 'nope!'];
161+
162+
$this->assertSame('', $this->http->buildQuery([]));
163+
$this->assertSame('foo=bar&whatever%3F=nope%21', $this->http->buildQuery($data));
164+
$this->assertSame('foo=bar&whatever?=nope!', $this->http->buildQuery($data, false));
165+
$this->assertSame('foo=bar, whatever?=nope!', $this->http->buildQuery($data, false, ', '));
166+
$this->assertSame('foo="bar", whatever?="nope!"', $this->http->buildQuery($data, false, ', ', '"'));
167+
168+
$data['florps'] = ['nope', 'nope', 'nah'];
169+
$this->assertSame('florps="nah", florps="nope", florps="nope", foo="bar", whatever?="nope!"', $this->http->buildQuery($data, false, ', ', '"'));
170+
}
171+
135172
}

0 commit comments

Comments
 (0)