Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
64 lines
2.1 KiB
PHP
64 lines
2.1 KiB
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
namespace LIT\MCP\Tests\Unit\Integrations\WordPress;
|
||
|
||
use LIT\MCP\Abilities\Ability;
|
||
use LIT\MCP\ChangeLog\ChangeLog;
|
||
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
|
||
use LIT\MCP\Integrations\WordPress\WordPressIntegration;
|
||
use LIT\MCP\Tests\Unit\TestCase;
|
||
use Mockery;
|
||
|
||
final class WordPressIntegrationTest extends TestCase
|
||
{
|
||
/** Grows with every task that adds abilities – keep in the order of abilities(). */
|
||
private const EXPECTED = [
|
||
'lit/content-types',
|
||
'lit/content-query',
|
||
'lit/content-get',
|
||
'lit/content-create',
|
||
'lit/content-update',
|
||
'lit/post-publish',
|
||
'lit/post-unpublish',
|
||
'lit/post-schedule',
|
||
'lit/post-trash',
|
||
'lit/post-duplicate',
|
||
'lit/post-replace-with-copy',
|
||
'lit/revisions-list',
|
||
'lit/revision-restore',
|
||
'lit/menu-list',
|
||
'lit/menu-get',
|
||
'lit/menu-create',
|
||
'lit/menu-set-items',
|
||
'lit/menu-assign-location',
|
||
'lit/wp-settings-get',
|
||
'lit/wp-settings-update',
|
||
];
|
||
|
||
public function testProvidesTheWordPressAbilitiesInOrder(): void
|
||
{
|
||
$integration = new WordPressIntegration(Mockery::mock(ContentSchema::class), Mockery::mock(ChangeLog::class));
|
||
|
||
self::assertSame('wordpress', $integration->id());
|
||
self::assertTrue($integration->isAvailable());
|
||
self::assertSame(
|
||
self::EXPECTED,
|
||
array_map(static fn (Ability $ability): string => $ability->name(), $integration->abilities())
|
||
);
|
||
}
|
||
|
||
public function testEveryAbilityHasAnObjectInputSchemaThatRejectsUnknownKeys(): void
|
||
{
|
||
$integration = new WordPressIntegration(Mockery::mock(ContentSchema::class), Mockery::mock(ChangeLog::class));
|
||
|
||
foreach ($integration->abilities() as $ability) {
|
||
$schema = $ability->inputSchema();
|
||
self::assertSame('object', $schema['type'], $ability->name());
|
||
self::assertFalse($schema['additionalProperties'], $ability->name());
|
||
self::assertMatchesRegularExpression('#^lit/[a-z]+(-[a-z]+)+$#', $ability->name());
|
||
}
|
||
}
|
||
}
|