duankeng2026 2010-02-22 13:15
浏览 41

测试返回HTML5的Zend Framework控制器

I have a controller test case that looks like the following:

class LoginControllerTest extends Zend_Test_PHPUnit_ControllerTestCase
{
    public function testLoginFormIsShown()
    {
        $this->dispatch('/login');
        $this->assertQuery('form#login');
    }
}

However our site is written using HTML5 and contains elements like <HEADER>, which creates a warning when ZF internally calles DomDocument::loadHtml() on the output:

1) LoginControllerTest::testLoginFormIsShown
DOMDocument::loadHTML(): Tag header invalid in Entity, line: 8

How can I either tell ZF not to pass this error through, or get PHPUnit to not regard the Warning as an error? I don't want to turn down error reporting for the whole test suite.

EDIT:

Adding @expectedException PHPUnit_Framework_Error_Warning to the test method supresses the failure, but hides any subsequent errors (and in fact doesn't even run the query).

EDIT AGAIN:

There doesn't seem to be a sensible resolution to this so I've ended up adding an @ in front of the breaking assertions for now.

  • 写回答

1条回答 默认 最新

  • dongmu9253 2010-02-22 13:19
    关注

    Looks like DOMDocument takes issue with html5. You can try Xpath:

    $this->assertXpath("//form[@id = 'login']");
    
    评论

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效