Skip to content

Commit

Permalink
Use get_echo instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
kuasha420 committed Jul 20, 2022
1 parent 45dceb5 commit 854df1d
Showing 1 changed file with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function test_content_placeholder_not_inserted_on_unselected_button_post_
);
$this->go_to( get_permalink( $post_ID ) );

$output = $this->capture_output( 'the_content' );
$output = get_echo( 'the_content' );

$this->assertStringNotContainsString( 'Thank with Google snippet added by Site Kit', $output );
$this->assertStringNotContainsString( '<button twg-button', $output );
Expand All @@ -63,7 +63,7 @@ public function test_content_placeholder_inserted_on_button_post_types() {

$this->create_post_and_go_to_it();

$output = $this->capture_output( 'the_content' );
$output = get_echo( 'the_content' );

$this->assertStringContainsString( 'Thank with Google snippet added by Site Kit', $output );
$this->assertStringContainsString( '<button twg-button', $output );
Expand All @@ -77,7 +77,7 @@ public function test_content_placeholder_not_inserted_on_dynamic_button_placemen

$this->create_post_and_go_to_it();

$output = $this->capture_output( 'the_content' );
$output = get_echo( 'the_content' );

$this->assertStringNotContainsString( 'Thank with Google snippet added by Site Kit', $output );
$this->assertStringNotContainsString( '<button twg-button', $output );
Expand All @@ -91,7 +91,7 @@ public function test_content_placeholder_inserted_static_below_content() {

$this->create_post_and_go_to_it();

$output = $this->capture_output( 'the_content' );
$output = get_echo( 'the_content' );
$content = get_the_content();

$this->assertStringStartsWith( $content, $output );
Expand All @@ -107,7 +107,7 @@ public function test_content_placeholder_inserted_static_above_content() {

$this->create_post_and_go_to_it();

$output = $this->capture_output( 'the_content' );
$output = get_echo( 'the_content' );
$content = get_the_content();

$this->assertStringEndsWith( $content, $output );
Expand All @@ -123,7 +123,7 @@ public function test_content_placeholder_inserted_static_below_first_paragraph()

$this->create_post_and_go_to_it();

$output = $this->capture_output( 'the_content' );
$output = get_echo( 'the_content' );

$this->assertStringStartsWith( '<p>Hello World</p>', $output );
$this->assertStringEndsWith( '<p>Goodbye World</p>', $output );
Expand All @@ -139,11 +139,4 @@ private function create_post_and_go_to_it() {
);
$this->go_to( get_permalink( $post_ID ) );
}

private function capture_output( $callback ) {
ob_start();
$callback();
$output = ob_get_clean();
return $output;
}
}

0 comments on commit 854df1d

Please sign in to comment.