You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/test-doubles.rst
+8-4
Original file line number
Diff line number
Diff line change
@@ -610,7 +610,7 @@ method being mocked, like in ``with()``.
610
610
public function testFunctionCalledTwoTimesWithSpecificArguments(): void
611
611
{
612
612
$mock = $this->getMockBuilder(stdClass::class)
613
-
->setMethods(['set'])
613
+
->addMethods(['set'])
614
614
->getMock();
615
615
616
616
$mock->expects($this->exactly(2))
@@ -681,7 +681,7 @@ argument passes verification and ``false`` otherwise.
681
681
$expectedObject = new stdClass;
682
682
683
683
$mock = $this->getMockBuilder(stdClass::class)
684
-
->setMethods(['foo'])
684
+
->addMethods(['foo'])
685
685
->getMock();
686
686
687
687
$mock->expects($this->once())
@@ -756,11 +756,15 @@ Here is a list of methods provided by the Mock Builder:
756
756
757
757
-
758
758
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.
760
760
761
761
-
762
762
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()``.
0 commit comments