better caps test and test moderators_ids is stored
This commit is contained in:
parent
e8462872e1
commit
44aebc95ea
|
@ -17,7 +17,7 @@ class Collections extends TAINACAN_UnitTestCase {
|
|||
* @group permissions
|
||||
*/
|
||||
function test_permissions () {
|
||||
$x = $this->tainacan_entity_factory->create_entity(
|
||||
$collection_test = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
array(
|
||||
'name' => 'testeCaps',
|
||||
|
@ -31,14 +31,12 @@ class Collections extends TAINACAN_UnitTestCase {
|
|||
$user_id = get_current_user_id();
|
||||
$this->assertEquals($new_user, $user_id);
|
||||
|
||||
//global $Tainacan_Collections;
|
||||
//$this->assertTrue($Tainacan_Collections->can_read($x));
|
||||
$this->assertFalse(current_user_can('edit_collection'));
|
||||
|
||||
$autor1 = $this->factory()->user->create(array( 'role' => 'author' ));
|
||||
wp_set_current_user($autor1);
|
||||
$autor1_id = get_current_user_id();
|
||||
$x = $this->tainacan_entity_factory->create_entity(
|
||||
$collection_test = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
array(
|
||||
'name' => 'testeCapsOwner',
|
||||
|
@ -47,10 +45,10 @@ class Collections extends TAINACAN_UnitTestCase {
|
|||
),
|
||||
true
|
||||
);
|
||||
$this->assertEquals($autor1_id, $x->WP_Post->post_author);
|
||||
$this->assertEquals($autor1_id, $collection_test->WP_Post->post_author);
|
||||
$autor2 = $this->factory()->user->create(array( 'role' => 'author' ));
|
||||
wp_set_current_user($autor2);
|
||||
$x2 = $this->tainacan_entity_factory->create_entity(
|
||||
$collection_test2 = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
array(
|
||||
'name' => 'testeCapsOwner2',
|
||||
|
@ -61,9 +59,22 @@ class Collections extends TAINACAN_UnitTestCase {
|
|||
);
|
||||
$current_user_id = get_current_user_id();
|
||||
$this->assertEquals($autor2, $current_user_id);
|
||||
$this->assertFalse(current_user_can($x->cap->edit_post, $x->WP_Post->ID));
|
||||
$this->assertTrue(current_user_can($x2->cap->edit_post, $x2->WP_Post->ID));
|
||||
$this->assertFalse(user_can($autor2, $x->cap->edit_post, $x->WP_Post->ID));
|
||||
$this->assertFalse(current_user_can($collection_test->cap->edit_post, $collection_test->WP_Post->ID));
|
||||
$this->assertTrue(current_user_can($collection_test2->cap->edit_post, $collection_test2->WP_Post->ID));
|
||||
$this->assertFalse(user_can($autor2, $collection_test->cap->edit_post, $collection_test->WP_Post->ID));
|
||||
|
||||
wp_set_current_user($this->user_id);
|
||||
$collection_test_moderator = $this->tainacan_entity_factory->create_entity(
|
||||
'collection',
|
||||
array(
|
||||
'name' => 'testeModerator',
|
||||
'description' => 'adasdasdsa',
|
||||
'default_order' => 'DESC',
|
||||
'moderators_ids' => [$autor2]
|
||||
),
|
||||
true
|
||||
);
|
||||
$this->assertEquals([$autor2], $collection_test_moderator->get_moderators_ids());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue