Issues

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

Issue Type: Improvement Created: 2010-01-24T03:28:57.000+0000 Last Updated: 2012-11-20T21:37:37.000+0000 Status: Open Fix version(s): Reporter: Benjamin Eberlei (beberlei) Assignee: None Tags: - Zend_Test_PHPUnit

Related issues: Attachments:

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

Posted by Benjamin Eberlei (beberlei) on 2010-01-24T03:44:14.000+0000

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

<pre class="highlight">
    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);
        }
    }

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts