bovigo/callmap
Stub and mock PHP method and function calls via a callmap. Define fixed returns, callbacks, consecutive results, or thrown exceptions, then verify invocations and arguments. Works with any unit test framework; argument checks via bovigo/assert or PHPUnit.
#[\ReturnTypeWillChange] to generated proxy methods if a PHP-internal class is mocked to prevent deprecation notices, as their return types available via reflection are not always up to date, e.g. for \XSLTProcessor where reflection delivers no return type information for the single methods of this classget_parent_class() in generated proxyis_callable(['parent', $someMethod])bovigo\callmap\FunctionProxy::returns() and bovigo\callmap\FunctionProxy::throws() so the instance is further recognized as a callable.\IteratorAggregate by providing specific return type
information, as reflection doesn't provide a return type for \IteratorAggregate::getIterator().returns() containing methods that don't have a return type declaration will result in an InvalidArgumentException.This release patches the usage of the deprecated \ReflectionParam::getClass
verify()->wasCalled*(), verify()->receivedNothing()) now increase assertion counter of PHPUnitNewCallable::of() and NewCallable::stub() to callable&\bovigo\callmap\FunctionProxybovigo\callmap\NewInstance::of() and bovigo\callmap\NewInstance::stub() have the proper intersection typebovigo\callmap\ClassProxy::stub(string ...$methods) to allow stubbing of methods
on a proxy instance that otherwise forwards method calls to the original classbovigo\callmap\ClassProxy::mapCalls() and bovigo\callmap\FunctionProxy::mapCall(), deprecated since 3.2.0voidbovigo\callmap\ClassProxy::returns(), bovigo\callmap\ClassProxy::mapCalls() is now an alias for this and should be considered deprecatedbovigo\callmap\FunctionProxy::returns(), bovigo\callmap\FunctionProxy::mapCall() is now an alias for this and should be considered deprecated* added `bovigo\callmap\FunctionProxy::throws()`
call_user_func_array(), instead call functions and methods directlybovigo\callmap\throws() now accepts all instances of \Throwable, not just \Exceptionself was not used correctly and lead to a fatal error when creating callmap instances of interfaces or classes using such a return type hintbovigo\callmap\NewInstance::of() and bovigo\callmap\NewInstance::stub() now throw a bovigo\callmap\ProxyCreationFailure instead of \ReflectionException when creation of proxy failsHow can I help you explore Laravel packages today?