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
The Processor class is marked as final and this makes it difficult to mock in unit tests. In a unit test, I want to hard-code the result of the processing with fixture data as I don't want to test nette/schema, I want to test my code. This is typically done with a mocking library like Mockery, but because the class is final this is not easy to do cleanly.
Mockery\Exception: The class \Nette\Schema\Processor is marked final and its methods cannot be replaced. Classes marked final can be passed in to \Mockery::mock() as instantiated objects to create a partial mock, but only if the mock is not subject to type hinting checks.
Alternatively, consider making an interface for the Processor, leave the Processor class as final and implement the interface. That way unit tests and methods can use the interface and you can still prevent subclassing.
The text was updated successfully, but these errors were encountered:
The
Processor
class is marked as final and this makes it difficult to mock in unit tests. In a unit test, I want to hard-code the result of the processing with fixture data as I don't want to test nette/schema, I want to test my code. This is typically done with a mocking library like Mockery, but because the class is final this is not easy to do cleanly.This results in:
Alternatively, consider making an interface for the Processor, leave the Processor class as final and implement the interface. That way unit tests and methods can use the interface and you can still prevent subclassing.
The text was updated successfully, but these errors were encountered: