| @@ 641-660 (lines=20) @@ | ||
| 638 | * |
|
| 639 | * @return array |
|
| 640 | */ |
|
| 641 | public function intercept_disconnect_success( $response, $args, $url ) { |
|
| 642 | if ( strpos( $url, 'https://jetpack.wordpress.com/xmlrpc.php' ) !== false ) { |
|
| 643 | $response = array(); |
|
| 644 | ||
| 645 | $response['body'] = ' |
|
| 646 | <methodResponse> |
|
| 647 | <params> |
|
| 648 | <param> |
|
| 649 | <value>1</value> |
|
| 650 | </param> |
|
| 651 | </params> |
|
| 652 | </methodResponse> |
|
| 653 | '; |
|
| 654 | ||
| 655 | $response['response']['code'] = 200; |
|
| 656 | return $response; |
|
| 657 | } |
|
| 658 | ||
| 659 | return $response; |
|
| 660 | } |
|
| 661 | ||
| 662 | /** |
|
| 663 | * Intercept the disconnect user API request sent to WP.com, and mock success response. |
|
| @@ 671-690 (lines=20) @@ | ||
| 668 | * |
|
| 669 | * @return array |
|
| 670 | */ |
|
| 671 | public function intercept_disconnect_failure( $response, $args, $url ) { |
|
| 672 | if ( strpos( $url, 'https://jetpack.wordpress.com/xmlrpc.php' ) !== false ) { |
|
| 673 | $response = array(); |
|
| 674 | ||
| 675 | $response['body'] = ' |
|
| 676 | <methodResponse> |
|
| 677 | <params> |
|
| 678 | <param> |
|
| 679 | <value>1</value> |
|
| 680 | </param> |
|
| 681 | </params> |
|
| 682 | </methodResponse> |
|
| 683 | '; |
|
| 684 | ||
| 685 | $response['response']['code'] = 500; |
|
| 686 | return $response; |
|
| 687 | } |
|
| 688 | ||
| 689 | return $response; |
|
| 690 | } |
|
| 691 | ||
| 692 | /** |
|
| 693 | * Data for test_disconnect_user |
|
| @@ 125-144 (lines=20) @@ | ||
| 122 | * |
|
| 123 | * @return WP_REST_Response |
|
| 124 | */ |
|
| 125 | public function mock_xmlrpc_success( $preempt, $args, $url ) { |
|
| 126 | if ( strpos( $url, 'https://jetpack.wordpress.com/xmlrpc.php' ) !== false ) { |
|
| 127 | $response = array(); |
|
| 128 | ||
| 129 | $response['body'] = ' |
|
| 130 | <methodResponse> |
|
| 131 | <params> |
|
| 132 | <param> |
|
| 133 | <value>1</value> |
|
| 134 | </param> |
|
| 135 | </params> |
|
| 136 | </methodResponse> |
|
| 137 | '; |
|
| 138 | ||
| 139 | $response['response']['code'] = 200; |
|
| 140 | return $response; |
|
| 141 | } |
|
| 142 | ||
| 143 | return $preempt; |
|
| 144 | } |
|
| 145 | ||
| 146 | /** |
|
| 147 | * Check response status code. |
|