Skip to content

Commit 268fc72

Browse files
committed
http_build_queryをいじる
1 parent 49b85f7 commit 268fc72

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
namespace tests\Unit\HTTP;
4+
5+
use tests\TestCase;
6+
use GuzzleHttp\Client;
7+
8+
class HttpBuildQueryTest extends TestCase {
9+
10+
public function test_http_build_query(){
11+
$data = ['a'=>1,'b'=>"あ[0]=あああ",'names'=>['a','b','c'],'assoc'=>['key'=>'value']];
12+
$ret = http_build_query($data,false,null,PHP_QUERY_RFC3986);
13+
$ret = preg_replace('/%5B(?:[0-9]|[1-9][0-9]+)%5D=/', '%5B%5D=', $ret);
14+
//
15+
$this->assertStringNotContainsString('names[0]=', urldecode($ret));
16+
$this->assertStringContainsString('names[]=', urldecode($ret));
17+
$this->assertStringContainsString('あ[0]=', urldecode($ret));
18+
}
19+
//public function test_guzzle_http(){
20+
// $cli = new Client(['base_uri' => 'http://localhost:8080']);
21+
// $ret = $cli->request('GET','/?b[]=1',['query'=>'a=1']);
22+
// dd($ret->getBody()->getContents());
23+
//}
24+
25+
}

0 commit comments

Comments
 (0)