Skip to content

Commit

Permalink
Update documentation addMethods and onlyMethods
Browse files Browse the repository at this point in the history
  • Loading branch information
rebangm committed Oct 6, 2020
1 parent b0af65a commit f032d12
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/test-doubles.rst
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ method being mocked, like in ``with()``.
public function testFunctionCalledTwoTimesWithSpecificArguments(): void
{
$mock = $this->getMockBuilder(stdClass::class)
->setMethods(['set'])
->addMethods(['set'])
->getMock();
$mock->expects($this->exactly(2))
Expand Down Expand Up @@ -658,7 +658,7 @@ argument passes verification and ``false`` otherwise.
$expectedObject = new stdClass;
$mock = $this->getMockBuilder(stdClass::class)
->setMethods(['foo'])
->addMethods(['foo'])
->getMock();
$mock->expects($this->once())
Expand Down Expand Up @@ -733,11 +733,15 @@ Here is a list of methods provided by the Mock Builder:

-

``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.
``onlyMethods(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. Each method must exist in the given mock class.

-

``setMethodsExcept(array $methods)`` can be called on the Mock Builder object to specify the methods that will not be replaced with a configurable test double while replacing all other public methods. This works inverse to ``setMethods()``.
``addMethods(array $methods)`` can be called on the Mock Builder object to specify the methods that don't exist (yet) in the given mock class. The behavior of the other methods remains the same.

-

``setMethodsExcept(array $methods)`` can be called on the Mock Builder object to specify the methods that will not be replaced with a configurable test double while replacing all other public methods. This works inverse to ``onlyMethods()``.

-

Expand Down

0 comments on commit f032d12

Please sign in to comment.