PHP code example of kagency / http-replay

1. Go to this page and download the library: Download kagency/http-replay 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/ */

    

kagency / http-replay example snippets


$messageHandler = new MessageHandler\Symfony2();
$filter = new ResponseFilter\Dispatcher(array(
    new ResponseFilter\Json(),
    new ResponseFilter\Headers(array(
        'date',
        'etag',
    )),
));

$reader = new Reader\MitmDump($messageHandler);
$interactions = $reader->readInteractions('recordFile.tns');

foreach ($interactions as $interaction) {
    $actualResponse = $app->runRequest($interaction->request);

    $this->assertEquals(
        $filter->filterResponse($messageHandler->simplifyResponse($interaction->request, $interaction->response)),
        $filter->filterResponse($messageHandler->simplifyResponse($interaction->request, $actualResponse))
    );
}