|
@@ 706-714 (lines=9) @@
|
| 703 |
|
|
| 704 |
|
$caps = $this->getAllCapsAndRoles(); |
| 705 |
|
|
| 706 |
|
foreach ( $caps as $cap => $roles ) { |
| 707 |
|
if (array_intersect($user->roles, $roles) ) { |
| 708 |
|
$this->assertTrue($user->has_cap($cap), "User should have the {$cap} capability"); |
| 709 |
|
$this->assertTrue(user_can($user, $cap), "User should have the {$cap} capability"); |
| 710 |
|
} else { |
| 711 |
|
$this->assertFalse($user->has_cap($cap), "User should not have the {$cap} capability"); |
| 712 |
|
$this->assertFalse(user_can($user, $cap), "User should not have the {$cap} capability"); |
| 713 |
|
} |
| 714 |
|
} |
| 715 |
|
|
| 716 |
|
$user->remove_role('contributor'); |
| 717 |
|
// user should have one role now |
|
@@ 781-790 (lines=10) @@
|
| 778 |
|
|
| 779 |
|
$caps = $this->getPrimitiveCapsAndRoles(); |
| 780 |
|
|
| 781 |
|
foreach ( $caps as $cap => $roles ) { |
| 782 |
|
// the user should have all the above caps |
| 783 |
|
if (isset($expected_caps[ $cap ]) ) { |
| 784 |
|
$this->assertTrue($user->has_cap($cap), "User should have the {$cap} capability"); |
| 785 |
|
$this->assertTrue(user_can($user, $cap), "User should have the {$cap} capability"); |
| 786 |
|
} else { |
| 787 |
|
$this->assertFalse($user->has_cap($cap), "User should not have the {$cap} capability"); |
| 788 |
|
$this->assertFalse(user_can($user, $cap), "User should not have the {$cap} capability"); |
| 789 |
|
} |
| 790 |
|
} |
| 791 |
|
|
| 792 |
|
// clean up |
| 793 |
|
remove_role($role_name); |