开发者

Testing Zend Framework controllers that return HTML5

开发者 https://www.devze.com 2022-12-21 01:38 出处:网络
I have a controller test case that looks like the following: class LoginControllerTest extends Zend_Test_PHPUnit_ControllerTestCase

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 sens开发者_StackOverflowible resolution to this so I've ended up adding an @ in front of the breaking assertions for now.


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

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

精彩评论

暂无评论...
验证码 换一张
取 消