I’m new to PHP Unit and now I have a dilemma.
Function structure is something like this:
function myfunc($arg) {
$data = $anotherobject->myfunc2($arg);
$diffdata = $anotherobject->myfunc3($arg);
return $data. " ".arg. " ". $diffdata;
}
How can I verifiy that the output is what it should be?
Edit:
Jasir is of course also right. The point of unittesting is to test a unit as small as possible. So you would also make tests to cover myfunc2() and myfunc3().
End of edit
Using a stub, you can set myfunc2() and myfunc3() to return a known value. You can then assert the return of myfunc as you would normally do.
Something along the lines of: