Mocking framework based on Mockito for Java
(C) 2011 Hamish Friedlander / SilverStripe. Distributable under the same license as SilverStripe.
Example usage:
Create the mock
$iterator = Phockito.mock('ArrayIterator);
Use the mock object - doesn't do anything, functions return null
$iterator->append('Test');
$iterator->asort();
Selectively verify execution
Phockito::verify($iterator)->append('Test');
1 is default - can also do 2, 3 for exact numbers, or 1+ for at least one, or 0 for never
Phockito::verify($iterator, 1)->asort();
Example stubbing:
Create the mock
$iterator = Phockito.mock('ArrayIterator);
Stub in a value
Phockito::when($iterator->offsetGet(0))->return('first');
Prints "first"
print_r($iterator->offsetGet(0));
Prints null, because get(999) not stubbed
print_r($iterator->offsetGet(999));
Note that several functions are declared as public so that builder classes can access them. Anything
starting with an "_" is for internal consumption only