Changeset 61210 for trunk/tests/phpunit/tests/user.php
- Timestamp:
- 11/11/2025 12:51:01 PM (11 months ago)
- File:
-
- 1 edited
-
trunk/tests/phpunit/tests/user.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/user.php
r60941 r61210 2159 2159 2160 2160 /** 2161 * Tests that the `WP_User::$roles` property is a sequential array. 2162 * 2163 * @ticket 63427 2164 * 2165 * @covers WP_User::get_role_caps 2166 */ 2167 public function test_wp_user_roles_property_is_sequential_array() { 2168 $user = new WP_User( self::$author_id ); 2169 $this->assertTrue( $this->is_sequential( $user->roles ), 'Initial roles array should be sequential.' ); 2170 2171 $user->remove_role( 'author' ); 2172 $this->assertIsArray( $user->roles, 'After removing all roles, $user->roles should still be an array.' ); 2173 $this->assertSame( array(), $user->roles, 'After removing all roles, $user->roles should be an empty array.' ); 2174 2175 $user->add_role( 'author' ); 2176 $user->add_role( 'subscriber' ); 2177 $this->assertSame( array( 'author', 'subscriber' ), $user->roles, 'After adding multiple roles, $user->roles should contain added roles.' ); 2178 $this->assertTrue( $this->is_sequential( $user->roles ), 'After adding multiple roles, $user->roles should still be sequential.' ); 2179 } 2180 2181 /** 2182 * Determines whether an array has sequential numeric keys. 2183 * 2184 * @param array $arr The array to check. 2185 * @return bool True if the array has sequential numeric keys, false otherwise. 2186 */ 2187 private function is_sequential( array $arr ) { 2188 return array_keys( $arr ) === range( 0, count( $arr ) - 1 ); 2189 } 2190 2191 /** 2161 2192 * @ticket 42564 2162 2193 */
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)