Skip to content

Commit 3ec4cf6

Browse files
authored
Split testsuite for unit and inspector based tests (#82)
1 parent 7d599f4 commit 3ec4cf6

File tree

64 files changed

+188
-85
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+188
-85
lines changed

.github/workflows/pipeline.yaml

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ permissions:
66
pull-requests: write
77

88
jobs:
9-
tests:
9+
unit:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
@@ -22,16 +22,36 @@ jobs:
2222
php-version: ${{ matrix.php }}
2323
coverage: "none"
2424

25-
- name: Composer Validation
26-
run: composer validate --strict
27-
2825
- name: Install Composer
2926
uses: "ramsey/composer-install@v3"
3027
with:
3128
dependency-versions: "${{ matrix.dependencies }}"
3229

3330
- name: Tests
34-
run: vendor/bin/phpunit --exclude-group inspector
31+
run: vendor/bin/phpunit --testsuite=unit
32+
33+
inspector:
34+
runs-on: ubuntu-latest
35+
steps:
36+
- name: Checkout
37+
uses: actions/checkout@v5
38+
39+
- name: Setup PHP
40+
uses: shivammathur/setup-php@v2
41+
with:
42+
php-version: '8.4'
43+
coverage: "none"
44+
45+
- name: Setup Node
46+
uses: actions/setup-node@v5
47+
with:
48+
node-version: '22'
49+
50+
- name: Install Composer
51+
uses: "ramsey/composer-install@v3"
52+
53+
- name: Tests
54+
run: vendor/bin/phpunit --testsuite=inspector
3555

3656
qa:
3757
runs-on: ubuntu-latest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.phpunit.cache
22
.php-cs-fixer.cache
33
composer.lock
4+
coverage
45
vendor
56
examples/**/dev.log
67
examples/**/sessions

Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,14 @@ phpstan:
1515
tests:
1616
vendor/bin/phpunit
1717

18+
unit-tests:
19+
vendor/bin/phpunit --testsuite=unit
20+
21+
inspector-tests:
22+
vendor/bin/phpunit --testsuite=inspector
23+
1824
coverage:
19-
XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-html=coverage
25+
XDEBUG_MODE=coverage vendor/bin/phpunit --testsuite=unit --coverage-html=coverage
2026

2127
ci: ci-stable
2228

phpstan.dist.neon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ parameters:
99
- tests/
1010
excludePaths:
1111
- examples/cli/vendor/* (?)
12-
- tests/Capability/Discovery/Fixtures/
13-
- tests/Capability/Discovery/SchemaGeneratorFixture.php
12+
- tests/Unit/Capability/Discovery/Fixtures/
13+
- tests/Unit/Capability/Discovery/SchemaGeneratorFixture.php
1414
treatPhpDocTypesAsCertain: false
1515
ignoreErrors:
1616
-

phpunit.xml.dist

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
failOnWarning="true">
1010

1111
<testsuites>
12-
<testsuite name="default">
13-
<directory>tests</directory>
12+
<testsuite name="unit">
13+
<directory>tests/Unit</directory>
14+
</testsuite>
15+
<testsuite name="inspector">
16+
<directory>tests/Inspector</directory>
1417
</testsuite>
1518
</testsuites>
1619

tests/Example/InspectorSnapshotTestCase.php renamed to tests/Inspector/InspectorSnapshotTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Mcp\Tests\Example;
12+
namespace Mcp\Tests\Inspector;
1313

1414
use PHPUnit\Framework\Attributes\DataProvider;
1515
use PHPUnit\Framework\TestCase;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the official PHP MCP SDK.
5+
*
6+
* A collaboration between Symfony and the PHP Foundation.
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Inspector;
13+
14+
use Mcp\Tests\Inspector\InspectorSnapshotTestCase;
15+
16+
final class ManualStdioExampleTest extends InspectorSnapshotTestCase
17+
{
18+
public static function provideMethods(): array
19+
{
20+
return [
21+
...parent::provideListMethods(),
22+
];
23+
}
24+
25+
protected function getServerScript(): string
26+
{
27+
return \dirname(__DIR__, 2).'/examples/03-manual-registration-stdio/server.php';
28+
}
29+
}

tests/Example/StdioCalculatorExampleTest.php renamed to tests/Inspector/StdioCalculatorExampleTest.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Mcp\Tests\Example;
12+
namespace Mcp\Tests\Inspector;
1313

14-
use PHPUnit\Framework\Attributes\Group;
15-
16-
#[Group('inspector')]
1714
final class StdioCalculatorExampleTest extends InspectorSnapshotTestCase
1815
{
1916
public static function provideMethods(): array
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"prompts": [
3+
{
4+
"name": "personalized_greeting",
5+
"description": "A manually registered prompt template.",
6+
"arguments": [
7+
{
8+
"name": "userName",
9+
"description": "the name of the user",
10+
"required": true
11+
}
12+
]
13+
}
14+
]
15+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"resources": [
3+
{
4+
"name": "application_version",
5+
"uri": "app://version",
6+
"description": "A manually registered resource providing app version.",
7+
"mimeType": "text/plain"
8+
}
9+
]
10+
}

0 commit comments

Comments
 (0)