Skip to content

v1.3.0

Compare
Choose a tag to compare
@sirbrillig sirbrillig released this 27 Jul 03:56
· 165 commits to master since this release

Add PHPUnit Custom Assertions

Add Custom assertions for PHPUnit if you subclass \Spies\TestCase: https://github.com/sirbrillig/spies/blob/master/API.md#phpunit-custom-assertions

class MyTest extends \Spies\TestCase {
    function test_spy_is_called_correctly() {
        $spy = \Spies\make_spy();
        $spy( 'hello', 'world', 7 );
        $spy( 'hello', 'world', 8 );
        $this->assertSpyWasCalledWith( 'hello', 'world', \Spies\any() );
    }
}

These can be used in place of Expectations if you want a more pure PHPUnit test experience. You should still call \Spies\finish_spying(); though in your tearDown method to clear all existing spies and mocks.