Skip to content

Commit 6f504c7

Browse files
rebangmsebastianbergmann
authored andcommitted
Update documentation addMethods and onlyMethods
1 parent 48214a3 commit 6f504c7

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/test-doubles.rst

+8-4
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ method being mocked, like in ``with()``.
610610
public function testFunctionCalledTwoTimesWithSpecificArguments(): void
611611
{
612612
$mock = $this->getMockBuilder(stdClass::class)
613-
->setMethods(['set'])
613+
->addMethods(['set'])
614614
->getMock();
615615
616616
$mock->expects($this->exactly(2))
@@ -681,7 +681,7 @@ argument passes verification and ``false`` otherwise.
681681
$expectedObject = new stdClass;
682682
683683
$mock = $this->getMockBuilder(stdClass::class)
684-
->setMethods(['foo'])
684+
->addMethods(['foo'])
685685
->getMock();
686686
687687
$mock->expects($this->once())
@@ -756,11 +756,15 @@ Here is a list of methods provided by the Mock Builder:
756756

757757
-
758758

759-
``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.
759+
``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.
760760

761761
-
762762

763-
``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()``.
763+
``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.
764+
765+
-
766+
767+
``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()``.
764768

765769
-
766770

0 commit comments

Comments
 (0)