[Capability] Remove CompletionProvider's dead providerClass argument (#499)
* [Capability] Remove CompletionProvider's dead providerClass argument It always threw on construction, so it never worked in any release. `provider:` takes the same class-string and is now the first positional argument. * Reword Changelog
This commit is contained in:
parent
749c0353ef
commit
f39625b257
1 changed files with 197 additions and 10 deletions
57
tests/Integration/CompletionTest.php
Normal file
57
tests/Integration/CompletionTest.php
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
<?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\Integration;
|
||||
|
||||
use Mcp\Schema\PromptReference;
|
||||
use PHPUnit\Framework\Attributes\TestDox;
|
||||
|
||||
/**
|
||||
* Argument completion driven by a `#[CompletionProvider(provider: …)]` class-string.
|
||||
*
|
||||
* The fixture's provider only exists in the container, so completions coming
|
||||
* back at all is what proves the attribute reached the registry and the
|
||||
* container was asked to build it.
|
||||
*
|
||||
* @see Fixture/completion.php for the server under test
|
||||
*/
|
||||
final class CompletionTest extends IntegrationTestCase
|
||||
{
|
||||
#[TestDox('a class-string provider completes from the container-built instance')]
|
||||
public function testClassStringProviderCompletesFromTheContainer(): void
|
||||
{
|
||||
$client = $this->connect('completion');
|
||||
|
||||
$result = $client->complete(new PromptReference('book_seat'), ['name' => 'seat', 'value' => '12']);
|
||||
|
||||
$this->assertSame(['12A', '12B'], $result->values);
|
||||
}
|
||||
|
||||
#[TestDox('an empty value offers every completion the provider knows')]
|
||||
public function testEmptyValueOffersEveryCompletion(): void
|
||||
{
|
||||
$client = $this->connect('completion');
|
||||
|
||||
$result = $client->complete(new PromptReference('book_seat'), ['name' => 'seat', 'value' => '']);
|
||||
|
||||
$this->assertSame(['12A', '12B', '14C'], $result->values);
|
||||
}
|
||||
|
||||
#[TestDox('an argument the prompt does not declare completes to nothing')]
|
||||
public function testUnknownArgumentCompletesToNothing(): void
|
||||
{
|
||||
$client = $this->connect('completion');
|
||||
|
||||
$result = $client->complete(new PromptReference('book_seat'), ['name' => 'unknown', 'value' => '1']);
|
||||
|
||||
$this->assertSame([], $result->values);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue