AspectMock
AspectMock copied to clipboard
Cannot verify parent method invocation
It seems like method invocation via verifyInvoked*() only works on double instances but not for parent:: method calls. Example:
class ParentClass {
public function hello() {
echo 'Hello';
}
}
class ChildClass extends ParentClass {
public function hello() {
parent::hello();
echo ' World';
}
}
test::double(ParentClass::class, ['hello']);
$c = new ChildClass();
$c->hello();
How would one verify that ParentClass::hello was invoked?
I have the same problem. If you implement the 'hello' method as a closure and echo something inside it, you can see that this method is actually mocked but verifyInvoked() fails to verfiy this.
I think I have found the issue in Mocker.php:
public function fakeMethodsAndRegisterCalls($class, $declaredClass, $method, $params, $static)
{
...
if (isset($this->classMap[$class])) Registry::registerClassCall($class, $method, $params);
return $result;
}
must be:
public function fakeMethodsAndRegisterCalls($class, $declaredClass, $method, $params, $static)
{
...
if (isset($this->classMap[$declaredClass])) Registry::registerClassCall($declaredClass, $method, $params);
return $result;
}