General: Fix 'rel' argument in Tests_Functions_wpListBookmarks test datasets.

`wp_list_bookmarks()` arguments include `'link_rel'`, but not `'rel'`. This commit fixes this argument in the test datasets. It also adds an expected `'rel=""'` result check, i.e. instead of only checking for `'noopener'`.

Follow-up to [52395].

Props davidbinda.
Fixes #53839.

git-svn-id: https://develop.svn.wordpress.org/trunk@52396 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Tonya Mork 2021-12-21 00:10:26 +00:00
parent b3b302df31
commit 3ce5c4c5a8

View File

@ -15,11 +15,12 @@ class Tests_Functions_wpListBookmarks extends WP_UnitTestCase {
*
* @ticket 53839
*
* @param array $args The arguments to create the bookmark.
* @param array $args The arguments to create the bookmark.
* @param string $expected Expected string to test.
*/
public function test_wp_list_bookmarks_adds_noopener( $args ) {
$bookmark = self::factory()->bookmark->create( $args );
$this->assertStringContainsString( 'noopener', wp_list_bookmarks( 'echo=0' ) );
public function test_wp_list_bookmarks_adds_noopener( $args, $expected ) {
self::factory()->bookmark->create( $args );
$this->assertStringContainsString( $expected, wp_list_bookmarks( 'echo=0' ) );
}
/**
@ -30,34 +31,38 @@ class Tests_Functions_wpListBookmarks extends WP_UnitTestCase {
public function data_wp_list_bookmarks_adds_noopener() {
return array(
'target as "_blank"' => array(
'args' => array(
'args' => array(
'link_name' => 'With _blank',
'link_url' => 'https://www.wordpress.org',
'link_target' => '_blank',
),
'expected' => 'rel="noopener"',
),
'target as "_blank" and a link relationship' => array(
'args' => array(
'args' => array(
'link_name' => 'With _blank and a link relationship',
'link_url' => 'https://www.wordpress.org',
'link_target' => '_blank',
'rel' => 'me',
'link_rel' => 'me',
),
'expected' => 'rel="me noopener"',
),
'target as "_top"' => array(
'args' => array(
'args' => array(
'link_name' => 'With _top',
'link_url' => 'https://www.wordpress.org',
'link_target' => '_top',
),
'expected' => 'rel="noopener"',
),
'target as "_top" and a link relationship' => array(
'args' => array(
'args' => array(
'link_name' => 'With _top and a link relationship',
'link_url' => 'https://www.wordpress.org',
'link_target' => '_top',
'rel' => 'me',
'link_rel' => 'me',
),
'expected' => 'rel="me noopener"',
),
);
}
@ -72,7 +77,7 @@ class Tests_Functions_wpListBookmarks extends WP_UnitTestCase {
* @param array $args The arguments to create the bookmark.
*/
public function test_wp_list_bookmarks_does_not_add_noopener( $args ) {
$bookmark = self::factory()->bookmark->create( $args );
self::factory()->bookmark->create( $args );
$this->assertStringNotContainsString( 'noopener', wp_list_bookmarks( 'echo=0' ) );
}
@ -95,7 +100,7 @@ class Tests_Functions_wpListBookmarks extends WP_UnitTestCase {
'link_name' => 'With _blank and a link relationship',
'link_url' => 'https://www.wordpress.org',
'link_target' => '_none',
'rel' => 'me',
'link_rel' => 'me',
),
),
);