How to destroy the controller #2137
Replies: 1 comment
-
The somewhat flippant answer to "how to properly destroy it" depends on what you do inside it. If you do anything odd (creating dangling references / messing with refcounts) then you might have to take care to implement proper cleanup yourself. Doing leak-testing will tell you if this is required. Though, for most use cases nothing fancy is requires. Looking at the provided code I do wonder if you might be overcomplicating something. I do not think I have ever needed to mock a controller, and we do heavy testing at $work. Usually we just instantiate our apps for testing using |
Beta Was this translation helpful? Give feedback.
-
Hello,
please help.
In our tests, we are instantiating the mocked controller like this:
... where
$class
inherits from the base controller.Internally, this opens a filehandle to the log, creates a database connection, etc.
How to properly destroy it? I could write a teardown method to close the handle, close the connection, and undef the controller, but I'm not sure if it'd be complete.
Beta Was this translation helpful? Give feedback.
All reactions