From f032d12ec500747bab97a5a54c1d642f6e476189 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Philippe=20D=C3=A9pigny?= Date: Mon, 5 Oct 2020 20:43:37 +0200 Subject: [PATCH] Update documentation addMethods and onlyMethods --- src/test-doubles.rst | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/test-doubles.rst b/src/test-doubles.rst index 7411af1f5..d6e795538 100644 --- a/src/test-doubles.rst +++ b/src/test-doubles.rst @@ -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)) @@ -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()) @@ -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()``. -