test only listed caps
This commit is contained in:
parent
b2b7d7dcef
commit
5dd7254798
|
@ -24,6 +24,8 @@ class DefaultCapabilities extends TAINACAN_UnitTestCase {
|
||||||
|
|
||||||
$defaults_caps = $Tainacan_Capabilities->defaults;
|
$defaults_caps = $Tainacan_Capabilities->defaults;
|
||||||
|
|
||||||
|
$tainacan_roles = $Tainacan_Capabilities->get_tainacan_roles();
|
||||||
|
|
||||||
foreach ($defaults_caps as $post_type => $wp_append_roles) {
|
foreach ($defaults_caps as $post_type => $wp_append_roles) {
|
||||||
if($post_type == 'tainacan-items') continue;
|
if($post_type == 'tainacan-items') continue;
|
||||||
$entity = Repository::get_entity_by_post_type($post_type);
|
$entity = Repository::get_entity_by_post_type($post_type);
|
||||||
|
@ -42,9 +44,11 @@ class DefaultCapabilities extends TAINACAN_UnitTestCase {
|
||||||
$new_user = $this->factory()->user->create(array( 'role' => 'tainacan-' . $role_name ));
|
$new_user = $this->factory()->user->create(array( 'role' => 'tainacan-' . $role_name ));
|
||||||
wp_set_current_user($new_user);
|
wp_set_current_user($new_user);
|
||||||
|
|
||||||
|
if(in_array($role_name, $tainacan_roles) ) {
|
||||||
foreach ($caps as $cap) {
|
foreach ($caps as $cap) {
|
||||||
$this->assertTrue(current_user_can($entity_cap->$cap), "tainacan-$role_name does not have capability {$entity_cap->$cap}");
|
$this->assertTrue(current_user_can($entity_cap->$cap), "tainacan-$role_name does not have capability {$entity_cap->$cap}");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue