From 321b34b25ed8c7b331565c5a9f17013ec3503c9b Mon Sep 17 00:00:00 2001 From: Felix Arntz Date: Sat, 11 Nov 2023 17:55:41 -0800 Subject: [PATCH] Update assertion for older PHP+WP version compatibility. --- tests/phpunit/tests/Plugin_Tests.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/phpunit/tests/Plugin_Tests.php b/tests/phpunit/tests/Plugin_Tests.php index 620887b..4477ee7 100644 --- a/tests/phpunit/tests/Plugin_Tests.php +++ b/tests/phpunit/tests/Plugin_Tests.php @@ -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 ); } @@ -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 ); } @@ -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 ); }