Skip to content

Commit

Permalink
Skip tests for PairedBrowsing if WP < 5
Browse files Browse the repository at this point in the history
  • Loading branch information
thelovekesh committed Feb 7, 2023
1 parent 8fd04db commit 56daefa
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/php/src/Admin/PairedBrowsingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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' ) );
Expand All @@ -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' );
}
}
}

0 comments on commit 56daefa

Please sign in to comment.