| 401 | /** |
| 402 | * @ticket 36376 |
| 403 | */ |
| 404 | function test_multiple_roles() { |
| 405 | // Create a new customer role |
| 406 | $role_name = 'customer'; |
| 407 | $expected_caps = array( |
| 408 | 'read' => true, |
| 409 | ); |
| 410 | add_role( $role_name, 'Customer', $expected_caps ); |
| 411 | $this->_flush_roles(); |
| 412 | |
| 413 | // create a new user and add the editor and customer roles to it |
| 414 | $user = self::factory()->user->create_and_get( array( 'role' => 'author' ) ); |
| 415 | $user->add_role( 'customer' ); |
| 416 | |
| 417 | wp_set_current_user( $user->ID ); |
| 418 | |
| 419 | $this->assertEquals( array( 'author', 'customer' ), $user->roles ); |
| 420 | $this->assertTrue( $user->has_cap( 'edit_posts' ) ); |
| 421 | $this->assertTrue( current_user_can( 'edit_posts' ) ); |
| 422 | } |
| 423 | |