PHPUnit testing generating Zend_Dom_Exception

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

PHPUnit testing generating Zend_Dom_Exception

Ian Munday
I'm getting up and running with PHPUnit after following the video  
tutorial and other resources at http://www.zendcasts.com/unit-testing-with-the-zend-framework-with-zend_test-and-phpunit/

However, when using the methods  assertQueryContentContains() or  
assertXpathContentContains(), I get the following exception:

Zend_Dom_Exception: Error parsing document (type == docXml)

Other methods such as assertModule(), assertController(),  
assertAction() and assertResponseCode() are working fine.

Has anyone else encountered this, or have clues as to how to fix?

Regards,

Ian
Reply | Threaded
Open this post in threaded view
|

Re: PHPUnit testing generating Zend_Dom_Exception

weierophinney
Administrator
-- Ian Munday <[hidden email]> wrote
(on Saturday, 19 September 2009, 04:34 PM +0100):

> I'm getting up and running with PHPUnit after following the video  
> tutorial and other resources at
> http://www.zendcasts.com/unit-testing-with-the-zend-framework-with-zend_test-and-phpunit/
>
> However, when using the methods  assertQueryContentContains() or  
> assertXpathContentContains(), I get the following exception:
>
> Zend_Dom_Exception: Error parsing document (type == docXml)
>
> Other methods such as assertModule(), assertController(), assertAction()
> and assertResponseCode() are working fine.
>
> Has anyone else encountered this, or have clues as to how to fix?

If you're getting an "error parsing document", then it's usually a
matter of ext/dom being unable to parse it. This most frequently happens
if you set the document as XML, but it has invalid markup. One thing to
note: DOMDocument::loadHTML() is typically *far* more forgiving of
markup errors than DOMDocument::loadXML() -- so make sure that if you're
claiming your document is XML or XHTML+XML that it's completely valid
XML markup.

--
Matthew Weier O'Phinney
Project Lead            | [hidden email]
Zend Framework          | http://framework.zend.com/
Reply | Threaded
Open this post in threaded view
|

Re: PHPUnit testing generating Zend_Dom_Exception

Ian Munday
Matthew Weier O'Phinney-3 wrote
If you're getting an "error parsing document", then it's usually a
matter of ext/dom being unable to parse it. This most frequently happens
if you set the document as XML, but it has invalid markup. One thing to
note: DOMDocument::loadHTML() is typically *far* more forgiving of
markup errors than DOMDocument::loadXML() -- so make sure that if you're
claiming your document is XML or XHTML+XML that it's completely valid
XML markup.
My document was not in fact valid XML, but my document was claiming to be by starting with "<?xml version="1.0"?>".  Removing this solved the problem.

Regards,

Ian