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'); } }