Browse Source

ZF-6142: backport r20908 to trunk

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@20909 44c647ce-9c0f-0410-b52a-842ac1e357ba
matthew 16 years ago
parent
commit
6f56206360
2 changed files with 10 additions and 2 deletions
  1. 2 2
      library/Zend/Dom/Query.php
  2. 8 0
      tests/Zend/Dom/QueryTest.php

+ 2 - 2
library/Zend/Dom/Query.php

@@ -178,12 +178,12 @@ class Zend_Dom_Query
         $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;
         }
 

+ 8 - 0
tests/Zend/Dom/QueryTest.php

@@ -89,6 +89,11 @@ class Zend_Dom_QueryTest extends PHPUnit_Framework_TestCase
         $this->query->setDocument($this->getHtml());
     }
 
+    public function handleError($msg, $code = 0) 
+    {
+        $this->error = $msg;
+    }
+
     public function testConstructorShouldNotRequireArguments()
     {
         $query = new Zend_Dom_Query();
@@ -154,11 +159,14 @@ class Zend_Dom_QueryTest extends PHPUnit_Framework_TestCase
 
     public function testQueryingInvalidDocumentShouldThrowException()
     {
+        set_error_handler(array($this, 'handleError'));
         $this->query->setDocumentXml('some bogus string');
         try {
             $this->query->query('.foo');
+            restore_error_handler();
             $this->fail('Querying invalid document should throw exception');
         } catch (Zend_Dom_Exception $e) {
+            restore_error_handler();
             $this->assertContains('Error parsing', $e->getMessage());
         }
     }