Skip to content

Commit 6f60f80

Browse files
committed
HTML API: Use assertEqualHTML() in wp_rel_ugc() tests.
In some tests, the expected output was updated to its pure HTML state, removing the wrapping call to `wp_slash()`. Instead, `stripslashes()` has been applied to the output of the code under function. This leaves more readable test failures. Developed in WordPress#9255 Discussed in https://core.trac.wordpress.org/ticket/63694 Props dmsnell, jonsurrell. See #63694. git-svn-id: https://develop.svn.wordpress.org/trunk@60485 602fd350-edb4-49c9-b593-d223f7449a82
1 parent d47a104 commit 6f60f80

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

tests/phpunit/tests/comment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public function test_update_comment_from_unprivileged_user_by_privileged_user()
168168
wp_set_current_user( 0 );
169169

170170
$comment = get_comment( $comment_id );
171-
$this->assertSame( '<a href="http://example.localhost/something.html" rel="nofollow ugc">click</a>', $comment->comment_content, 'Comment: ' . $comment->comment_content );
171+
$this->assertEqualHTML( '<a href="http://example.localhost/something.html" rel="nofollow ugc">click</a>', $comment->comment_content, '<body>', 'Comment: ' . $comment->comment_content );
172172
}
173173

174174
/**

tests/phpunit/tests/formatting/wpRelUgc.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,25 @@ class Tests_Formatting_wpRelUgc extends WP_UnitTestCase {
1212
*/
1313
public function test_add_ugc() {
1414
$content = '<p>This is some cool <a href="/">Code</a></p>';
15-
$expected = '<p>This is some cool <a href=\"/\" rel=\"nofollow ugc\">Code</a></p>';
16-
$this->assertSame( $expected, wp_rel_ugc( $content ) );
15+
$expected = '<p>This is some cool <a href="/" rel="nofollow ugc">Code</a></p>';
16+
$this->assertEqualHTML( $expected, stripslashes( wp_rel_ugc( $content ) ) );
1717
}
1818

1919
/**
2020
* @ticket 48022
2121
*/
2222
public function test_convert_ugc() {
2323
$content = '<p>This is some cool <a href="/" rel="weird">Code</a></p>';
24-
$expected = '<p>This is some cool <a href=\"/\" rel=\"weird nofollow ugc\">Code</a></p>';
25-
$this->assertSame( $expected, wp_rel_ugc( $content ) );
24+
$expected = '<p>This is some cool <a href="/" rel="weird nofollow ugc">Code</a></p>';
25+
$this->assertEqualHTML( $expected, stripslashes( wp_rel_ugc( $content ) ) );
2626
}
2727

2828
/**
2929
* @ticket 48022
3030
* @dataProvider data_wp_rel_ugc
3131
*/
3232
public function test_wp_rel_ugc( $input, $output, $expect_deprecation = false ) {
33-
$this->assertSame( wp_slash( $output ), wp_rel_ugc( $input ) );
33+
$this->assertEqualHTML( $output, stripslashes( wp_rel_ugc( $input ) ) );
3434
}
3535

3636
public function data_wp_rel_ugc() {
@@ -81,7 +81,7 @@ public function data_wp_rel_ugc() {
8181
public function test_append_ugc_with_valueless_attribute() {
8282

8383
$content = '<p>This is some cool <a href="demo.com" download rel="hola">Code</a></p>';
84-
$expected = '<p>This is some cool <a href=\"demo.com\" download rel=\"hola nofollow ugc\">Code</a></p>';
85-
$this->assertSame( $expected, wp_rel_ugc( $content ) );
84+
$expected = '<p>This is some cool <a href="demo.com" download rel="hola nofollow ugc">Code</a></p>';
85+
$this->assertEqualHTML( $expected, stripslashes( wp_rel_ugc( $content ) ) );
8686
}
8787
}

0 commit comments

Comments
 (0)