From c3046830ee49676e654a9601cf641f62cf38c512 Mon Sep 17 00:00:00 2001 From: Vraja Das Date: Mon, 6 Jan 2025 09:07:26 +0200 Subject: [PATCH] fix php tests for integrations page --- src/integrations/admin/integrations-page.php | 13 +++++-------- .../Admin/Integrations_Page_Integration_Test.php | 15 +++++++++++---- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/integrations/admin/integrations-page.php b/src/integrations/admin/integrations-page.php index 64544403a30..c0971fe30d8 100644 --- a/src/integrations/admin/integrations-page.php +++ b/src/integrations/admin/integrations-page.php @@ -9,11 +9,9 @@ use WPSEO_Addon_Manager; use WPSEO_Admin_Asset_Manager; use Yoast\WP\SEO\Conditionals\Admin_Conditional; -use Yoast\WP\SEO\Conditionals\Jetpack_Conditional; use Yoast\WP\SEO\Conditionals\Google_Site_Kit_Feature_Conditional; +use Yoast\WP\SEO\Conditionals\Jetpack_Conditional; use Yoast\WP\SEO\Conditionals\Third_Party\Elementor_Activated_Conditional; - - use Yoast\WP\SEO\Helpers\Options_Helper; use Yoast\WP\SEO\Helpers\Woocommerce_Helper; use Yoast\WP\SEO\Integrations\Integration_Interface; @@ -115,8 +113,8 @@ public function enqueue_assets() { $this->admin_asset_manager->enqueue_script( 'integrations-page' ); - $elementor_conditional = new Elementor_Activated_Conditional(); - $jetpack_conditional = new Jetpack_Conditional(); + $elementor_conditional = new Elementor_Activated_Conditional(); + $jetpack_conditional = new Jetpack_Conditional(); $google_site_kit_conditional = new Google_Site_Kit_Feature_Conditional(); $woocommerce_seo_file = 'wpseo-woocommerce/wpseo-woocommerce.php'; @@ -143,7 +141,6 @@ public function enqueue_assets() { $ssp_active = \class_exists( PodcastEpisode::class ); $wp_recipe_maker_active = \class_exists( WP_Recipe_Maker::class ); $mastodon_active = $this->is_mastodon_active(); - $woocommerce_seo_activate_url = \wp_nonce_url( \self_admin_url( 'plugins.php?action=activate&plugin=' . $woocommerce_seo_file ), @@ -197,10 +194,10 @@ public function enqueue_assets() { 'mastodon_active' => $mastodon_active, 'is_multisite' => \is_multisite(), 'plugin_url' => \plugins_url( '', \WPSEO_FILE ), - 'googleSiteKit' => [ + 'googleSiteKit' => [ 'isInstalled' => \file_exists( \WP_PLUGIN_DIR . '/' . $google_site_kit_file ), 'isActive' => \is_plugin_active( $google_site_kit_file ), - 'afterSetup' => \get_option( 'googlesitekit_has_connected_admins', false ) === "1", + 'afterSetup' => \get_option( 'googlesitekit_has_connected_admins', false ) === '1', 'isConnected' => $this->options_helper->get( 'google_site_kit_connected', false ), 'featureEnabled' => $google_site_kit_conditional->is_met(), ], diff --git a/tests/Unit/Integrations/Admin/Integrations_Page_Integration_Test.php b/tests/Unit/Integrations/Admin/Integrations_Page_Integration_Test.php index e51203ed69f..63f57fc07c7 100644 --- a/tests/Unit/Integrations/Admin/Integrations_Page_Integration_Test.php +++ b/tests/Unit/Integrations/Admin/Integrations_Page_Integration_Test.php @@ -119,13 +119,13 @@ public function test_enqueue_assets() { Monkey\Functions\expect( 'get_site_url' ) ->andReturn( 'https://www.example.com' ); - Monkey\Functions\expect( 'is_plugin_active' )->times( 5 )->andReturnTrue(); + Monkey\Functions\expect( 'is_plugin_active' )->times( 6 )->andReturnTrue(); Monkey\Functions\expect( 'wp_nonce_url' )->times( 3 )->andReturn( 'nonce' ); Monkey\Functions\expect( 'self_admin_url' )->times( 3 )->andReturn( 'https://www.example.com' ); Monkey\Functions\expect( 'plugins_url' )->andReturn( 'https://www.example.com' ); Monkey\Functions\expect( 'admin_url' )->andReturn( 'https://www.example.com' ); - $this->options_helper->expects( 'get' )->times( 5 )->andReturnTrue(); + $this->options_helper->expects( 'get' )->times( 6 )->andReturnTrue(); $this->admin_asset_manager->expects( 'localize_script' )->with( 'integrations-page', @@ -137,8 +137,8 @@ public function test_enqueue_assets() { 'allow_algolia_integration' => true, 'wincher_integration_active' => true, 'allow_wincher_integration' => null, - 'elementor_integration_active' => true, - 'jetpack_integration_active' => true, + 'elementor_integration_active' => false, + 'jetpack_integration_active' => false, 'woocommerce_seo_installed' => false, 'woocommerce_seo_active' => true, 'woocommerce_active' => false, @@ -156,6 +156,13 @@ public function test_enqueue_assets() { 'mastodon_active' => false, 'is_multisite' => false, 'plugin_url' => 'https://www.example.com', + 'googleSiteKit' => [ + 'isInstalled' => false, + 'isActive' => true, + 'afterSetup' => false, + 'isConnected' => true, + 'featureEnabled' => false, + ], ] );