|
@@ 213-227 (lines=15) @@
|
| 210 |
|
/** |
| 211 |
|
* Testing the `/jetpack/v4/database-object/backup` endpoint with admin user. |
| 212 |
|
*/ |
| 213 |
|
public function test_backup_database_object_unauthorized() { |
| 214 |
|
wp_set_current_user( $this->admin_id ); |
| 215 |
|
|
| 216 |
|
$request = new WP_REST_Request( 'GET', '/jetpack/v4/database-object/backup' ); |
| 217 |
|
$request->set_query_params( |
| 218 |
|
array( |
| 219 |
|
'object_id' => 123, |
| 220 |
|
'object_type' => 'woocommerce_attribute', |
| 221 |
|
) |
| 222 |
|
); |
| 223 |
|
$response = $this->server->dispatch( $request ); |
| 224 |
|
|
| 225 |
|
$this->assertEquals( 403, $response->get_status() ); |
| 226 |
|
$this->assertEquals( 'You are not allowed to perform this action.', $response->get_data()['message'] ); |
| 227 |
|
} |
| 228 |
|
|
| 229 |
|
/** |
| 230 |
|
* Testing the `/jetpack/v4/database-object/backup` endpoint on success. |
|
@@ 232-247 (lines=16) @@
|
| 229 |
|
/** |
| 230 |
|
* Testing the `/jetpack/v4/database-object/backup` endpoint on success. |
| 231 |
|
*/ |
| 232 |
|
public function test_backup_database_object_success() { |
| 233 |
|
$request = new WP_REST_Request( 'GET', '/jetpack/v4/database-object/backup' ); |
| 234 |
|
$request->set_query_params( |
| 235 |
|
array( |
| 236 |
|
'object_id' => 123, |
| 237 |
|
'object_type' => 'woocommerce_attribute', |
| 238 |
|
) |
| 239 |
|
); |
| 240 |
|
$response = $this->server->dispatch( $request ); |
| 241 |
|
|
| 242 |
|
$response = $this->dispatch_request_signed_with_blog_token( $request ); |
| 243 |
|
|
| 244 |
|
$this->assertEquals( 404, $response->get_status() ); // success in this context. |
| 245 |
|
|
| 246 |
|
$this->assertEquals( 'Object not found', $response->get_data()['message'] ); |
| 247 |
|
} |
| 248 |
|
|
| 249 |
|
/** |
| 250 |
|
* Testing the `/jetpack/v4/options/backup` endpoint with invalid params. |
|
@@ 263-276 (lines=14) @@
|
| 260 |
|
/** |
| 261 |
|
* Testing the `/jetpack/v4/options/backup` endpoint with admin user. |
| 262 |
|
*/ |
| 263 |
|
public function test_backup_options_unauthorized() { |
| 264 |
|
wp_set_current_user( $this->admin_id ); |
| 265 |
|
|
| 266 |
|
$request = new WP_REST_Request( 'GET', '/jetpack/v4/options/backup' ); |
| 267 |
|
$request->set_query_params( |
| 268 |
|
array( |
| 269 |
|
'name' => 'home', |
| 270 |
|
) |
| 271 |
|
); |
| 272 |
|
$response = $this->server->dispatch( $request ); |
| 273 |
|
|
| 274 |
|
$this->assertEquals( 403, $response->get_status() ); |
| 275 |
|
$this->assertEquals( 'You are not allowed to perform this action.', $response->get_data()['message'] ); |
| 276 |
|
} |
| 277 |
|
|
| 278 |
|
/** |
| 279 |
|
* Testing the `/jetpack/v4/options/backup` endpoint on success. |