It's amazing what a simple "@" can do to a line of code in PHP :)

hvir...@hector-mac:~/Web/library/ZendFramework-1.10.1$ svn diff -r
20701:21134 library/Zend/Dom/Query.php
Index: library/Zend/Dom/Query.php
===================================================================
--- library/Zend/Dom/Query.php
(.../branches/release-1.10/library/Zend/Dom/Query.php) (revision 20701)
+++ library/Zend/Dom/Query.php
(.../tags/release-1.10.1/library/Zend/Dom/Query.php) (revision 21134)
@@ -178,12 +178,12 @@
         $type   = $this->getDocumentType();
         switch ($type) {
             case self::DOC_XML:
-                $success = @$domDoc->loadXML($document);
+                $success = $domDoc->loadXML($document);
                 break;
             case self::DOC_HTML:
             case self::DOC_XHTML:
             default:
-                $success = @$domDoc->loadHTML($document);
+                $success = $domDoc->loadHTML($document);
                 break;
         }

So this explains why it worked in 1.10.0 and not in 1.10.1. Since PHPUnit
automatically promotes all warnings to exceptions, errors in loading the
HTML causes PHPUnit tests to fail.

As mentioned in the DOMDocument documentation (ha, what a mouthful!),
perhaps ZF should be handling these errors with a custom error handler:

http://us3.php.net/manual/en/domdocument.loadhtml.php

It seems the issue tracker is being worked on at the moment so I'll wait
until later to file the bug.

--
Hector


On Mon, Feb 22, 2010 at 1:58 PM, Hector Virgen <[email protected]> wrote:

> After some more testing I found the cause of the problem. My layout
> contains a small snippet of javascript:
>
> <script type="text/javascript">
> //<![CDATA[
> document.write('<a href="?enhanced=1" class="switch_modes">Switch to
> Enhanced Mode</a>');
> //]]>
> </script>
>
> As you can see, the script body is properly enclosed in a CDATA section,
> but it seems that Zend_Dom_Query insists on interpreting the script as HTML.
> Removing the document.write() line allows the unit tests to run and pass.
>
> I'm still not sure why this works fine in 1.10.0 but not 1.10.1. I'm going
> to take a look at the diff to see what has changed to see if I can correct
> this.
>
> If anyone has any pointers or suggestions, let me know. I would prefer to
> not have to create a one-line javascript file.
>
> --
> Hector
>
>
>
> On Tue, Feb 16, 2010 at 2:49 PM, Hector Virgen <[email protected]> wrote:
>
>> Is anyone else experiencing problems with
>> Zend_Test_PHPUnit_ControllerTestCase#assertQuery() in 1.10.1?
>>
>> In 1.10.0, my unit tests were passing successfully, but after upgrading to
>> 1.10.1, all of my assertQuery() tests result in the same error:
>>
>> 1) UsersControllerTest::testNotLoggedInOnLoginPageDoesNotCauseRedirection
>> DOMDocument::loadHTML(): Unexpected end tag : a in Entity, line: 30
>>
>>
>> /Users/hvirgen/Web/library/ZendFramework-1.10.1/library/Zend/Dom/Query.php:186
>>
>> /Users/hvirgen/Web/library/ZendFramework-1.10.1/library/Zend/Dom/Query.php:160
>>
>> /Users/hvirgen/Web/library/ZendFramework-1.10.1/library/Zend/Test/PHPUnit/Constraint/DomQuery.php:157
>>
>> /Users/hvirgen/Web/library/ZendFramework-1.10.1/library/Zend/Test/PHPUnit/ControllerTestCase.php:290
>>
>> /Users/hvirgen/Web/projects/datadirector3/tests/application/controllers/UsersControllerTest.php:17
>>
>> I have verified that the response body is valid XHTML, so I'm not sure why
>> it's saying there's a broken anchor.
>>
>> --
>> Hector
>>
>
>

Reply via email to