<i id='JM8w5'><tr id='JM8w5'><dt id='JM8w5'><q id='JM8w5'><span id='JM8w5'><b id='JM8w5'><form id='JM8w5'><ins id='JM8w5'></ins><ul id='JM8w5'></ul><sub id='JM8w5'></sub></form><legend id='JM8w5'></legend><bdo id='JM8w5'><pre id='JM8w5'><center id='JM8w5'></center></pre></bdo></b><th id='JM8w5'></th></span></q></dt></tr></i><div id='JM8w5'><tfoot id='JM8w5'></tfoot><dl id='JM8w5'><fieldset id='JM8w5'></fieldset></dl></div>
<tfoot id='JM8w5'></tfoot>

  1. <small id='JM8w5'></small><noframes id='JM8w5'>

  2. <legend id='JM8w5'><style id='JM8w5'><dir id='JM8w5'><q id='JM8w5'></q></dir></style></legend>

        <bdo id='JM8w5'></bdo><ul id='JM8w5'></ul>

      使用 PHPUnit 和 Zend 框架测试异常的问题

      Problem testing exceptions with PHPUnit and Zend Framework(使用 PHPUnit 和 Zend 框架测试异常的问题)
      <i id='Nqva9'><tr id='Nqva9'><dt id='Nqva9'><q id='Nqva9'><span id='Nqva9'><b id='Nqva9'><form id='Nqva9'><ins id='Nqva9'></ins><ul id='Nqva9'></ul><sub id='Nqva9'></sub></form><legend id='Nqva9'></legend><bdo id='Nqva9'><pre id='Nqva9'><center id='Nqva9'></center></pre></bdo></b><th id='Nqva9'></th></span></q></dt></tr></i><div id='Nqva9'><tfoot id='Nqva9'></tfoot><dl id='Nqva9'><fieldset id='Nqva9'></fieldset></dl></div>
    1. <tfoot id='Nqva9'></tfoot>
        <bdo id='Nqva9'></bdo><ul id='Nqva9'></ul>

                <tbody id='Nqva9'></tbody>

              • <small id='Nqva9'></small><noframes id='Nqva9'>

                <legend id='Nqva9'><style id='Nqva9'><dir id='Nqva9'><q id='Nqva9'></q></dir></style></legend>
              • 本文介绍了使用 PHPUnit 和 Zend 框架测试异常的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                当用户在没有正确的 post 参数的情况下访问/user/validate 时,我的 Zend 应用程序会抛出一个 zend 异常.(我收到标准的发生错误"消息,在我的布局中框起来了).这是故意的.

                When a user accesses /user/validate without the correct post parameters, my Zend application throws a zend exception. (I get the standard "An Error Occurred" message, framed within my layout). This is intentional.

                我现在正在尝试使用 PHPUnit 测试该行为.这是我的测试:

                I am now trying to test that behaviour with PHPUnit. Here's my test:

                /**
                 * @expectedException Zend_Exception
                 */
                public function testEmptyUserValidationParametersCauseException() {
                    $this->dispatch('/user/validate');
                }
                

                当我运行测试时,我收到一条消息,说它失败了,预期异常 Zend_Exception".有什么想法吗?

                When I run the test I get a message saying it failed, "Expected exception Zend_Exception". Any ideas?

                我在文件中有其他测试工作正常...

                I have other tests in the file which are working just fine...

                谢谢!

                推荐答案

                Zend_Controller_Plugin_ErrorHandler 插件为您处理异常,默认的 Error_Controller 强制执行 500 重定向,这可能意味着您正在测试的异常不再存在.尝试以下单元测试,看看它是否通过:

                The Zend_Controller_Plugin_ErrorHandler plugin handles exceptions for you and the default Error_Controller forces a 500 redirect which may mean the exception you are testing for no longer exists. Try the following unit test and see if it passes:

                public function testUnknownUserRedirectsToErrorPage()
                {
                    $this->dispatch('/user/validate');
                    $this->assertController('error');
                    $this->assertAction('error');
                    $this->assertResponseCode('500');
                }
                

                如果这有效,则表明当您呈现错误视图时,异常将不再存在,因为它包含在重定向之前的代码中.

                If this works then it shows that by the time you are rendering the error view the exception will no longer exist as it is contained in the code before the redirect.

                这篇关于使用 PHPUnit 和 Zend 框架测试异常的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                  <tbody id='LK4kk'></tbody>

                <legend id='LK4kk'><style id='LK4kk'><dir id='LK4kk'><q id='LK4kk'></q></dir></style></legend>

                  <bdo id='LK4kk'></bdo><ul id='LK4kk'></ul>
                  <i id='LK4kk'><tr id='LK4kk'><dt id='LK4kk'><q id='LK4kk'><span id='LK4kk'><b id='LK4kk'><form id='LK4kk'><ins id='LK4kk'></ins><ul id='LK4kk'></ul><sub id='LK4kk'></sub></form><legend id='LK4kk'></legend><bdo id='LK4kk'><pre id='LK4kk'><center id='LK4kk'></center></pre></bdo></b><th id='LK4kk'></th></span></q></dt></tr></i><div id='LK4kk'><tfoot id='LK4kk'></tfoot><dl id='LK4kk'><fieldset id='LK4kk'></fieldset></dl></div>

                  • <small id='LK4kk'></small><noframes id='LK4kk'>

                  • <tfoot id='LK4kk'></tfoot>