forked from christianwach/bp-event-organiser
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Users: Add basic event caps for users with the 'subscriber' or 'contr…
…ibutor' role. Commit also includes unit tests. See #5.
- Loading branch information
Showing
2 changed files
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
/** | ||
* @group user | ||
* @group cap | ||
*/ | ||
class BPEO_Tests_User_BpeoEventMetaCap extends BPEO_UnitTestCase { | ||
protected $current_user; | ||
protected $user; | ||
|
||
public function setUp() { | ||
parent::setUp(); | ||
$this->current_user = bp_loggedin_user_id(); | ||
} | ||
|
||
public function tearDown() { | ||
$this->set_current_user( $this->current_user ); | ||
} | ||
|
||
public function test_non_loggedin_user_can_publish_events() { | ||
$this->set_current_user( 0 ); | ||
$this->assertFalse( current_user_can( 'publish_events' ) ); | ||
} | ||
|
||
public function test_loggedin_user_can_publish_events() { | ||
$this->user = $this->factory->user->create(); | ||
$this->set_current_user( $this->user ); | ||
|
||
$this->assertTrue( current_user_can( 'publish_events' ) ); | ||
} | ||
|
||
public function test_loggedin_user_can_edit_events() { | ||
$this->user = $this->factory->user->create(); | ||
$this->set_current_user( $this->user ); | ||
|
||
$this->assertTrue( current_user_can( 'edit_events' ) ); | ||
} | ||
|
||
public function test_loggedin_user_can_delete_events() { | ||
$this->user = $this->factory->user->create(); | ||
$this->set_current_user( $this->user ); | ||
|
||
$this->assertTrue( current_user_can( 'delete_events' ) ); | ||
} | ||
} |