id); self::assertSame('WP Super Cache', $profile->label); self::assertSame(Tier::LockOnFailure, $profile->tier); self::assertSame(['3.1.5'], $profile->testedVersions); self::assertNull($profile->minVersion); self::assertSame(SuperCacheFeature::cases(), $profile->capabilities); } /** Argument counts are those the listener passes; wp_cache_clear_cache($blog_id = 0) gets the blog. */ public function testTheManifestHoldsTheTwoPurgeFunctionsWithTheirArgumentCounts(): void { $manifest = SuperCacheCompatibility::profile()->manifests[0]; $calls = []; foreach ($manifest->calls as $call) { $calls[$call->symbol] = [$call->args, $call->features()]; } self::assertSame([ 'wp_cache_post_edit' => [1, [SuperCacheFeature::PurgePost]], 'wp_cache_clear_cache' => [1, [SuperCacheFeature::PurgeAll]], ], $calls); self::assertContainsOnlyInstancesOf(Call::class, $manifest->calls); } /** Both purge functions read $cache_path; wp_cache_post_edit also $blog_cache_dir. */ public function testTheGlobalsTheFunctionsReadAreRequired(): void { $manifest = SuperCacheCompatibility::profile()->manifests[0]; self::assertSame(['WPCACHEHOME'], array_map(static fn ($c) => $c->name, $manifest->constants)); $globals = []; foreach ($manifest->globals as $global) { $globals[$global->name] = $global->features(); } self::assertSame( ['cache_path' => SuperCacheFeature::cases(), 'blog_cache_dir' => [SuperCacheFeature::PurgePost]], $globals ); } /** * @runInSeparateProcess * @preserveGlobalState disabled */ public function testActiveAndVersionFollowTheCacheHomeConstantAndThePluginHeader(): void { $profile = SuperCacheCompatibility::profile(); self::assertFalse(($profile->active)()); self::assertNull(($profile->version)()); define('WPCACHEHOME', '/plugins/wp-super-cache/'); Functions\expect('get_file_data') ->once() ->with('/plugins/wp-super-cache/wp-cache.php', ['Version' => 'Version']) ->andReturn(['Version' => '3.1.5']); self::assertTrue(($profile->active)()); self::assertSame('3.1.5', ($profile->version)()); } /** * @runInSeparateProcess * @preserveGlobalState disabled */ public function testAnUnreadableHeaderIsAnUnknownVersion(): void { define('WPCACHEHOME', '/plugins/wp-super-cache/'); Functions\when('get_file_data')->justReturn(['Version' => '']); self::assertNull((SuperCacheCompatibility::profile()->version)()); } public function testAllProfilesCoexistWithoutIdCollision(): void { $compatibility = new Compatibility( [DiviProfile::profile(), PodsCompatibility::profile(), SuperCacheCompatibility::profile()] ); self::assertSame(['divi', 'pods', 'wpsc'], array_map(static fn ($p) => $p->id, $compatibility->profiles())); self::assertSame(SuperCacheFeature::PurgeAll, $compatibility->capability('wpsc-purge-all')); } }