Index: tests/Zend/Service/Yahoo/OfflineTest.php =================================================================== --- tests/Zend/Service/Yahoo/OfflineTest.php (revision 12417) +++ tests/Zend/Service/Yahoo/OfflineTest.php (working copy) @@ -47,6 +47,10 @@ */ require_once 'Zend/Http/Client/Adapter/Test.php'; +/** + * @see Zend_Service_Yahoo_WebResult + */ +require_once 'Zend/Service/Yahoo/WebResult.php'; /** * @category Zend @@ -531,6 +535,19 @@ $this->assertContains("option 'type'", $e->getMessage()); } } + + /** + * WebResult should check if the result has a Cache section or not + * + * @group ZF-3636 + */ + public function testWebResultCache(){ + // create empty result eg. without cache section + $domDoc = new DOMDocument(); + $element = $domDoc->createElement('Result'); + // this should not result in errors + $webResult = new Zend_Service_Yahoo_WebResult($element); + } } Index: library/Zend/Service/Yahoo/WebResult.php =================================================================== --- library/Zend/Service/Yahoo/WebResult.php (revision 12417) +++ library/Zend/Service/Yahoo/WebResult.php (working copy) @@ -93,8 +93,17 @@ $this->_xpath = new DOMXPath($result->ownerDocument); $this->_xpath->registerNamespace('yh', $this->_namespace); - - $this->CacheUrl = $this->_xpath->query('./yh:Cache/yh:Url/text()', $result)->item(0)->data; - $this->CacheSize = (int) $this->_xpath->query('./yh:Cache/yh:Size/text()', $result)->item(0)->data; + + // check if the cache section exists + $cacheUrl = $this->_xpath->query('./yh:Cache/yh:Url/text()', $result)->item(0); + if ($cacheUrl instanceof DOMNode) + { + $this->CacheUrl = $cacheUrl->data; + } + $cacheSize = $this->_xpath->query('./yh:Cache/yh:Size/text()', $result)->item(0); + if ($cacheSize instanceof DOMNode) + { + $this->CacheSize = (int) $cacheSize->data; + } } }