@@ 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 |
@@ 891-910 (lines=20) @@ | ||
888 | * |
|
889 | * @return WP_REST_Response |
|
890 | */ |
|
891 | public function mock_xmlrpc_success( $preempt, $args, $url ) { |
|
892 | if ( strpos( $url, 'https://jetpack.wordpress.com/xmlrpc.php' ) !== false ) { |
|
893 | $response = array(); |
|
894 | ||
895 | $response['body'] = ' |
|
896 | <methodResponse> |
|
897 | <params> |
|
898 | <param> |
|
899 | <value>1</value> |
|
900 | </param> |
|
901 | </params> |
|
902 | </methodResponse> |
|
903 | '; |
|
904 | ||
905 | $response['response']['code'] = 200; |
|
906 | return $response; |
|
907 | } |
|
908 | ||
909 | return $preempt; |
|
910 | } |
|
911 | ||
912 | /** |
|
913 | * Used to simulate a failed response to any XML-RPC request. |
|
@@ 922-933 (lines=12) @@ | ||
919 | * |
|
920 | * @return WP_REST_Response |
|
921 | */ |
|
922 | public function mock_xmlrpc_failure( $preempt, $args, $url ) { |
|
923 | if ( strpos( $url, 'https://jetpack.wordpress.com/xmlrpc.php' ) !== false ) { |
|
924 | $response = array(); |
|
925 | ||
926 | $response['body'] = ''; |
|
927 | ||
928 | $response['response']['code'] = 500; |
|
929 | return $response; |
|
930 | } |
|
931 | ||
932 | return $preempt; |
|
933 | } |
|
934 | ||
935 | /** |
|
936 | * Intercept the `Jetpack_Options` call and mock the values. |