| @@ 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. | |
| @@ 628-647 (lines=20) @@ | ||
| 625 | * | |
| 626 | * @return array | |
| 627 | */ | |
| 628 | 	public function intercept_disconnect_success( $response, $args, $url ) { | |
| 629 | 		if ( strpos( $url, 'https://jetpack.wordpress.com/xmlrpc.php' ) !== false ) { | |
| 630 | $response = array(); | |
| 631 | ||
| 632 | $response['body'] = ' | |
| 633 | <methodResponse> | |
| 634 | <params> | |
| 635 | <param> | |
| 636 | <value>1</value> | |
| 637 | </param> | |
| 638 | </params> | |
| 639 | </methodResponse> | |
| 640 | '; | |
| 641 | ||
| 642 | $response['response']['code'] = 200; | |
| 643 | return $response; | |
| 644 | } | |
| 645 | ||
| 646 | return $response; | |
| 647 | } | |
| 648 | ||
| 649 | /** | |
| 650 | * Intercept the disconnect user API request sent to WP.com, and mock failure response. | |
| @@ 658-677 (lines=20) @@ | ||
| 655 | * | |
| 656 | * @return array | |
| 657 | */ | |
| 658 | 	public function intercept_disconnect_failure( $response, $args, $url ) { | |
| 659 | 		if ( strpos( $url, 'https://jetpack.wordpress.com/xmlrpc.php' ) !== false ) { | |
| 660 | $response = array(); | |
| 661 | ||
| 662 | $response['body'] = ' | |
| 663 | <methodResponse> | |
| 664 | <params> | |
| 665 | <param> | |
| 666 | <value>1</value> | |
| 667 | </param> | |
| 668 | </params> | |
| 669 | </methodResponse> | |
| 670 | '; | |
| 671 | ||
| 672 | $response['response']['code'] = 500; | |
| 673 | return $response; | |
| 674 | } | |
| 675 | ||
| 676 | return $response; | |
| 677 | } | |
| 678 | ||
| 679 | /** | |
| 680 | * Data for test_disconnect_user | |