My code looks something like:
class A
{
function foo(&$a, $b)
{
if ($a == 0) {
return false;
} else {
$a = $b + 1;
return true;
}
}
}
class B
{
function foo1($a, $b)
{
$a = new A;
$a->foo($a, $b);
if ($a == 0) {
return false;
}
echo $a;
return true;
}
}
I need to get the value of $a
.
How to mock the function foo()
?
PHPUnit clones the arguments before passing them to the mocked method. There's no work-around for primitive arguments, but for objects you can add a non-public __clone
method to block this behavior.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With