Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
jazzsequence committed Apr 22, 2024
1 parent f06de38 commit 6f8456d
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions tests/phpunit/test-site-health.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
<?php

/**
* Pantheon Site Health page Tests
*
* @package pantheon
*/

/**
* Pantheon Site Health page Test Case
*/
class Test_Site_Health extends WP_UnitTestCase {
/**
* The original active plugins.
*
* Used to restore the original active plugins after the test.
*
* @var array
*/
private $original_active_plugins;

public function setUp(): void {
Expand All @@ -27,7 +36,7 @@ private function set_active_plugin( $plugin ) {
}

public function test_site_health_mods() {
// Mock array to represent the structure passed to the filter
// Mock array to represent the structure passed to the filter.
$mock_tests = [
'direct' => [
'update_temp_backup_writable' => [],
Expand All @@ -40,9 +49,9 @@ public function test_site_health_mods() {

$result = apply_filters( 'site_status_tests', $mock_tests );

$this->assertArrayNotHasKey('update_temp_backup_writable', $result['direct']);
$this->assertArrayNotHasKey('available_updates_disk_space', $result['direct']);
$this->assertArrayNotHasKey('background_updates', $result['async']);
$this->assertArrayNotHasKey( 'update_temp_backup_writable', $result['direct'] );
$this->assertArrayNotHasKey( 'available_updates_disk_space', $result['direct'] );
$this->assertArrayNotHasKey( 'background_updates', $result['async'] );
}

public function test_object_cache_no_redis() {
Expand All @@ -53,8 +62,7 @@ public function test_object_cache_no_redis() {
}

public function test_object_cache_with_redis_no_plugin() {
// Mock the environment for this scenario
$_ENV['CACHE_HOST'] = 'cacheserver'; // Ensure CACHE_HOST is set
$_ENV['CACHE_HOST'] = 'cacheserver'; // Ensure CACHE_HOST is set.

$result = Pantheon\Site_Health\test_object_cache();

Expand All @@ -63,22 +71,22 @@ public function test_object_cache_with_redis_no_plugin() {
}

public function test_object_cache_with_wpredis_active() {
$_ENV['CACHE_HOST'] = 'cacheserver'; // Ensure CACHE_HOST is set
$_ENV['CACHE_HOST'] = 'cacheserver'; // Ensure CACHE_HOST is set.
$this->set_active_plugin( 'wp-redis/wp-redis.php' );

$result = Pantheon\Site_Health\test_object_cache();

$this->assertEquals( 'recommended', $result['status'] );
$this->assertStringContainsString('WP Redis is active for your site. We recommend using Object Cache Pro.', $result['description'] );
$this->assertStringContainsString( 'WP Redis is active for your site. We recommend using Object Cache Pro.', $result['description'] );
}

public function test_object_cache_with_ocp_active() {
$_ENV['CACHE_HOST'] = 'cacheserver'; // Ensure CACHE_HOST is set
$_ENV['CACHE_HOST'] = 'cacheserver'; // Ensure CACHE_HOST is set.
$this->set_active_plugin( 'object-cache-pro/object-cache-pro.php' );

$result = Pantheon\Site_Health\test_object_cache();

$this->assertEquals( 'good', $result['status'] );
$this->assertStringContainsString('Object Cache Pro is active for your site.', $result['description'] );
$this->assertStringContainsString( 'Object Cache Pro is active for your site.', $result['description'] );
}
}
}

0 comments on commit 6f8456d

Please sign in to comment.