|
@@ 153-168 (lines=16) @@
|
| 150 |
|
} |
| 151 |
|
} |
| 152 |
|
|
| 153 |
|
class Test_Jetpack_Capabilities_WP_Role extends Test_Jetpack_Capabilities_Base { |
| 154 |
|
public function test_check_role() { |
| 155 |
|
$capability = $this->builder |
| 156 |
|
->create( 'jetpack.backup.restore' ) |
| 157 |
|
->require_wp_role( 'administrator' ) |
| 158 |
|
->get(); |
| 159 |
|
|
| 160 |
|
// no admin privilege |
| 161 |
|
$this->assertFalse( $capability->check()->granted() ); |
| 162 |
|
|
| 163 |
|
$this->setUserRole( 'administrator' ); |
| 164 |
|
|
| 165 |
|
// has admin privilege |
| 166 |
|
$this->assertTrue( $capability->check()->granted() ); |
| 167 |
|
} |
| 168 |
|
} |
| 169 |
|
|
| 170 |
|
class Test_Jetpack_Capabilities_WP_Capability extends Test_Jetpack_Capabilities_Base { |
| 171 |
|
public function test_check_capability() { |
|
@@ 170-185 (lines=16) @@
|
| 167 |
|
} |
| 168 |
|
} |
| 169 |
|
|
| 170 |
|
class Test_Jetpack_Capabilities_WP_Capability extends Test_Jetpack_Capabilities_Base { |
| 171 |
|
public function test_check_capability() { |
| 172 |
|
$capability = $this->builder |
| 173 |
|
->create( 'jetpack.backup.restore' ) |
| 174 |
|
->require_wp_capability( 'do_a_thing' ) |
| 175 |
|
->get(); |
| 176 |
|
|
| 177 |
|
// no admin privilege |
| 178 |
|
$this->assertFalse( $capability->check()->granted() ); |
| 179 |
|
|
| 180 |
|
$this->addUserCapability( 'do_a_thing' ); |
| 181 |
|
|
| 182 |
|
// has admin privilege |
| 183 |
|
$this->assertTrue( $capability->check()->granted() ); |
| 184 |
|
} |
| 185 |
|
} |
| 186 |
|
|
| 187 |
|
class Test_Jetpack_Capabilities_WP_Filter extends Test_Jetpack_Capabilities_Base { |
| 188 |
|
public function test_check_filter() { |
|
@@ 187-202 (lines=16) @@
|
| 184 |
|
} |
| 185 |
|
} |
| 186 |
|
|
| 187 |
|
class Test_Jetpack_Capabilities_WP_Filter extends Test_Jetpack_Capabilities_Base { |
| 188 |
|
public function test_check_filter() { |
| 189 |
|
$capability = $this->builder |
| 190 |
|
->create( 'jetpack.backup.restore' ) |
| 191 |
|
->require_filter( 'my_filter', true ) |
| 192 |
|
->get(); |
| 193 |
|
|
| 194 |
|
// no admin privilege |
| 195 |
|
$this->assertFalse( $capability->check()->granted() ); |
| 196 |
|
|
| 197 |
|
add_filter( 'my_filter', '__return_true' ); |
| 198 |
|
|
| 199 |
|
// has admin privilege |
| 200 |
|
$this->assertTrue( $capability->check()->granted() ); |
| 201 |
|
} |
| 202 |
|
} |
| 203 |
|
|
| 204 |
|
class Test_Jetpack_Capabilities_JetpackActiveRule extends Test_Jetpack_Capabilities_Base { |
| 205 |
|
public function test_check_jetpack_is_active() { |