SuperCacheProbe prüft beim Prüfen, ob wp_cache_post_edit die Cache-Datei einer Testseite entfernt; während der Probe ist nur der Einzelseiten-Purge erlaubt, der Pfad kommt aus home und es werden nur feste Dateinamen gelöscht. ProbeStep bündelt die Schrittlogik von Pods und WP Super Cache; ThrowawayPost hält Marker und Titel zentral und räumt auch private Probe-Seiten auf (WP Super Cache wie Pods beim Laden des Reiters). super-cache-smoke.sh prüft gegen das echte Plugin; lib.sh sperrt parallele Smoke-Läufe per flock, wp-config.php wird atomar wiederhergestellt. Doku: Host-Abhängigkeit des Einzel-Purges, WP-Cron für den Nachlauf, Komplett-Purge durch Divi beim Prüfen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
69 lines
2.6 KiB
PHP
69 lines
2.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace LIT\MCP\Tests\Unit\Integrations\SuperCache;
|
|
|
|
use Brain\Monkey\Functions;
|
|
use LIT\MCP\Admin\CompatibilityTab;
|
|
use LIT\MCP\Compatibility\ProvidesCompatibility;
|
|
use LIT\MCP\Integrations\Bootable;
|
|
use LIT\MCP\Integrations\Integration;
|
|
use LIT\MCP\Integrations\SuperCache\SuperCacheCompatibility;
|
|
use LIT\MCP\Integrations\SuperCache\SuperCacheIntegration;
|
|
use LIT\MCP\Tests\Unit\TestCase;
|
|
|
|
final class SuperCacheIntegrationTest extends TestCase
|
|
{
|
|
public function testIsAnIntegrationWithoutAbilitiesThatProvidesItsProfile(): void
|
|
{
|
|
$integration = new SuperCacheIntegration();
|
|
|
|
self::assertInstanceOf(Integration::class, $integration);
|
|
self::assertInstanceOf(ProvidesCompatibility::class, $integration);
|
|
self::assertSame('wpsc', $integration->id());
|
|
self::assertSame('WP Super Cache', $integration->label());
|
|
self::assertSame([], $integration->abilities());
|
|
self::assertEquals([SuperCacheCompatibility::profile()], $integration->compatibilities());
|
|
}
|
|
|
|
public function testIsAvailableOnlyWithSuperCache(): void
|
|
{
|
|
self::assertSame(defined('WPCACHEHOME'), (new SuperCacheIntegration())->isAvailable());
|
|
}
|
|
|
|
public function testBootHooksTheOrphanCleanupIntoTheProfileLoad(): void
|
|
{
|
|
$integration = new SuperCacheIntegration();
|
|
$integration->boot();
|
|
|
|
self::assertInstanceOf(Bootable::class, $integration);
|
|
self::assertNotFalse(has_action(CompatibilityTab::LOAD_ACTION, [$integration, 'removeOrphans']));
|
|
}
|
|
|
|
public function testNoCleanupForAnotherProfileWithoutWpscOrWithoutTheCapability(): void
|
|
{
|
|
Functions\expect('get_posts')->never();
|
|
Functions\when('current_user_can')->justReturn(true);
|
|
(new SuperCacheIntegration(static fn (): bool => true))->removeOrphans('pods');
|
|
(new SuperCacheIntegration(static fn (): bool => false))->removeOrphans('wpsc');
|
|
|
|
Functions\when('current_user_can')->justReturn(false);
|
|
(new SuperCacheIntegration(static fn (): bool => true))->removeOrphans('wpsc');
|
|
$this->addToAssertionCount(1);
|
|
}
|
|
|
|
public function testCleansUpPagesForTheAdministratorWithWpsc(): void
|
|
{
|
|
Functions\when('current_user_can')->justReturn(true);
|
|
Functions\expect('get_posts')->once()->andReturnUsing(static function (array $args): array {
|
|
self::assertSame('page', $args['post_type']);
|
|
self::assertSame(['draft', 'private'], $args['post_status']);
|
|
|
|
return [];
|
|
});
|
|
|
|
(new SuperCacheIntegration(static fn (): bool => true))->removeOrphans('wpsc');
|
|
}
|
|
}
|