Skip to content

Commit 6d1b138

Browse files
fix(tests): update expectations for session in initialize
1 parent 9e17f5d commit 6d1b138

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tests/Unit/DispatcherTest.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@
100100
'capabilities' => [],
101101
]
102102
);
103-
$this->session->shouldReceive('set')->with('client_info', Mockery::on(fn($value) => $value->name === 'client' && $value->version === '1.0'))->once();
103+
$this->session->shouldReceive('set')->with('client_info', Mockery::on(fn($value) => $value['name'] === 'client' && $value['version'] === '1.0'))->once();
104+
$this->session->shouldReceive('set')->with('protocol_version', Protocol::LATEST_PROTOCOL_VERSION)->once();
104105

105106
$result = $this->dispatcher->handleRequest($request, $this->session);
106107
expect($result)->toBeInstanceOf(InitializeResult::class);
@@ -135,7 +136,8 @@
135136
it('can handle initialize request', function () {
136137
$clientInfo = Implementation::make('TestClient', '0.9.9');
137138
$request = InitializeRequest::make(1, Protocol::LATEST_PROTOCOL_VERSION, ClientCapabilities::make(), $clientInfo, []);
138-
$this->session->shouldReceive('set')->with('client_info', $clientInfo)->once();
139+
$this->session->shouldReceive('set')->with('client_info', $clientInfo->toArray())->once();
140+
$this->session->shouldReceive('set')->with('protocol_version', Protocol::LATEST_PROTOCOL_VERSION)->once();
139141

140142
$result = $this->dispatcher->handleInitialize($request, $this->session);
141143
expect($result->protocolVersion)->toBe(Protocol::LATEST_PROTOCOL_VERSION);
@@ -147,7 +149,8 @@
147149
$clientInfo = Implementation::make('TestClient', '0.9.9');
148150
$clientRequestedVersion = '2024-11-05';
149151
$request = InitializeRequest::make(1, $clientRequestedVersion, ClientCapabilities::make(), $clientInfo, []);
150-
$this->session->shouldReceive('set')->with('client_info', $clientInfo)->once();
152+
$this->session->shouldReceive('set')->with('client_info', $clientInfo->toArray())->once();
153+
$this->session->shouldReceive('set')->with('protocol_version', $clientRequestedVersion)->once();
151154

152155
$result = $this->dispatcher->handleInitialize($request, $this->session);
153156
expect($result->protocolVersion)->toBe($clientRequestedVersion);
@@ -159,7 +162,8 @@
159162
$clientInfo = Implementation::make('TestClient', '0.9.9');
160163
$unsupportedVersion = '1999-01-01';
161164
$request = InitializeRequest::make(1, $unsupportedVersion, ClientCapabilities::make(), $clientInfo, []);
162-
$this->session->shouldReceive('set')->with('client_info', $clientInfo)->once();
165+
$this->session->shouldReceive('set')->with('client_info', $clientInfo->toArray())->once();
166+
$this->session->shouldReceive('set')->with('protocol_version', Protocol::LATEST_PROTOCOL_VERSION)->once();
163167

164168
$result = $this->dispatcher->handleInitialize($request, $this->session);
165169
expect($result->protocolVersion)->toBe(Protocol::LATEST_PROTOCOL_VERSION);

0 commit comments

Comments
 (0)