PHP code example of mcustiel / codeception-http-mock

1. Go to this page and download the library: Download mcustiel/codeception-http-mock library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mcustiel / codeception-http-mock example snippets


// YourCest.php
class YourCest extends \Codeception\TestCase\Test
{
    // tests
    public function tryToTest(\AcceptanceTester $I)
    {
        $I->expectRequest()->when()
                ->methodIs('GET')
                ->pathIs('/foo')
            ->then()
                ->body('mocked body')
            ->end();
        $I->doNotExpectAnyOtherRequest();
        $response = file_get_contents('http://localhost:28080/foo');
        $I->assertEquals('mocked body', $response);
    }
}