Skip to content

Commit 04a08ac

Browse files
Sarthak JaiswalSarthak Jaiswal
authored andcommitted
Used get_echo() function to reduce code
1 parent 3af6650 commit 04a08ac

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

plugins/speculation-rules/tests/test-speculation-rules-settings.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,7 @@ public function test_add_setting_ui(): void {
206206
$this->assertArrayHasKey( 'plsr_speculation_rules', $wp_settings_sections['reading'] );
207207

208208
// Check the output of the callback function for the section.
209-
ob_start();
210-
call_user_func( $wp_settings_sections['reading']['plsr_speculation_rules']['callback'] );
211-
$output = ob_get_clean();
209+
$output = get_echo( $wp_settings_sections['reading']['plsr_speculation_rules']['callback'] );
212210
$this->assertStringContainsString( 'This section allows you to control how URLs that your users navigate to are speculatively loaded to improve performance.', $output );
213211
}
214212

@@ -265,9 +263,7 @@ public function test_render_settings_field( array $args, array $stored_settings,
265263
update_option( 'plsr_speculation_rules', $stored_settings );
266264

267265
// Capture the output of the settings field rendering.
268-
ob_start();
269-
plsr_render_settings_field( $args );
270-
$output = ob_get_clean();
266+
$output = get_echo( 'plsr_render_settings_field', array( $args ) );
271267

272268
// Check for the presence of form elements.
273269
$this->assertStringContainsString( $name_check, $output );

0 commit comments

Comments
 (0)