jeudi 27 avril 2017

API Phpunit Test issue

I'm having issue with testing of restful api using phpunit test. I have an endpoint like http://ift.tt/2oA5irb, when try to run it thru postman or browser it working fine i see the results but when try to run it using phpunit the response is "No record found" here's the code of my test:

/**
 * @group userendpoint
 */
public function test_user_endpoint(){
    $response = $this->get('http://ift.tt/2qapIUQ');
    if($response->getStatusCode() !== 200){
        print json_decode($response->getContent())->msg;
    }

    $this->assertEquals(200, $response->getStatusCode());
    $data = json_decode($response->getContent(), true);
    $this->assertArrayHasKey('profile', $data);
}

It's kinda weird error for me, because it can get the record using browser and postman. Is there any wrong in my code. Please advise, thanks



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire