Extending Laravel's Codeception module (for better AJAX testing)

Submitted by Mahmoud_Zalt - 8 years ago

1 . remove the Laravel4 module from the functional.suite.yml 2. codeception build 3. inside the FunctionalHelper, do extend the \Codeception\Module\Laravel4 4. and there add your extra Laravel functions.

Some VIP functions:
-------------------

    public function grabOriginalResponse()
    {
        return $this->client->getInternalResponse();
    }

    public function grabJSONResponse()
    {
        return json_decode($this->grabResponse());
    }

    public function grabResponse()
    {
        $response = $this->client->getInternalResponse();
        return $response->getContent();
    }

    public function grabResponseAsArray()
    {
        return (array) $this->grabJSONResponse();
    }






>> In your TestClassCest use those functions and Laravel module functions normally
example:
-------------------


        $I->sendAjaxGetRequest($endpoint, $options);

        $response = $I->grabResponse();

        dd($response);