Skip to content

Commit 36013ff

Browse files
committed
PICKME: Update font tests to use semantic HTML comparison
1 parent 3d9fde3 commit 36013ff

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ 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(
38+
function () use ( $font_face, $fonts ) {
39+
$font_face->generate_and_print( $fonts );
40+
}
41+
);
42+
$this->assertEqualHTML( $expected_output, $output );
3943
}
4044
}

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,12 @@ 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(
41+
function () use ( $fonts ) {
42+
wp_print_font_faces( $fonts );
43+
}
44+
);
45+
$this->assertEqualHTML( $expected_output, $output );
4246
}
4347

4448
public function test_should_escape_tags() {
@@ -60,9 +64,13 @@ public function test_should_escape_tags() {
6064
</style>
6165
6266
CSS;
63-
$this->expectOutputString( $expected_output );
6467

65-
wp_print_font_faces( $fonts );
68+
$output = get_echo(
69+
function () use ( $fonts ) {
70+
wp_print_font_faces( $fonts );
71+
}
72+
);
73+
$this->assertEqualHTML( $expected_output, $output );
6674
}
6775

6876
public function test_should_print_fonts_in_merged_data() {
@@ -71,8 +79,8 @@ public function test_should_print_fonts_in_merged_data() {
7179
$expected = $this->get_expected_fonts_for_fonts_block_theme( 'font_face_styles' );
7280
$expected_output = $this->get_expected_styles_output( $expected );
7381

74-
$this->expectOutputString( $expected_output );
75-
wp_print_font_faces();
82+
$output = get_echo( 'wp_print_font_faces' );
83+
$this->assertEqualHTML( $expected_output, $output );
7684
}
7785

7886
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)