r/PHPhelp•
kool171

Mocking php object

Sowww this is not a real help but more a question, how does mockery or php unit mock objects simple bij building a string with php inside it and then eval the code or are they using some elegant ways?

Posted May 6, 2020, 7:53 PM UTC

11
eshad89•

PhpUnit is using eval combined with class reflection. Without eval it will not be possible to create a full featured mock builder.

https://github.com/sebastianbergmann/phpunit-mock-objects/blob/0dfddc236629eb7ead4df2dfa3d79d548e011a3b/src/Generator.php#L610

1