I am kind of new to testing and I would like to understand how testing is implemented in a real world scenario. For instance, There is this code which implements an internal framework, and employs method chaining. At first glance I assumed mocking would be the best way to go, but most examples go this way:
public function someFunction(A $a)
{
return $a * b;
}
However, the code I am testing goes this way:
public function deleteUser($user_id)
{
$user_id = (int)$user_id;
$flag = Framework::getInstance()->request->get('delete') || false;
if (!$this->exists($user_id)) {
throw new UserException(UserException::NOT_EXIST);
}
return $this->delete([
'id' => $user_id
]);
}
How would you test it?
I have looked at "Testing objects with dependencies in PHPUnit", but modifying the actual code is not an option.