Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge branch 'master' of git://git.zendframework.com/zf
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 0 additions & 2 deletions src/Server/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,13 @@ public function toJson()
{
if ($this->isError()) {
$response = array(
'result' => null,
'error' => $this->getError()->toArray(),
'id' => $this->getId(),
);
} else {
$response = array(
'result' => $this->getResult(),
'id' => $this->getId(),
'error' => null,
);
}

Expand Down
7 changes: 4 additions & 3 deletions test/Server/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function testResponseShouldBeAbleToCastToJSON()

$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->assertTrue(array_key_exists('jsonrpc', $test));

Expand All @@ -139,7 +139,8 @@ public function testResponseShouldCastErrorToJSONIfIsError()
$test = Json\Json::decode($json, Json\Json::TYPE_ARRAY);

$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('error', $test));
$this->assertTrue(array_key_exists('id', $test));
$this->assertFalse(array_key_exists('jsonrpc', $test));

Expand All @@ -157,7 +158,7 @@ public function testCastToStringShouldCastToJSON()

$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));

Expand Down

0 comments on commit 6f9a6cc

Please sign in to comment.