move roles test from collections to a new file
This commit is contained in:
parent
c89a5743a5
commit
5bbe4ebe7e
|
@ -21,8 +21,7 @@ class Collections extends TAINACAN_UnitTestCase {
|
|||
wp_set_current_user($new_user);
|
||||
$user_id = get_current_user_id();
|
||||
$this->assertEquals($new_user, $user_id);
|
||||
$this->assertTrue(user_can($user_id, 'read_'.\Tainacan\Entities\Collection::get_post_type()), 'User cannot read Collections');
|
||||
$this->assertFalse(user_can($user_id, 'edit_'.\Tainacan\Entities\Collection::get_post_type()), 'A subscriber User can edit a Collections?');
|
||||
//TODO test collection insert, update, save, fetch permissions
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace Tainacan\Tests;
|
||||
|
||||
/**
|
||||
* Class TestCollections
|
||||
*
|
||||
* @package Test_Tainacan
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group permissions
|
||||
*/
|
||||
class Permissions extends TAINACAN_UnitTestCase {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function test_roles () {
|
||||
$new_user = $this->factory()->user->create(array( 'role' => 'subscriber' ));
|
||||
wp_set_current_user($new_user);
|
||||
$user_id = get_current_user_id();
|
||||
$this->assertEquals($new_user, $user_id);
|
||||
$this->assertTrue(user_can($user_id, 'read_'.\Tainacan\Entities\Collection::get_post_type()), 'User cannot read Collections');
|
||||
$this->assertTrue(user_can($user_id, 'subscriber'));
|
||||
$this->assertFalse(user_can($user_id, 'edit_'.\Tainacan\Entities\Collection::get_post_type()), 'A subscriber user can edit a Collections?');
|
||||
|
||||
$new_admin_user = $this->factory()->user->create(array( 'role' => 'administrator' ));
|
||||
wp_set_current_user($new_admin_user);
|
||||
$user_id = get_current_user_id();
|
||||
$this->assertTrue(user_can($user_id, 'administrator'));
|
||||
$this->assertTrue(user_can($user_id, 'edit_'.\Tainacan\Entities\Collection::get_post_type()), 'A administrator user cannot edit a Collections?');
|
||||
//TODO test all roles and check the capabilities
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue