feat: guide tool and server instructions
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace LIT\MCP\Tests\Unit\Guides;
|
||||
|
||||
use LIT\MCP\Guides\GuideRepository;
|
||||
use LIT\MCP\Tests\Unit\TestCase;
|
||||
|
||||
final class GuideRepositoryTest extends TestCase
|
||||
{
|
||||
private GuideRepository $guides;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->guides = new GuideRepository(dirname(__DIR__, 2) . '/Fixtures/guides');
|
||||
}
|
||||
|
||||
public function testListsTopicsSortedWithoutExtension(): void
|
||||
{
|
||||
self::assertSame(['divi-shortform', 'overview'], $this->guides->topics());
|
||||
}
|
||||
|
||||
public function testReturnsMarkdownOfKnownTopic(): void
|
||||
{
|
||||
self::assertStringContainsString('Testinhalt Kurzform', (string) $this->guides->get('divi-shortform'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider maliciousTopics
|
||||
*/
|
||||
public function testRejectsAnythingThatIsNotAPlainTopicName(string $topic): void
|
||||
{
|
||||
self::assertNull($this->guides->get($topic));
|
||||
}
|
||||
|
||||
/** @return array<string, array{string}> */
|
||||
public static function maliciousTopics(): array
|
||||
{
|
||||
return [
|
||||
'traversal' => ['../../wp-config'],
|
||||
'with extension' => ['overview.md'],
|
||||
'empty' => [''],
|
||||
'absolute' => ['/etc/passwd'],
|
||||
'unknown' => ['does-not-exist'],
|
||||
'uppercase' => ['OVERVIEW'],
|
||||
];
|
||||
}
|
||||
|
||||
public function testMissingDirectoryYieldsNoTopics(): void
|
||||
{
|
||||
self::assertSame([], (new GuideRepository('/nonexistent/dir'))->topics());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user