|
@@ 617-630 (lines=14) @@
|
| 614 |
|
/** |
| 615 |
|
* Test changing the connection owner with the required capability. |
| 616 |
|
*/ |
| 617 |
|
public function test_change_owner_with_permission() { |
| 618 |
|
$user = wp_get_current_user(); |
| 619 |
|
$user->add_cap( 'jetpack_disconnect' ); |
| 620 |
|
|
| 621 |
|
// Attempt owner change with bad user. |
| 622 |
|
$request = new WP_REST_Request( 'POST', '/jetpack/v4/connection/owner' ); |
| 623 |
|
$request->set_header( 'Content-Type', 'application/json' ); |
| 624 |
|
|
| 625 |
|
$response = $this->server->dispatch( $request ); |
| 626 |
|
$user->remove_cap( 'jetpack_disconnect' ); |
| 627 |
|
|
| 628 |
|
$this->assertEquals( 400, $response->get_status() ); |
| 629 |
|
$this->assertEquals( 'invalid_param', $response->get_data()['code'] ); |
| 630 |
|
} |
| 631 |
|
|
| 632 |
|
/** |
| 633 |
|
* Test changing the connection owner without the required capability. |
|
@@ 635-645 (lines=11) @@
|
| 632 |
|
/** |
| 633 |
|
* Test changing the connection owner without the required capability. |
| 634 |
|
*/ |
| 635 |
|
public function test_change_owner_without_permission() { |
| 636 |
|
$user = wp_get_current_user(); |
| 637 |
|
|
| 638 |
|
$request = new WP_REST_Request( 'POST', '/jetpack/v4/connection/owner' ); |
| 639 |
|
$request->set_header( 'Content-Type', 'application/json' ); |
| 640 |
|
$request->set_body( wp_json_encode( array( 'owner' => $user->ID ) ) ); |
| 641 |
|
|
| 642 |
|
$response = $this->server->dispatch( $request ); |
| 643 |
|
$this->assertEquals( 401, $response->get_status() ); |
| 644 |
|
$this->assertEquals( 'invalid_user_permission_set_connection_owner', $response->get_data()['code'] ); |
| 645 |
|
} |
| 646 |
|
} |
| 647 |
|
|