Kick off the SDK based on Symfony's MCP SDK

This commit is contained in:
Christopher Hertel 2025-07-25 11:40:39 +02:00
commit ee0dffe369
No known key found for this signature in database
GPG key ID: 111F6BFF7B6B5AA3

View file

@ -0,0 +1,52 @@
<?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\Message;
use Mcp\Message\Error;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Small;
use PHPUnit\Framework\TestCase;
#[Small]
#[CoversClass(Error::class)]
final class ErrorTest extends TestCase
{
public function testWithIntegerId(): void
{
$error = new Error(1, -32602, 'Another error occurred');
$expected = [
'jsonrpc' => '2.0',
'id' => 1,
'error' => [
'code' => -32602,
'message' => 'Another error occurred',
],
];
$this->assertSame($expected, $error->jsonSerialize());
}
public function testWithStringId(): void
{
$error = new Error('abc', -32602, 'Another error occurred');
$expected = [
'jsonrpc' => '2.0',
'id' => 'abc',
'error' => [
'code' => -32602,
'message' => 'Another error occurred',
],
];
$this->assertSame($expected, $error->jsonSerialize());
}
}