Skip to content

Commit bd57a12

Browse files
committed
Tests: Update fonts tests to use semantic HTML comparison.
This aims to make the tests more robust. Follow-up to [60295], [61391], [61392]. Props jonsurrell. See #64225. git-svn-id: https://develop.svn.wordpress.org/trunk@61409 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 7c7e521 commit bd57a12

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

tests/phpunit/tests/fonts/font-face/wpFontFace/generateAndPrint.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function test_should_generate_and_print_given_fonts( array $fonts, $expec
3434
$style_element = "<style class='wp-fonts-local' type='text/css'>\n%s\n</style>\n";
3535
$expected_output = sprintf( $style_element, $expected );
3636

37-
$this->expectOutputString( $expected_output );
38-
$font_face->generate_and_print( $fonts );
37+
$output = get_echo( array( $font_face, 'generate_and_print' ), array( $fonts ) );
38+
$this->assertEqualHTML( $expected_output, $output );
3939
}
4040
}

tests/phpunit/tests/fonts/font-face/wpPrintFontFaces.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ public function test_should_not_print_when_no_fonts() {
3737
public function test_should_print_given_fonts( array $fonts, $expected ) {
3838
$expected_output = $this->get_expected_styles_output( $expected );
3939

40-
$this->expectOutputString( $expected_output );
41-
wp_print_font_faces( $fonts );
40+
$output = get_echo( 'wp_print_font_faces', array( $fonts ) );
41+
$this->assertEqualHTML( $expected_output, $output );
4242
}
4343

4444
public function test_should_escape_tags() {
@@ -60,9 +60,9 @@ public function test_should_escape_tags() {
6060
</style>
6161
6262
CSS;
63-
$this->expectOutputString( $expected_output );
6463

65-
wp_print_font_faces( $fonts );
64+
$output = get_echo( 'wp_print_font_faces', array( $fonts ) );
65+
$this->assertEqualHTML( $expected_output, $output );
6666
}
6767

6868
public function test_should_print_fonts_in_merged_data() {
@@ -71,8 +71,8 @@ public function test_should_print_fonts_in_merged_data() {
7171
$expected = $this->get_expected_fonts_for_fonts_block_theme( 'font_face_styles' );
7272
$expected_output = $this->get_expected_styles_output( $expected );
7373

74-
$this->expectOutputString( $expected_output );
75-
wp_print_font_faces();
74+
$output = get_echo( 'wp_print_font_faces' );
75+
$this->assertEqualHTML( $expected_output, $output );
7676
}
7777

7878
private function get_expected_styles_output( $styles ) {

tests/phpunit/tests/fonts/font-face/wpPrintFontFacesFromStyleVariations.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ public function test_should_print_fonts_in_style_variations() {
4343
$expected = $this->get_custom_style_variations( 'expected_styles' );
4444
$expected_output = $this->get_expected_styles_output( $expected );
4545

46-
$this->expectOutputString( $expected_output );
47-
wp_print_font_faces_from_style_variations();
46+
$output = get_echo( 'wp_print_font_faces_from_style_variations' );
47+
$this->assertEqualHTML( $expected_output, $output );
4848
}
4949

5050
private function get_expected_styles_output( $styles ) {

0 commit comments

Comments
 (0)