Skip to content

Commit

Permalink
refs #34 Fixed checking method not exists
Browse files Browse the repository at this point in the history
  • Loading branch information
tabuna committed Jul 12, 2022
1 parent d646a01 commit bd3b8e2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Guide.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public function findProcedure(Request $request): ?string

return $this->map
->filter(fn (string $procedure) => $this->getProcedureName($procedure) === $class)
->filter(fn (string $procedure) => method_exists($procedure, $method))
->filter(fn (string $procedure) => $this->checkExistPublicMethod($procedure, $method))
->map(fn (string $procedure) => Str::finish($procedure, self::DEFAULT_DELIMITER . $method))
->first();
Expand Down
5 changes: 5 additions & 0 deletions tests/Expected/Requests/testCallNoExistMethod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"jsonrpc": "2.0",
"method": "fixture@undefined",
"id": 1
}
9 changes: 9 additions & 0 deletions tests/Expected/Responses/testCallNoExistMethod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"error": {
"code": -32601,
"data": null,
"message": "Method not found"
},
"id": "1",
"jsonrpc": "2.0"
}
1 change: 1 addition & 0 deletions tests/Unit/ExpectedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public function exampleCalls(): Generator
yield ['testCallCloseMethod'];
yield ['testRuntimeError'];
yield ['testInvalidRequestException'];
yield ['testCallNoExistMethod'];

// Binding
yield ['testBindDeepValue',];
Expand Down

0 comments on commit bd3b8e2

Please sign in to comment.