Skip to content

Commit

Permalink
Update assertion for older PHP+WP version compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixarntz committed Nov 12, 2023
1 parent c270361 commit 321b34b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/phpunit/tests/Plugin_Tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ public function test_fast_smooth_scroll_print_style() {
return;
}
$this->assertMatchesRegularExpression( $pattern, $output );

if ( ! method_exists( $this, 'assertStringContainsString' ) ) {
$this->assertTrue( false !== strpos( $output, '@media (prefers-reduced-motion: reduce) {' ) );
return;
}
$this->assertStringContainsString( '@media (prefers-reduced-motion: reduce) {', $output );
}

Expand Down Expand Up @@ -82,7 +87,6 @@ public function test_fast_smooth_scroll_register_scripts_does_not_print_offset_s
$this->assertFalse( strpos( $polyfills_inline_script, 'var fastSmoothScrollOffset = ' ) );
return;
}

$this->assertStringNotContainsString( 'var fastSmoothScrollOffset = ', $polyfill_inline_script );
$this->assertStringNotContainsString( 'var fastSmoothScrollOffset = ', $polyfills_inline_script );
}
Expand All @@ -103,6 +107,11 @@ public function test_fast_smooth_scroll_register_scripts_prints_offset_script_wi
// Restore original `$wp_scripts`.
$wp_scripts = $orig_wp_scripts;

if ( ! method_exists( $this, 'assertStringContainsString' ) ) {
$this->assertTrue( false !== strpos( $polyfill_inline_script, 'var fastSmoothScrollOffset = 120;' ) );
$this->assertTrue( false !== strpos( $polyfills_inline_script, 'var fastSmoothScrollOffset = 120;' ) );
return;
}
$this->assertStringContainsString( 'var fastSmoothScrollOffset = 120;', $polyfill_inline_script );
$this->assertStringContainsString( 'var fastSmoothScrollOffset = 120;', $polyfills_inline_script );
}
Expand Down

0 comments on commit 321b34b

Please sign in to comment.