Issues

ZF-8912: ControllerTestCase failure messages are lacking to identify failure

Description

Lots of failures can happen inside the MVC, however the failure messages of the assertions suck to identify the root cause in this regard. They should all grab the ErrorHandler ACtion plugin if present and check if there is an exception on the stack and print it aswell.

Comments

Some example, should probably be factored out into its own "annotateErrorMessageFromErrorHandler" method:


    public function assertController($controller, $message = '')
    {
        $this->_incrementAssertionCount();
        if ($controller != $this->request->getControllerName()) {
            $msg = sprintf('Failed asserting last controller used <"%s"> was "%s"',
                $this->request->getControllerName(),
                $controller
            );
            $errors = $this->getRequest()->getParam('error_handler');
            if ($errors) {
                if ($errors->exception instanceof Exception) {
                    $msg .= "\nException was catched in Front-Controller:\n[".get_class($errors->exception)."] ".$errors->exception->getMessage()."\n";
                    $msg .= "Stack Trace: ".$errors->exception->getTraceAsString()."\n\n";
                }
            }

            if (!empty($message)) {
                $msg = $message . "\n" . $msg;
            }
            $this->fail($msg);
        }
    }