diff --git a/tests/test-template.php b/tests/test-template.php index 6d81766f0..e822c0903 100644 --- a/tests/test-template.php +++ b/tests/test-template.php @@ -11,6 +11,7 @@ * Tests for template.php */ class Test_Template extends TestCase { + /** * Test if function adding script on GET method, is_offline() or is_500 is true * @@ -21,8 +22,7 @@ public function test_wp_service_worker_offline_page_reload() { $this->assertEquals( 10, has_action( 'error_footer', 'wp_service_worker_offline_page_reload' ) ); // Check when method is GET but not offline or 500. - $actual_script = wp_service_worker_offline_page_reload(); - $this->assertEquals( $_SERVER['REQUEST_METHOD'], 'GET' ); + $actual_script = get_echo( 'wp_service_worker_offline_page_reload' ); $this->assertFalse( is_offline() ); $this->assertFalse( is_500() ); $this->assertEmpty( $actual_script ); @@ -31,36 +31,20 @@ public function test_wp_service_worker_offline_page_reload() { $error_template_url = add_query_arg( 'wp_error_template', 'offline', home_url( '/', 'relative' ) ); $this->go_to( $error_template_url ); - ob_start(); - wp_service_worker_offline_page_reload(); - $actual_script = ob_get_clean(); - $this->assertEquals( $_SERVER['REQUEST_METHOD'], 'GET' ); + $actual_script = get_echo( 'wp_service_worker_offline_page_reload' ); $this->assertTrue( is_offline() ); $this->assertFalse( is_500() ); $this->assertStringContainsString( '