Adopt Schema component in server handlers
This commit is contained in:
parent
6025f890f9
commit
09707b4798
1 changed files with 1516 additions and 2424 deletions
58
tests/Schema/JsonRpc/RequestTest.php
Normal file
58
tests/Schema/JsonRpc/RequestTest.php
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the official PHP MCP SDK.
|
||||
*
|
||||
* A collaboration between Symfony and the PHP Foundation.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Mcp\Tests\Schema\JsonRpc;
|
||||
|
||||
use Mcp\Schema\JsonRpc\Request;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class RequestTest extends TestCase
|
||||
{
|
||||
public function testMetaAndIdAreLoopedThrough()
|
||||
{
|
||||
$requestImplementation = new class extends Request {
|
||||
public static function getMethod(): string
|
||||
{
|
||||
return 'foo/bar';
|
||||
}
|
||||
|
||||
public static function fromParams(?array $params): self
|
||||
{
|
||||
return new self();
|
||||
}
|
||||
|
||||
protected function getParams(): ?array
|
||||
{
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
$notification = $requestImplementation::fromArray([
|
||||
'jsonrpc' => '2.0',
|
||||
'id' => '12345',
|
||||
'method' => 'foo/bar',
|
||||
'params' => [
|
||||
'_meta' => ['key' => 'value'],
|
||||
],
|
||||
]);
|
||||
|
||||
$expectedMeta = [
|
||||
'jsonrpc' => '2.0',
|
||||
'id' => '12345',
|
||||
'method' => 'foo/bar',
|
||||
'params' => [
|
||||
'_meta' => ['key' => 'value'],
|
||||
],
|
||||
];
|
||||
|
||||
$this->assertSame($expectedMeta, $notification->jsonSerialize());
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue