Files
Jan-Niclas LoosenandClaude Opus 5.5 1a294b7881 feat(pods): Verhaltensprobe als Prüfschritt
Beim Prüfen schreibt und liest PodsProbe auf einem Wegwerf-Entwurf ein Textfeld genau so, wie LIT MCP es tut, vergleicht die Werte und löscht den Entwurf wieder. Bevorzugt von Pods angelegte Typen; ohne Pod mit Textfeld gilt der Schritt als grün mit Hinweis „nicht geprüft“. Ein roter Schritt sperrt Pods über die Berichtssperre. Liegengebliebene Probe-Einträge räumt der Load-Hook des Reiters auf. Pods-Smoke um Probe und Bereinigung erweitert.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 14:33:26 +01:00

111 lines
3.6 KiB
PHP

<?php
declare(strict_types=1);
namespace LIT\MCP\Tests\Unit\Integrations\Pods;
use Brain\Monkey\Functions;
use LIT\MCP\Admin\CompatibilityTab;
use LIT\MCP\Compatibility\ProvidesCompatibility;
use LIT\MCP\Guides\InstructionsBuilder;
use LIT\MCP\Integrations\Integration;
use LIT\MCP\Integrations\IntegrationRegistry;
use LIT\MCP\Integrations\Pods\PodsCompatibility;
use LIT\MCP\Integrations\Pods\PodsIntegration;
use LIT\MCP\Tests\Unit\TestCase;
final class PodsIntegrationTest extends TestCase
{
public function testIsAnIntegrationWithoutAbilitiesThatProvidesItsProfile(): void
{
$integration = new PodsIntegration();
self::assertInstanceOf(Integration::class, $integration);
self::assertInstanceOf(ProvidesCompatibility::class, $integration);
self::assertSame('pods', $integration->id());
self::assertSame('Pods', $integration->label());
self::assertSame([], $integration->abilities());
self::assertEquals([PodsCompatibility::profile()], $integration->compatibilities());
}
public function testBootHooksTheOrphanCleanupIntoTheProfileLoad(): void
{
$integration = new PodsIntegration();
$integration->boot();
self::assertNotFalse(has_action(CompatibilityTab::LOAD_ACTION, [$integration, 'removeOrphans']));
}
public function testNoCleanupForAnotherProfile(): void
{
Functions\expect('get_posts')->never();
Functions\when('current_user_can')->justReturn(true);
(new PodsIntegration(static fn (): bool => true))->removeOrphans('divi');
$this->addToAssertionCount(1);
}
public function testNoCleanupWithoutPods(): void
{
Functions\expect('get_posts')->never();
Functions\when('current_user_can')->justReturn(true);
(new PodsIntegration(static fn (): bool => false))->removeOrphans('pods');
$this->addToAssertionCount(1);
}
public function testNoCleanupWithoutTheCapability(): void
{
Functions\expect('get_posts')->never();
Functions\when('current_user_can')->justReturn(false);
(new PodsIntegration(static fn (): bool => true))->removeOrphans('pods');
$this->addToAssertionCount(1);
}
public function testCleansUpForTheAdministratorWithPods(): void
{
Functions\when('current_user_can')->justReturn(true);
Functions\when('get_post_types')->justReturn(['post' => 'post']);
Functions\expect('get_posts')->once()->andReturn([]);
(new PodsIntegration(static fn (): bool => true))->removeOrphans('pods');
}
public function testIsAvailableOnlyWithPods(): void
{
self::assertSame(defined('PODS_VERSION'), (new PodsIntegration())->isAvailable());
}
/** An available integration without abilities is no tool group, but it is an active integration. */
public function testAnAvailableIntegrationWithoutAbilitiesIsNoGroupButIsNamedAsActive(): void
{
$pods = new class implements Integration {
public function id(): string
{
return 'pods';
}
public function label(): string
{
return 'Pods';
}
public function isAvailable(): bool
{
return true;
}
public function abilities(): array
{
return [];
}
};
$registry = new IntegrationRegistry($pods);
self::assertSame([], $registry->grouped());
self::assertSame([], $registry->groupMap());
self::assertStringContainsString('Aktive Integrationen: pods.', (new InstructionsBuilder($registry))->build());
}
}