Skip to content

Commit

Permalink
qa/cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
al-esc committed Jun 6, 2024
1 parent 8c4798f commit 08c9a3c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 22 deletions.
30 changes: 13 additions & 17 deletions pantheon.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,32 @@
* Plugin Name: Pantheon
* Plugin URI: https://pantheon.io/
* Description: Building on Pantheon's and WordPress's strengths, together.
* <<<<<<< HEAD
* Version: 1.4.4
* =======
* Version: 1.5.0
* >>>>>>> 05d46a9 (Feature: Add compatibility layer logic and status output.)
* Author: Pantheon
* Author URI: https://pantheon.io/
*
* @package pantheon
*/

define('PANTHEON_MU_PLUGIN_VERSION', '1.5.0');
define( 'PANTHEON_MU_PLUGIN_VERSION', '1.5.0' );

if (isset($_ENV['PANTHEON_ENVIRONMENT'])) {
if ( isset( $_ENV['PANTHEON_ENVIRONMENT'] ) ) {
require_once 'inc/functions.php';
require_once 'inc/pantheon-page-cache.php';
require_once 'inc/site-health.php';
if (!defined('DISABLE_PANTHEON_UPDATE_NOTICES') || !DISABLE_PANTHEON_UPDATE_NOTICES) {
if ( ! defined( 'DISABLE_PANTHEON_UPDATE_NOTICES' ) || ! DISABLE_PANTHEON_UPDATE_NOTICES ) {
require_once 'inc/pantheon-updates.php';
}
if (!defined('RETURN_TO_PANTHEON_BUTTON') || RETURN_TO_PANTHEON_BUTTON) {
if ( ! defined( 'RETURN_TO_PANTHEON_BUTTON' ) || RETURN_TO_PANTHEON_BUTTON ) {
require_once 'inc/pantheon-login-form-mods.php';
}
if ('dev' === $_ENV['PANTHEON_ENVIRONMENT'] && function_exists('wp_is_writable')) {
if ( 'dev' === $_ENV['PANTHEON_ENVIRONMENT'] && function_exists( 'wp_is_writable' ) ) {
require_once 'inc/pantheon-plugin-install-notice.php';
}
if (defined('WP_CLI') && WP_CLI) {
if ( defined( 'WP_CLI' ) && WP_CLI ) {
require_once 'inc/cli.php';
}
if (!defined('FS_METHOD')) {
if ( ! defined( 'FS_METHOD' ) ) {
/**
* When this constant is not set, WordPress writes and then deletes a
* temporary file to determine if it has direct access to the filesystem,
Expand All @@ -42,21 +38,21 @@
* Setting this constant to 'direct' tells WordPress to assume it has
* direct access and skip creating the extra temporary file.
*/
define('FS_METHOD', 'direct');
define( 'FS_METHOD', 'direct' );
}
// When developing a WordPress Multisite locally, ensure that this constant is set.
// This will set the Multisite variable in all Pantheon environments.
if (getenv('FRAMEWORK') === 'wordpress_network' && !defined('WP_ALLOW_MULTISITE')) {
define('WP_ALLOW_MULTISITE', true);
if ( getenv( 'FRAMEWORK' ) === 'wordpress_network' && ! defined( 'WP_ALLOW_MULTISITE' ) ) {
define( 'WP_ALLOW_MULTISITE', true );
}
if (defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE) {
if ( defined( 'WP_ALLOW_MULTISITE' ) && WP_ALLOW_MULTISITE ) {
require_once 'inc/pantheon-network-setup.php';
if (!defined('MULTISITE') && MULTISITE) {
if ( ! defined( 'MULTISITE' ) && MULTISITE ) {
require_once 'inc/pantheon-multisite-finalize.php';
}
}

if (!defined('PANTHEON_COMPATIBILITY') || PANTHEON_COMPATIBILITY) {
if ( ! defined( 'PANTHEON_COMPATIBILITY' ) || PANTHEON_COMPATIBILITY ) {
require_once 'inc/compatibility/class-compatibilityfactory.php';
Pantheon\Compatibility\CompatibilityFactory::get_instance();
}
Expand Down
24 changes: 19 additions & 5 deletions tests/phpunit/test-compatibility-layer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
*/

use Pantheon\Compatibility\CompatibilityFactory;
use Pantheon\Compatibility\ForceLogin;


/**
* Pantheon Compatibility Layer Test Case
*/
class Test_Compatibility_Layer extends WP_UnitTestCase {



/**
* The original active plugins.
*
Expand Down Expand Up @@ -60,6 +63,22 @@ public function test_instantiate_compatibility_layers() {
}
}

public function test_compatibility_hooks() {
$this->set_active_plugin( 'wp-force-login/wp-force-login.php' );
CompatibilityFactory::get_instance();
global $wp_filter;
$this->assertTrue( array_key_exists( 'deactivate_wp-force-login/wp-force-login.php', $wp_filter ) );
$hooked_functions = array_column($wp_filter['deactivate_wp-force-login/wp-force-login.php']->callbacks[10],
'function');
$function_names = array_column( $hooked_functions, 0 );
$this->assertInstanceOf( ForceLogin::class, $function_names[0] );
}

private function set_active_plugin( $plugin ) {
update_option( 'active_plugins', $plugin );
wp_cache_delete( 'plugins', 'plugins' );
}

public function test_daily_pantheon_cron() {
$this->set_active_plugin( 'wp-force-login/wp-force-login.php' );
$this->compatibility_factory->daily_pantheon_cron();
Expand All @@ -68,9 +87,4 @@ public function test_daily_pantheon_cron() {
$this->assertIsArray( $applied_fixes );
$this->assertArrayHasKey( 'wp-force-login/wp-force-login.php', $applied_fixes );
}

private function set_active_plugin( $plugin ) {
update_option( 'active_plugins', $plugin );
wp_cache_delete( 'plugins', 'plugins' );
}
}

0 comments on commit 08c9a3c

Please sign in to comment.