Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
No warning when class to be mocked doesn't exist #728
I've been investigating an error when running my tests (PHPUnit 3.6):
I finally tracked this down to me having created a mock object of class Foo in one test and in a later test using the real class Foo. When the mock object was created, the class Foo didn't exist so PHPUnit silently created it. I was surprised that PHPUnit didn't warn me about this. I guess there must be a case where this is desirable. Is this a bug or something that needs documenting?
This comment has been minimized.
This comment has been minimized.Show comment Hide comment
Hi, thanks for the bug report.
This is a long standing issue with the Mocking API. It was always able to create new classes and since people depend on it we have to keep it that way for BC reasons.
I'd like to be able to just change how getMock works and add another "createClass" or whatever but well.. bc :(
For the same reason adding a warning wouldn't really work out as we would "break" peoples suites by annoying them with warnings.
The tracking issue for this is sebastianbergmann/phpunit-mock-objects#12