Skip to content

Commit 3c3f459

Browse files
committed
explained each assertion
1 parent 39fb17b commit 3c3f459

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

tests/phpunit/tests/user.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2175,19 +2175,26 @@ private function is_sequential( array $arr ) {
21752175
*/
21762176
public function test_user_roles_property_is_sequential_array() {
21772177
$user = new WP_User( self::$author_id );
2178+
// Initial roles array should be sequential.
21782179
$this->assertTrue( $this->is_sequential( $user->roles ) );
21792180

21802181
$user->remove_role( 'author' );
2182+
// After removing all roles, $user->roles should still be an array.
21812183
$this->assertIsArray( $user->roles );
2184+
// After removing all roles, $user->roles should be an empty array.
21822185
$this->assertSame( array(), $user->roles );
21832186

21842187
$user->add_role( 'author' );
2188+
// After adding "author" role, $user->roles should contain only that role.
21852189
$this->assertSame( array( 'author' ), $user->roles );
2190+
// After adding "author" role, $user->roles should remain sequential.
21862191
$this->assertTrue( $this->is_sequential( $user->roles ) );
21872192

21882193
$user->add_role( 'custom_role' );
21892194
$user->add_role( 'subscriber' );
2190-
$this->assertSame( array( 'author', 'subscriber' ), $user->roles );
2195+
// After adding multiple roles, $user->roles should contain valid roles only.
2196+
$this->assertSame( array( 'author', 'custom_role', 'subscriber' ), $user->roles );
2197+
// After adding multiple roles, $user->roles should still be sequential.
21912198
$this->assertTrue( $this->is_sequential( $user->roles ) );
21922199
}
21932200

0 commit comments

Comments
 (0)