PHP code example of sitphp / doubles

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

    

sitphp / doubles example snippets


// Get a double instance of type "dummy" for class "MyClass"
$my_double = Double::dummy(MyClass::class)->getInstance();

// Get a double instance of type "mock" for class "MyClass"
$my_double = Double::mock(MyClass::class)->getInstance();

// Test that the method "myMethod" is called a least one time
$double::_method('myMethod')->count('>=1');

// Test that the arguments passed to method "myMethod" are "value1" and "value2"
$double::_method('myMethod')->args(['value1', 'value2']);

// Make method "myMethod" return "hello"
$my_double::_method('myMethod')->return('hello');

// Get double instance with config
$my_double = Double::dummy(MyClass::class, [
    'allow_final_doubles' => true,
    'allow_non_existent_classes' => true
])->getInstance();