Quantcast
Viewing all articles
Browse latest Browse all 3667

PHPUnit - REST API testing


I have REST API written in php, i want to test it with phpunit.

I wrote test like this, it works but response body was empty. I tested it with fiddler, it send response body.

Sorry for my english.

class ProgrammerControllerTest extends PHPUnit_Framework_TestCase{    public function testPOST()    {       // create our http client (Guzzle)    $client = new Guzzle\Http\Client();    $response = $client->post("http://api.loc/v2/", array('headers' => "User-Agent: Fiddler\r\n" ."Host: api.loc\r\n"."Content-Type: application/x-www-form-urlencoded\r\n"."Content-Length: 34\r\n",'body'    => array('kle' =>'sino','lat' => '41', 'long' => '69'),    ));    var_dump($response);    }} 

Viewing all articles
Browse latest Browse all 3667

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>