PHP code example of aeris / spy

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

    

aeris / spy example snippets


$spy = new Spy();

$spy(5);
$spy(6);
$spy(7);

$spy->shouldHaveBeenCalled()
  ->twice()
  ->with(\Mockery::on(function($arg) {
    return $arg > 5;
  )))

$spy = new Spy();

$spy();

$spy->shouldHaveBeenCalled();  // Passes (no exception)
$spy->shouldNotHaveBeenCalled(); // Failed (throws \Mockery\Exception\InvalidCountException)

$spy = new Spy();
$spy->andReturn('foo');

$spy();  // 'foo'

$spy = new Spy()
$spy->andReturnUsing(function($str) {
  strtoupper($str);
});

$spy('foo');  // 'FOO'

$spy = Spy::returns('foo');

$spy(); 	// 'foo'

$spy = Spy::returnsUsing(function($str) {
  strtoupper($str);
});

$spy('foo'); 	// 'FOO'