|
@@ 21-36 (lines=16) @@
|
| 18 |
|
\Mockery::close(); |
| 19 |
|
} |
| 20 |
|
|
| 21 |
|
public function test_get_capability() { |
| 22 |
|
|
| 23 |
|
$capability = $this->builder |
| 24 |
|
->create_capability( 'jetpack.backup.restore' ) |
| 25 |
|
->require_wp_role( 'administrator' ) |
| 26 |
|
->require_wp_capability( 'administrator' ) |
| 27 |
|
->get_capability(); |
| 28 |
|
|
| 29 |
|
// no admin privilege |
| 30 |
|
$this->assertFalse( $capability->check()->granted() ); |
| 31 |
|
|
| 32 |
|
$this->setUserRole( 'administrator' ); |
| 33 |
|
|
| 34 |
|
// has admin privilege |
| 35 |
|
$this->assertTrue( $capability->check()->granted() ); |
| 36 |
|
} |
| 37 |
|
|
| 38 |
|
public function test_capability_has_details() { |
| 39 |
|
$capability = $this->builder |
|
@@ 49-64 (lines=16) @@
|
| 46 |
|
$this->assertFalse( $capability->check()->granted() ); |
| 47 |
|
} |
| 48 |
|
|
| 49 |
|
public function test_jetpack_plan_rule() { |
| 50 |
|
$capability = $this->builder |
| 51 |
|
->create_capability( 'jetpack.backup.restore' ) |
| 52 |
|
->require_minimum_jetpack_plan( 'a_nice_plan' ) |
| 53 |
|
->get_capability(); |
| 54 |
|
|
| 55 |
|
// expected plan |
| 56 |
|
$this->mockJetpackPlan( 'a_nice_plan' ); |
| 57 |
|
|
| 58 |
|
$this->assertTrue( $capability->check()->granted() ); |
| 59 |
|
|
| 60 |
|
// unexpected plan |
| 61 |
|
$this->mockJetpackPlan( 'some_other_plan' ); |
| 62 |
|
|
| 63 |
|
$this->assertFalse( $capability->check()->granted() ); |
| 64 |
|
} |
| 65 |
|
|
| 66 |
|
/** |
| 67 |
|
* Utility functions |