Answer the question
In order to leave comments, you need to log in
What is the difference between getMockBuilder and createMock in PHPUnit?
I understand it this way. CreateMock it copies all methods and properties from the original class, but does not call it. But getMockBuilder we can configure before use, for example, use the disableOriginalConstructor () method (I suspect that the constructor will not be copied). Is this true or not? But if this is the case, then I don’t see the point in getMockBuilder, because the methods are not executed anyway and it doesn’t really matter to us whether there is a constructor or not, or getMockBuilder has advantages that I don’t understand. Thanks in advance
Answer the question
In order to leave comments, you need to log in
I will refer to the official documentation :
Take a look at two ways to create identical mock objects:
$mock1 = $this->getMock(MyClass::class, [], [], '', true, false, true);
$mock2 = $this->getMockBuilder(MyClass::class)
->disableOriginalClone()
->getMock();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question