From 75f3b6d010457964b873e60685c24c74f5e39496 Mon Sep 17 00:00:00 2001 From: castellon Date: Tue, 1 Dec 2026 11:03:05 +0100 Subject: [PATCH] Test: do not assume FrontConsent is missing from the plugins folder get_frontconsent_action_url() returns an activate link when FrontConsent is already in wp-content/plugins and an install link otherwise. The test always expected the install link, so it passed on the CI (clean install) and failed on any development site that has FrontConsent. It now expects the link that matches what is on disk. --- tests/Unit/CookieNoticeDeprecationNoticeTest.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/Unit/CookieNoticeDeprecationNoticeTest.php b/tests/Unit/CookieNoticeDeprecationNoticeTest.php index eef2abc8..8435c1f9 100644 --- a/tests/Unit/CookieNoticeDeprecationNoticeTest.php +++ b/tests/Unit/CookieNoticeDeprecationNoticeTest.php @@ -87,9 +87,9 @@ public function test_promo_tab_hides_the_install_cta_without_install_plugins_cap } /** - * A user who does have the capability still sees the real install link. + * A user who does have the capability still sees the real install (or activate) link. */ - public function test_promo_tab_shows_the_install_cta_with_install_plugins_capability() { + public function test_promo_tab_shows_the_install_or_activate_cta_with_install_plugins_capability() { $user_id = self::factory()->user->create( array( 'role' => 'administrator' ) ); wp_set_current_user( $user_id ); @@ -103,7 +103,12 @@ public function test_promo_tab_shows_the_install_cta_with_install_plugins_capabi $method->invoke( $settings ); $output = ob_get_clean(); - $this->assertStringContainsString( 'action=install-plugin', html_entity_decode( $output, ENT_QUOTES, 'UTF-8' ) ); + // The button installs FrontConsent, or activates it when a copy is already in the plugins folder (as on a + // development site), so the expectation follows what is on disk instead of assuming a clean install. + $installed = file_exists( WP_PLUGIN_DIR . '/frontconsent/frontconsent.php' ) || file_exists( WP_PLUGIN_DIR . '/front-consent/frontconsent.php' ); + $expected = $installed ? 'action=activate' : 'action=install-plugin'; + + $this->assertStringContainsString( $expected, html_entity_decode( $output, ENT_QUOTES, 'UTF-8' ) ); } /**