Pārlūkot izejas kodu

fixes ZF-11490 Zend Json Server error response with result

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@24251 44c647ce-9c0f-0410-b52a-842ac1e357ba
mcleod@spaceweb.nl 14 gadi atpakaļ
vecāks
revīzija
3d35a0d427

+ 0 - 2
library/Zend/Json/Server/Response.php

@@ -173,7 +173,6 @@ class Zend_Json_Server_Response
     {
         if ($this->isError()) {
             $response = array(
-                'result' => null,
                 'error'  => $this->getError()->toArray(),
                 'id'     => $this->getId(),
             );
@@ -181,7 +180,6 @@ class Zend_Json_Server_Response
             $response = array(
                 'result' => $this->getResult(),
                 'id'     => $this->getId(),
-                'error'  => null,
             );
         }
 

+ 4 - 3
tests/Zend/Json/Server/ResponseTest.php

@@ -143,7 +143,8 @@ class Zend_Json_Server_ResponseTest extends PHPUnit_Framework_TestCase
 
         $this->assertTrue(is_array($test));
         $this->assertTrue(array_key_exists('result', $test));
-        $this->assertTrue(array_key_exists('error', $test));
+        // assertion changed to false, because 'error' may not coexist with 'result'
+        $this->assertFalse(array_key_exists('error', $test), "'error' may not coexist with 'result'");
         $this->assertTrue(array_key_exists('id', $test));
         $this->assertTrue(array_key_exists('jsonrpc', $test));
 
@@ -164,7 +165,7 @@ class Zend_Json_Server_ResponseTest extends PHPUnit_Framework_TestCase
         $test = Zend_Json::decode($json);
 
         $this->assertTrue(is_array($test));
-        $this->assertTrue(array_key_exists('result', $test));
+        $this->assertFalse(array_key_exists('result', $test), "'result' may not coexist with 'error'");
         $this->assertTrue(array_key_exists('id', $test));
         $this->assertFalse(array_key_exists('jsonrpc', $test));
 
@@ -182,7 +183,7 @@ class Zend_Json_Server_ResponseTest extends PHPUnit_Framework_TestCase
 
         $this->assertTrue(is_array($test));
         $this->assertTrue(array_key_exists('result', $test));
-        $this->assertTrue(array_key_exists('error', $test));
+        $this->assertFalse(array_key_exists('error', $test), "'error' may not coexist with 'result'");
         $this->assertTrue(array_key_exists('id', $test));
         $this->assertFalse(array_key_exists('jsonrpc', $test));