From 56daefad6c9c987df7424a84f16dcc57bb5a0e67 Mon Sep 17 00:00:00 2001 From: thelovekesh Date: Wed, 8 Feb 2023 04:12:48 +0530 Subject: [PATCH] Skip tests for PairedBrowsing if WP < 5 --- tests/php/src/Admin/PairedBrowsingTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/php/src/Admin/PairedBrowsingTest.php b/tests/php/src/Admin/PairedBrowsingTest.php index 38400ccca51..994782cac2a 100644 --- a/tests/php/src/Admin/PairedBrowsingTest.php +++ b/tests/php/src/Admin/PairedBrowsingTest.php @@ -149,6 +149,8 @@ public function test_init_frontend_app() { * @covers ::init_client() */ public function test_init_frontend_client() { + $this->maybe_skip_test(); + wp_set_current_user( self::factory()->user->create( [ 'role' => 'administrator' ] ) ); $post = self::factory()->post->create_and_get(); AMP_Options_Manager::update_option( Option::THEME_SUPPORT, AMP_Theme_Support::TRANSITIONAL_MODE_SLUG ); @@ -232,6 +234,8 @@ function () use ( &$redirected ) { /** @covers ::filter_template_include_for_app() */ public function test_filter_template_include_for_app_when_allowed() { + $this->maybe_skip_test(); + $include_path = $this->instance->filter_template_include_for_app(); $this->assertTrue( wp_style_is( 'amp-paired-browsing-app' ) ); $this->assertTrue( wp_script_is( 'amp-paired-browsing-app' ) ); @@ -245,4 +249,13 @@ public function test_filter_template_include_for_app_when_allowed() { $this->assertStringContainsString( 'ampPairedBrowsingAppData', $template ); $this->assertStringContainsString( 'ampPairedBrowsingQueryVar', $template ); } + + /** + * Skip tests when wp-url and wp-dom-ready are not available. + */ + public function maybe_skip_test() { + if ( version_compare( get_bloginfo( 'version' ), '5.0', '<' ) ) { + $this->markTestSkipped( 'Skipping test as PairedBrowsing can\'t be tested due to lack of wp-dom-ready and wp-url scripts in WP < 5.0' ); + } + } }