Skip to content

Commit 4eee286

Browse files
committed
Update Test
1 parent 56c786f commit 4eee286

File tree

7 files changed

+40
-21
lines changed

7 files changed

+40
-21
lines changed

tests/Fixtures/ResourceWithResultMetaResource.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Tests\Fixtures;
46

57
use Laravel\Mcp\Response;
@@ -18,7 +20,7 @@ public function handle(): ResponseFactory
1820
return Response::make(
1921
Response::text('Resource content with result meta')
2022
)->withMeta([
21-
'last_modified' => now()->toIso8601String(),
23+
'last_modified' => '2025-01-01',
2224
'version' => '1.0',
2325
]);
2426
}

tests/Fixtures/SayHiWithMetaTool.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Tests\Fixtures;
46

57
use Illuminate\JsonSchema\JsonSchema;

tests/Fixtures/ToolWithBothMetaTool.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Tests\Fixtures;
46

57
use Illuminate\JsonSchema\JsonSchema;

tests/Fixtures/ToolWithResultMetaTool.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Tests\Fixtures;
46

57
use Illuminate\JsonSchema\JsonSchema;

tests/Unit/Methods/ReadResourceTest.php

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,21 @@
114114
$payload = $response->toArray();
115115

116116
expect($payload['id'])->toEqual(1)
117-
->and($payload['result'])->toHaveKey('_meta')
118-
->and($payload['result']['_meta'])->toHaveKey('last_modified')
119-
->and($payload['result']['_meta'])->toHaveKey('version')
120-
->and($payload['result']['_meta']['version'])->toBe('1.0')
121-
->and($payload['result']['contents'][0])->toEqual([
122-
'text' => 'Resource content with result meta',
123-
'uri' => 'file://resources/with-result-meta.txt',
124-
'name' => 'resource-with-result-meta-resource',
125-
'title' => 'Resource With Result Meta Resource',
126-
'mimeType' => 'text/plain',
117+
->and($payload)->toMatchArray([
118+
'result' => [
119+
'_meta' => [
120+
'last_modified' => '2025-01-01',
121+
'version' => '1.0',
122+
],
123+
'contents' => [
124+
[
125+
'text' => 'Resource content with result meta',
126+
'uri' => 'file://resources/with-result-meta.txt',
127+
'name' => 'resource-with-result-meta-resource',
128+
'title' => 'Resource With Result Meta Resource',
129+
'mimeType' => 'text/plain',
130+
],
131+
],
132+
],
127133
]);
128134
});

tests/Unit/Prompts/PromptTest.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ public function handle(): Response
4141
}
4242
};
4343

44-
expect($prompt->toArray()['_meta'])->toEqual([
45-
'category' => 'greeting',
46-
'tags' => ['hello', 'welcome'],
47-
]);
44+
expect($prompt->toArray())
45+
->toHaveKey('_meta')
46+
->_meta->toEqual([
47+
'category' => 'greeting',
48+
'tags' => ['hello', 'welcome'],
49+
]);
4850
});
4951

5052
it('includes meta in array representation with other fields', function (): void {
@@ -81,7 +83,8 @@ public function arguments(): array
8183
->toHaveKey('description', 'A friendly greeting')
8284
->toHaveKey('arguments')
8385
->toHaveKey('_meta')
84-
->and($array['_meta'])->toEqual(['version' => '1.0'])
85-
->and($array['arguments'])->toHaveCount(1);
86+
->and($array)
87+
->_meta->toEqual(['version' => '1.0'])
88+
->arguments->toHaveCount(1);
8689

8790
});

tests/Unit/Resources/ResourceTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,10 @@ public function handle(): string
179179
}
180180
};
181181

182-
expect($resource->toArray()['_meta'])->toEqual([
183-
'author' => 'John Doe',
184-
'version' => '1.0',
185-
]);
182+
expect($resource->toArray())
183+
->toHaveKey('_meta')
184+
->_meta->toEqual([
185+
'author' => 'John Doe',
186+
'version' => '1.0',
187+
]);
186188
});

0 commit comments

Comments
 (0)