From 3ce5c4c5a87772bd900fdd7cbbc59beaa999a9a5 Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Tue, 21 Dec 2021 00:10:26 +0000 Subject: [PATCH] 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 --- .../tests/bookmark/wpListBookmarks.php | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/tests/phpunit/tests/bookmark/wpListBookmarks.php b/tests/phpunit/tests/bookmark/wpListBookmarks.php index 02305e9565..ba0121fd00 100644 --- a/tests/phpunit/tests/bookmark/wpListBookmarks.php +++ b/tests/phpunit/tests/bookmark/wpListBookmarks.php @@ -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', ), ), );