library mockery-callable-mock
Mockery Callable Mock
tmarsteel/mockery-callable-mock
Mockery Callable Mock
- Friday, September 15, 2017
- by tmarsteel
- Repository
- 1 Watchers
- 0 Stars
- 110 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 2 Forks
- 0 Open issues
- 5 Versions
- 1 % Grown
Mockery Callable Mock
<?php
use Akamon\MockeryCallableMock\MockeryCallableMock;
// creating a mockery function/callable
$mock = new MockeryCallableMock();
// call it normally
$mock('foo', 'bar');
call_user_func($mock, 'foo', 'bar');
// add it expectations
$mock->shouldBeCalled(); // returns a mockery expectation, so you can use it normally
$mock->shouldBeCalled()->with('foo')->once();
$mock('foo');
$mock->shouldBeCalled()->withNoArgs()->twice();
$mock();
$mock();
// returned values
$mock->shouldBeCalled()->andReturn('foo');
$retval = $mock();
// creating stubs
$stub = new MockeryCallableMock();
$stub->canBeCalled()->with('foo')->andReturn('bar');
// verifying calls
$mock = new MockeryCallableMock();
$mock('bar');
$mock->shouldHaveBeenCalled()->with('bar');
$mock->shouldNotHaveBeenCalled('foo');
// spying
$realAction = function($arg1, $arg2) { /* ... */ }; // or
$realAction = [$this, 'methodToInvoke'];
$callableSpy = new MockeryCallableMock($realAction);
$callableSpy(); // $realAction gets invoked
$callableSpy()->shouldHaveBeenCalled();
Requirements
PHP 7.0+, (*1)
Authors
License
Akamon Mockery Callable Mock is licensed under the MIT License. See the LICENSE file for full details., (*2)
dev-master
9999999-dev
Mockery Callable Mock
Sources
Download
MIT
The Requires
The Development Requires
by
Tobias Marstaller
mock
mockery
callable
v2.1.0
2.1.0.0
Mockery Callable Mock
Sources
Download
MIT
The Requires
The Development Requires
by
Tobias Marstaller
mock
mockery
callable
v2.0.0
2.0.0.0
Mockery Callable Mock
Sources
Download
MIT
The Requires
The Development Requires
by
Tobias Marstaller
mock
mockery
callable
2.0.0-RC1
2.0.0.0-RC1
Mockery Callable Mock
Sources
Download
MIT
The Requires
The Development Requires
mock
mockery
callable
v1.0.0
1.0.0.0
Mockery Callable Mock
Sources
Download
MIT
The Requires
The Development Requires
mock
mockery
callable