sebastianbergmann/phpunit-documentation — Issue #51: Document setMethods(null)
Author: bskendig
Created: 2012-02-23 16:16:10+00:00
State: open

The PHPUnit call "setMethods()" can be called with "null" as an argument if you don't want to mock any methods on an object. This is useful if the only purpose you're mocking an object is so you can avoid calling its constructor, and you need to call a real method on that object to test it. setMethods(null) isn't covered in the PHPUnit documentation, however.

I recommend that two lines on "http://www.phpunit.de/manual/3.6/en/test-doubles.html" be modified:

* When an array is provided as the second (optional) parameter, only the methods whose names are in the array are replaced with a configurable test double. The behavior of the other methods is not changed. Providing NULL as the parameter means that no methods will be replaced.

* setMethods(array $methods) can be called on the Mock Builder object to specify the methods that are to be replaced with a configurable test double. The behavior of the other methods is not changed. If you call setMethods(NULL), then no methods will be replaced.