PHP code example of pbweb / mimic

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

    

pbweb / mimic example snippets


interface RestClient
{
    public function get($something);
    public function put($something);
}

class MimicRestClient extends MimicActionHandler implements RestClient
{
    public function get($something)
    {
        return $this->handleAction(__FUNCTION__, func_get_args());
    }
    
    public function put($something)
    {
        return $this->handleAction(__FUNCTION__, func_get_args());
    }
}

// In your dependency injection container:
$mimicClient = new MimicRestClient();

// In your test setup:
$mimicClient->enqueue('get', ['cheese'], 'cheese result');

// In your test or in a class which you are testing:
$result = $mimicClient->get('cheese'); // returns 'cheese result'

// Matches any call to update that has 1 as its first argument and any value as its second argument.
$mimicClient->enqueue('update', [1, ArgumentMatchers::any(), 'result');

return $this->handleAction(__FUNCTION__, func_get_args());

$mimic->enableQueue();

$mimic->disableQueue();

$isQueueEnabled = $mimic->isQueueEnabled();

$mimic->enqueue($method, array $argumentList = [], $response = null, $throw = false);

$actionList = $mimic->getQueueContent();

$isFinished = $mimic->isFinished();

$mimic->clearQueue();