X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=tests%2FHttpRequest_004.phpt;fp=tests%2FHttpRequest_004.phpt;h=f6094bb03580879b78e58890c5541795606c2547;hb=b9045f99a675bcdf7d8f96a8ffb4885459f39f63;hp=0000000000000000000000000000000000000000;hpb=24a9fbbdd1666d8bffb5cb771544f73fbf9a4ff1;p=m6w6%2Fext-http diff --git a/tests/HttpRequest_004.phpt b/tests/HttpRequest_004.phpt new file mode 100644 index 0000000..f6094bb --- /dev/null +++ b/tests/HttpRequest_004.phpt @@ -0,0 +1,166 @@ +--TEST-- +HttpRequest multiple posts +--SKIPIF-- + +--FILE-- + 1, 'dbl' => M_PI), + array('str' => 'something', 'nil' => null) +); + +echo "\nFirst Request\n"; +$r = new HttpRequest('http://dev.iworks.at/.print_request.php', HttpRequest::METH_POST); +$r->setPostFields($fields[0]); +$r->addPostFields($fields[1]); +var_dump($r->send()->getBody()); +var_dump($fields); + +echo "\nSecond Request\n"; +$r->setPostFields($fields); +var_dump($r->send()->getBody()); +var_dump($fields); + +echo "\nThird Request\n"; +$r->addPostFields(array('x' => 'X')); +var_dump($r->send()->getBody()); +var_dump($fields); + +echo "\nFourth Request\n"; +$r->setPostFields(array()); +var_dump($r->send()->getBody()); +var_dump($fields); + +echo "Done\n"; +?> +--EXPECTF-- +%sTEST + +First Request +string(150) "Array +( + [int] => 1 + [dbl] => 3.1415926535898 + [str] => something + [nil] => +) +string(44) "int=1&dbl=3.1415926535898&str=something&nil=" + +" +array(2) { + [0]=> + array(2) { + ["int"]=> + int(1) + ["dbl"]=> + float(3.1415926535898) + } + [1]=> + array(2) { + ["str"]=> + string(9) "something" + ["nil"]=> + NULL + } +} + +Second Request +string(270) "Array +( + [0] => Array + ( + [int] => 1 + [dbl] => 3.1415926535898 + ) + + [1] => Array + ( + [str] => something + [nil] => + ) + +) +string(56) "0[int]=1&0[dbl]=3.1415926535898&1[str]=something&1[nil]=" + +" +array(2) { + [0]=> + array(2) { + ["int"]=> + int(1) + ["dbl"]=> + float(3.1415926535898) + } + [1]=> + array(2) { + ["str"]=> + string(9) "something" + ["nil"]=> + NULL + } +} + +Third Request +string(287) "Array +( + [0] => Array + ( + [int] => 1 + [dbl] => 3.1415926535898 + ) + + [1] => Array + ( + [str] => something + [nil] => + ) + + [x] => X +) +string(60) "0[int]=1&0[dbl]=3.1415926535898&1[str]=something&1[nil]=&x=X" + +" +array(2) { + [0]=> + array(2) { + ["int"]=> + int(1) + ["dbl"]=> + float(3.1415926535898) + } + [1]=> + array(2) { + ["str"]=> + string(9) "something" + ["nil"]=> + NULL + } +} + +Fourth Request +string(14) "string(0) "" + +" +array(2) { + [0]=> + array(2) { + ["int"]=> + int(1) + ["dbl"]=> + float(3.1415926535898) + } + [1]=> + array(2) { + ["str"]=> + string(9) "something" + ["nil"]=> + NULL + } +} +Done +