Skip to content

Commit ea0be70

Browse files
authored
Test Improvements (#115)
- Use available Testbench features. Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
1 parent c28c8d5 commit ea0be70

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

tests/Feature/Console/StartCommandTest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
use Illuminate\Testing\TestResponse;
55
use Symfony\Component\Process\Process;
66

7+
use function Orchestra\Testbench\remote;
8+
79
it('can initialize a connection over http', function (): void {
810
$response = $this->postJson('test-mcp', initializeMessage());
911

@@ -111,7 +113,7 @@
111113
});
112114

113115
it('can initialize a connection over stdio', function (): void {
114-
$process = new Process([PHP_BINARY, 'vendor/bin/testbench', 'mcp:start', 'test-mcp']);
116+
$process = remote(['mcp:start', 'test-mcp']);
115117
$process->setInput(json_encode(initializeMessage()));
116118

117119
$process->run(function (string $type, string $output): void {
@@ -122,7 +124,7 @@
122124
});
123125

124126
it('can list tools over stdio', function (): void {
125-
$process = new Process([PHP_BINARY, 'vendor/bin/testbench', 'mcp:start', 'test-mcp']);
127+
$process = remote(['mcp:start', 'test-mcp']);
126128
$process->setInput(json_encode(listToolsMessage()));
127129

128130
$process->run();
@@ -133,7 +135,7 @@
133135
});
134136

135137
it('can call a tool over stdio', function (): void {
136-
$process = new Process([PHP_BINARY, 'vendor/bin/testbench', 'mcp:start', 'test-mcp']);
138+
$process = remote(['mcp:start', 'test-mcp']);
137139
$process->setInput(json_encode(callToolMessage()));
138140

139141
$process->run();
@@ -144,7 +146,7 @@
144146
});
145147

146148
it('can handle a ping over stdio', function (): void {
147-
$process = new Process([PHP_BINARY, 'vendor/bin/testbench', 'mcp:start', 'test-mcp']);
149+
$process = remote(['mcp:start', 'test-mcp']);
148150
$process->setInput(json_encode(pingMessage()));
149151

150152
$process->run();
@@ -155,7 +157,7 @@
155157
});
156158

157159
it('can stream a tool response over stdio', function (): void {
158-
$process = new Process([PHP_BINARY, 'vendor/bin/testbench', 'mcp:start', 'test-mcp']);
160+
$process = remote(['mcp:start', 'test-mcp']);
159161
$process->setInput(json_encode(callStreamingToolMessage()));
160162

161163
$process->run();

tests/TestCase.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,15 @@
55
namespace Tests;
66

77
use Laravel\Mcp\Server\Contracts\Resources\Content;
8-
use Laravel\Mcp\Server\McpServiceProvider;
98
use Laravel\Mcp\Server\Resource;
109
use Laravel\Mcp\Server\ServerContext;
1110
use Laravel\Mcp\Server\Transport\JsonRpcResponse;
11+
use Orchestra\Testbench\Concerns\WithWorkbench;
1212
use Orchestra\Testbench\TestCase as TestbenchTestCase;
13-
use Workbench\App\Providers\WorkbenchServiceProvider;
1413

1514
abstract class TestCase extends TestbenchTestCase
1615
{
17-
protected function getPackageProviders($app)
18-
{
19-
return [
20-
McpServiceProvider::class,
21-
WorkbenchServiceProvider::class,
22-
];
23-
}
16+
use WithWorkbench;
2417

2518
protected function getServerContext(array $properties = []): ServerContext
2619
{

0 commit comments

Comments
 (0)