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
Class "myEntity" is declared "final" and cannot be mocked. Essentially if one makes a call to a method on which isn't mocked it appears as though phpunit will try to mock that method onto a parameter passed to the mock object with the previously mentioned none existant method
Current behavior
Create a mock object and mock a single method which takes a parameter which returns that same parameter with the use of willReturn() and sets an expectation to call it at least once. If you call the a method which you didn't mock and pass the parameter to it phpunit does something very odd it looks like its trying to modify the parameter I passed. The test however still passes and it should certainly fail. This behavior seems similar to bug #3607
Currently this test passed and it should certainly fail. I think it should also throw an error due to an unmet expectation and not to try to alter any passed parameters
The text was updated successfully, but these errors were encountered:
The getMockForAbstractClass() method returns a mock object for an abstract class. All abstract methods of the given abstract class are mocked. This allows for testing the concrete methods of an abstract class.
Even if you use setMethod() to specify a subset of methods to mock, getMockForAbstractClass() will mock all abstract methods. (Otherwise the class could not be instantiated.)
So your expectation, that the method insert() is not mocked is not valid. And once PHPUnit tries to fulfill it's duty to dynamically create a return object for that method it will fail with the expected message Class "myEntity" is declared "final" and cannot be mocked..
Please remember: PHPUnit has no means to know that you expect mytestInterface::update() to use the parameter as the return value unless you configure the mock accordingly. That's why it tires to "magically" create a new object of type myEntity.
Summary
Class "myEntity" is declared "final" and cannot be mocked. Essentially if one makes a call to a method on which isn't mocked it appears as though phpunit will try to mock that method onto a parameter passed to the mock object with the previously mentioned none existant method
Current behavior
Create a mock object and mock a single method which takes a parameter which returns that same parameter with the use of willReturn() and sets an expectation to call it at least once. If you call the a method which you didn't mock and pass the parameter to it phpunit does something very odd it looks like its trying to modify the parameter I passed. The test however still passes and it should certainly fail. This behavior seems similar to bug #3607
How to reproduce
Expected behavior
Currently this test passed and it should certainly fail. I think it should also throw an error due to an unmet expectation and not to try to alter any passed parameters
The text was updated successfully, but these errors were encountered: