From 070e9e4381a4b6a566526a5bb7dfbac320878b42 Mon Sep 17 00:00:00 2001 From: Gopal Krishnan Date: Tue, 3 Oct 2023 10:58:57 +1100 Subject: [PATCH] Add the governance plugin (#4907) * Add the VIP Governance plugin to the integrations * Update the config used for seeing if the governance plugin is loaded or not * Add a test for the new vip-governance integration * Leave only the single test that actually tests some functionality * Add a test for the Block Data API as well * Shift the import lines to be in the right order * Add in a test to see if the isloaded method works correctly for both the integrations * Add a code coverage ignore block to the registrations * Remove the extra false loaded check * Switch the isLoad check to not define any constant * Initial rollout safeguard --- integrations/vip-governance.php | 63 +++++++++++++++++++ .../integrations/test-vip-block-data-api.php | 30 +++++++++ tests/integrations/test-vip-governance.php | 30 +++++++++ vip-integrations.php | 10 +++ 4 files changed, 133 insertions(+) create mode 100644 integrations/vip-governance.php create mode 100644 tests/integrations/test-vip-block-data-api.php create mode 100644 tests/integrations/test-vip-governance.php diff --git a/integrations/vip-governance.php b/integrations/vip-governance.php new file mode 100644 index 0000000000..de9bdce570 --- /dev/null +++ b/integrations/vip-governance.php @@ -0,0 +1,63 @@ +is_loaded() ) { + return; + } + + // Load the version of the plugin that should be set to the latest version, otherwise if it's not found deactivate the integration. + $load_path = WPMU_PLUGIN_DIR . '/vip-integrations/vip-governance-' . $this->version . '/vip-governance.php'; + if ( file_exists( $load_path ) ) { + require_once $load_path; + } else { + $this->is_active = false; + } + } ); + } + + /** + * Configure `VIP Governance` for VIP Platform. + */ + public function configure(): void {} +} diff --git a/tests/integrations/test-vip-block-data-api.php b/tests/integrations/test-vip-block-data-api.php new file mode 100644 index 0000000000..5d32c50489 --- /dev/null +++ b/tests/integrations/test-vip-block-data-api.php @@ -0,0 +1,30 @@ +slug ); + + $block_data_api_integration->load(); + + $this->assertFalse( $block_data_api_integration->is_active() ); + } + + public function test__if_is_loaded_gives_back_true_when_loaded(): void { + $block_data_api_integration = new BlockDataApiIntegration( $this->slug ); + + $this->assertFalse( $block_data_api_integration->is_loaded() ); + } +} diff --git a/tests/integrations/test-vip-governance.php b/tests/integrations/test-vip-governance.php new file mode 100644 index 0000000000..ab1754ef63 --- /dev/null +++ b/tests/integrations/test-vip-governance.php @@ -0,0 +1,30 @@ +slug ); + + $vip_governance_integration->load(); + + $this->assertFalse( $vip_governance_integration->is_active() ); + } + + public function test__if_is_loaded_gives_back_true_when_loaded(): void { + $vip_governance_integration = new VipGovernanceIntegration( $this->slug ); + + $this->assertFalse( $vip_governance_integration->is_loaded() ); + } +} diff --git a/vip-integrations.php b/vip-integrations.php index 207804117f..0767948588 100644 --- a/vip-integrations.php +++ b/vip-integrations.php @@ -14,6 +14,8 @@ defined( 'ABSPATH' ) || die(); +// @codeCoverageIgnoreStart - the actual code here is tested individually in the unit tests. + require_once __DIR__ . '/integrations/integration.php'; require_once __DIR__ . '/integrations/integrations.php'; require_once __DIR__ . '/integrations/enums.php'; @@ -25,6 +27,14 @@ IntegrationsSingleton::instance()->register( new BlockDataApiIntegration( 'block-data-api' ) ); IntegrationsSingleton::instance()->register( new ParselyIntegration( 'parsely' ) ); +// ToDo: Remove this after the initial deployment of the VIP Governance integration. +if ( file_exists( __DIR__ . '/integrations/vip-governance.php' ) ) { + require_once __DIR__ . '/integrations/vip-governance.php'; + IntegrationsSingleton::instance()->register( new VipGovernanceIntegration( 'vip-governance' ) ); +} + +// @codeCoverageIgnoreEnd + /** * Activates an integration with an optional configuration value. *