Skip to content

Commit

Permalink
Fix #94
Browse files Browse the repository at this point in the history
  • Loading branch information
yoanm committed May 6, 2023
1 parent 3b0fd12 commit 3b594ab
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/App/Creator/ResponseCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ public function createEmptyResponse(JsonRpcRequest $fromRequest = null) : JsonRp
->setIsNotification($fromRequest->isNotification())
;

if (!is_null($fromRequest->getId())) {
// Notification response doesn't have any ID defined (notification request doesn't either)
if (!$fromRequest->isNotification()) {
$response->setId($fromRequest->getId());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace Tests\Functional\App\Creator\ResponseCreator;

use Prophecy\PhpUnit\ProphecyTrait;
use Yoanm\JsonRpcServer\Domain\Model\JsonRpcRequest;

/**
* @covers \Yoanm\JsonRpcServer\App\Creator\ResponseCreator
Expand Down Expand Up @@ -40,4 +41,17 @@ public function testShouldBindResultAndRequestParamToResponse()
$this->assertSame($result, $response->getResult());
$this->assertFromRequestBinding($fromRequest, $response);
}



/**
* Bug fix: https://github.com/yoanm/php-jsonrpc-server-sdk/issues/94
*/
public function testShouldConvertRequestWithZeroIdToResponseWithZeroId() {
$fromRequest = $this->createRequest(self::DEFAULT_METHOD, self::DEFAULT_JSONRPC, 0);

$response = $this->responseCreator->createEmptyResponse($fromRequest);

$this->assertSame(0, $response->getId());
}
}

0 comments on commit 3b594ab

Please sign in to comment.