feat(cache): WP Fastest Cache statt WP Super Cache
Die Cache-Integration war für WP Super Cache gebaut, eingesetzt wird aber WP Fastest Cache. Profil (wpfc), Listener, Drosselung, lit/cache-clear und Leeren-Probe laufen jetzt über die öffentlichen WPFC-Funktionen wpfc_clear_post_cache_by_id/wpfc_clear_all_cache; die Probe leert nur die Wegwerf-Seite (singleDeleteCache ohne Elternseiten) und prüft, dass WPFC den Hook noch verarbeitet. Smoke fastest-cache-smoke.sh ersetzt den WPSC-Smoke. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
e1fad3dffe
commit
bee9da3a86
+29
-28
@@ -50,18 +50,18 @@ final class PluginTest extends TestCase
|
||||
public function testIntegrationsInRegistryOrder(): void
|
||||
{
|
||||
self::assertSame(
|
||||
['core', 'wordpress', 'media', 'divi', 'divi-library', 'divi-theme-builder', 'pods', 'wpsc'],
|
||||
['core', 'wordpress', 'media', 'divi', 'divi-library', 'divi-theme-builder', 'pods', 'wpfc'],
|
||||
self::registry()->ids()
|
||||
);
|
||||
}
|
||||
|
||||
/** Divi, Pods and WP Super Cache boot (hooks, orphan cleanup); a second boot registers nothing twice. */
|
||||
/** Divi, Pods and WP Fastest Cache boot (hooks, orphan cleanup); a second boot registers nothing twice. */
|
||||
public function testTheBootableIntegrationsBootExactlyOnce(): void
|
||||
{
|
||||
Actions\expectAdded('upgrader_process_complete')->once();
|
||||
Actions\expectAdded('lit_mcp_compat_changed')->once();
|
||||
Filters\expectAdded(SettingsPage::TABS_FILTER)->never();
|
||||
Actions\expectAdded(CompatibilityTab::LOAD_ACTION)->times(3); // Divi, Pods and WP Super Cache
|
||||
Actions\expectAdded(CompatibilityTab::LOAD_ACTION)->times(3); // Divi, Pods and WP Fastest Cache
|
||||
Actions\expectAdded(CompatibilityTab::EXTRA_ACTION)->once();
|
||||
Filters\expectAdded(CompatibilityTab::COLUMNS_FILTER)->once();
|
||||
$registry = self::registry();
|
||||
@@ -97,17 +97,17 @@ final class PluginTest extends TestCase
|
||||
self::assertArrayNotHasKey('pods', $registry->grouped());
|
||||
}
|
||||
|
||||
/** WP Super Cache is registered with its profile; its tool group appears only while the plugin is loaded. */
|
||||
public function testSuperCacheIsRegisteredAndNoToolGroupWithoutTheCachePlugin(): void
|
||||
/** WP Fastest Cache is registered with its profile; its tool group appears only while the plugin is loaded. */
|
||||
public function testFastestCacheIsRegisteredAndNoToolGroupWithoutTheCachePlugin(): void
|
||||
{
|
||||
$registry = self::registry();
|
||||
|
||||
self::assertContains('wpsc', $registry->ids());
|
||||
self::assertArrayNotHasKey('wpsc', $registry->grouped());
|
||||
self::assertContains('wpfc', $registry->ids());
|
||||
self::assertArrayNotHasKey('wpfc', $registry->grouped());
|
||||
}
|
||||
|
||||
/**
|
||||
* The purger of the real wiring asks the registry's Compatibility at call time: with WP Super Cache loaded and
|
||||
* The purger of the real wiring asks the registry's Compatibility at call time: with WP Fastest Cache loaded and
|
||||
* its manifest met, the whole-cache purge runs (a registry captured by value would still be null: always locked).
|
||||
*
|
||||
* @runInSeparateProcess
|
||||
@@ -115,33 +115,34 @@ final class PluginTest extends TestCase
|
||||
*/
|
||||
public function testTheWiredPurgerAsksTheCompatibilityOfTheRegistry(): void
|
||||
{
|
||||
define('WPCACHEHOME', '/plugins/wp-super-cache/');
|
||||
eval('function wp_cache_post_edit($id) { $GLOBALS["wpsc_calls"][] = "post:" . $id; }'
|
||||
. 'function wp_cache_clear_cache($blog = 0) { $GLOBALS["wpsc_calls"][] = "all:" . $blog; }');
|
||||
$GLOBALS['wpsc_calls'] = [];
|
||||
$GLOBALS['cache_path'] = '/cache/';
|
||||
$GLOBALS['blog_cache_dir'] = '/cache/blogs/';
|
||||
$GLOBALS['cache_enabled'] = true;
|
||||
Functions\when('get_file_data')->justReturn(['Version' => '3.1.5']);
|
||||
define('WPFC_MAIN_PATH', '/plugins/wp-fastest-cache/');
|
||||
eval('function wpfc_clear_post_cache_by_id($id = false) { $GLOBALS["wpfc_calls"][] = "post:" . $id; }'
|
||||
. 'function wpfc_clear_all_cache($minified = false) { $GLOBALS["wpfc_calls"][] = "all"; }'
|
||||
. 'class WpFastestCache { public function singleDeleteCache($c = false, $p = false, $parents = true) {}'
|
||||
. ' public function getWpContentDir($path = false) { return ""; } }');
|
||||
$GLOBALS['wpfc_calls'] = [];
|
||||
$GLOBALS['wp_fastest_cache'] = new \WpFastestCache();
|
||||
$GLOBALS['wp_fastest_cache_options'] = (object) ['wpFastestCacheStatus' => 'on'];
|
||||
Functions\when('get_file_data')->justReturn(['Version' => '1.5.5']);
|
||||
Functions\when('get_option')->justReturn(false);
|
||||
Functions\when('get_transient')->justReturn(false);
|
||||
Functions\when('set_transient')->justReturn(true);
|
||||
Functions\when('is_multisite')->justReturn(false);
|
||||
Functions\when('current_user_can')->justReturn(true);
|
||||
$integrations = (new ReflectionProperty(IntegrationRegistry::class, 'integrations'))->getValue(self::registry(log: new FakeChangeLog(1)));
|
||||
$wpsc = array_values(array_filter(
|
||||
$wpfc = array_values(array_filter(
|
||||
$integrations,
|
||||
static fn ($integration): bool => $integration->id() === 'wpsc'
|
||||
static fn ($integration): bool => $integration->id() === 'wpfc'
|
||||
))[0];
|
||||
|
||||
$result = $wpsc->abilities()[0]->execute(['scope' => 'all', 'confirm' => true]);
|
||||
$result = $wpfc->abilities()[0]->execute(['scope' => 'all', 'confirm' => true]);
|
||||
|
||||
self::assertSame('purged', $result['outcome']);
|
||||
self::assertSame(['all:0'], $GLOBALS['wpsc_calls']);
|
||||
self::assertSame(['all'], $GLOBALS['wpfc_calls']);
|
||||
}
|
||||
|
||||
/** lit-site-status keeps its order: Divi, Pods, WP Super Cache, The Events Calendar. */
|
||||
public function testSiteStatusListsDiviPodsSuperCacheAndTheEventsCalendarInThatOrder(): void
|
||||
/** lit-site-status keeps its order: Divi, Pods, WP Fastest Cache, The Events Calendar. */
|
||||
public function testSiteStatusListsDiviPodsFastestCacheAndTheEventsCalendarInThatOrder(): void
|
||||
{
|
||||
Functions\when('get_bloginfo')->justReturn('x');
|
||||
Functions\when('home_url')->justReturn('https://example.test');
|
||||
@@ -158,13 +159,13 @@ final class PluginTest extends TestCase
|
||||
|
||||
$components = $status->execute([])['components'];
|
||||
|
||||
self::assertSame(['divi', 'pods', 'wpsc', 'the-events-calendar'], array_column($components, 'id'));
|
||||
self::assertSame(['divi', 'pods', 'wpfc', 'the-events-calendar'], array_column($components, 'id'));
|
||||
$pods = array_column($components, null, 'id')['pods'];
|
||||
self::assertFalse($pods['active'], 'no Pods in unit tests');
|
||||
self::assertSame([], $pods['problems']);
|
||||
$wpsc = array_column($components, null, 'id')['wpsc'];
|
||||
self::assertFalse($wpsc['active'], 'no WP Super Cache in unit tests');
|
||||
self::assertSame([], $wpsc['problems']);
|
||||
$wpfc = array_column($components, null, 'id')['wpfc'];
|
||||
self::assertFalse($wpfc['active'], 'no WP Fastest Cache in unit tests');
|
||||
self::assertSame([], $wpfc['problems']);
|
||||
}
|
||||
|
||||
public function testTheCompatibilityCoversAllProfilesWithoutIdCollision(): void
|
||||
@@ -172,9 +173,9 @@ final class PluginTest extends TestCase
|
||||
$compat = self::registry()->compatibility();
|
||||
|
||||
$ids = array_map(static fn (Profile $p): string => $p->id, $compat->profiles());
|
||||
self::assertSame(['divi', 'pods', 'wpsc'], $ids);
|
||||
self::assertSame(['divi', 'pods', 'wpfc'], $ids);
|
||||
self::assertSame($ids, array_values(array_unique($ids)));
|
||||
self::assertSame('wpsc', $compat->owner($compat->capability('wpsc-purge-all'))?->id);
|
||||
self::assertSame('wpfc', $compat->owner($compat->capability('wpfc-purge-all'))?->id);
|
||||
self::assertNotNull($compat->capability('page-write'));
|
||||
self::assertNotNull($compat->capability('pods-field-read'));
|
||||
self::assertSame('divi', $compat->owner($compat->capability('page-write'))?->id);
|
||||
|
||||
Reference in New Issue
Block a user