diff options
author | Sergey Biryukov <sergeybiryukov@git.wordpress.org> | 2020-09-23 00:25:47 +0000 |
---|---|---|
committer | Sergey Biryukov <sergeybiryukov@git.wordpress.org> | 2020-09-23 00:25:47 +0000 |
commit | 7d15225ad0f722e1ce42f4030a48ecd41636eea4 (patch) | |
tree | 07cc8be544927b67d01c5df87e0382f296b1c2aa /tests/phpunit | |
parent | 83eb948b7f27407bbb08f69eedeaf76591503558 (diff) | |
download | wordpress-7d15225ad0f722e1ce42f4030a48ecd41636eea4.tar.gz wordpress-7d15225ad0f722e1ce42f4030a48ecd41636eea4.zip |
Users: Check if the user ID passed as `selected` to `wp_dropdown_users()` corresponds to an existing user.
This avoids a few PHP notices if the `include_selected` parameter was specified and a non-existing user ID was passed.
Props campusboy1987.
Fixes #51370.
git-svn-id: https://develop.svn.wordpress.org/trunk@49036 602fd350-edb4-49c9-b593-d223f7449a82
Diffstat (limited to 'tests/phpunit')
-rw-r--r-- | tests/phpunit/tests/user/wpDropdownUsers.php | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/phpunit/tests/user/wpDropdownUsers.php b/tests/phpunit/tests/user/wpDropdownUsers.php index 4f6b89db77..91c35cf63a 100644 --- a/tests/phpunit/tests/user/wpDropdownUsers.php +++ b/tests/phpunit/tests/user/wpDropdownUsers.php @@ -130,6 +130,22 @@ class Tests_User_WpDropdownUsers extends WP_UnitTestCase { } /** + * @ticket 51370 + */ + public function test_include_selected_with_non_existing_user_id() { + $found = wp_dropdown_users( + array( + 'echo' => false, + 'selected' => PHP_INT_MAX, + 'include_selected' => true, + 'show' => 'user_login', + ) + ); + + $this->assertNotContains( (string) PHP_INT_MAX, $found ); + } + + /** * @ticket 38135 */ public function test_role() { |