[wp-trac] [WordPress Trac] #50860: Fix duplicate array keys in Tests_Kses::test_wp_filter_post_kses_address method
WordPress Trac
noreply at wordpress.org
Wed Aug 5 14:30:24 UTC 2020
#50860: Fix duplicate array keys in Tests_Kses::test_wp_filter_post_kses_address
method
------------------------------+-----------------------------
Reporter: ediamin | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Build/Test Tools | Version:
Severity: normal | Keywords: has-patch
Focuses: |
------------------------------+-----------------------------
This is the current code
{{{
function test_wp_filter_post_kses_address() {
global $allowedposttags;
$attributes = array(
'class' => 'classname',
'id' => 'id',
'style' => 'color: red;',
'style' => 'color: red',
'style' => 'color: red; text-align:center',
'style' => 'color: red; text-align:center;',
'title' => 'title',
);
foreach ( $attributes as $name => $value ) {
$string = "<address $name='$value'>1 WordPress
Avenue, The Internet.</address>";
$expect_string = "<address $name='" . str_replace( '; ',
';', trim( $value, ';' ) ) . "'>1 WordPress Avenue, The
Internet.</address>";
$this->assertEquals( $expect_string, wp_kses( $string,
$allowedposttags ) );
}
}
}}}
Here you can see the `$attributes` array contains four duplicate style
keys. So in practive, we are only testing for the last value of style that
is `color: red; text-align:center;`.
This patch tries to fix this problem by separating test assertions for
styles.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/50860>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list