forked from wp-cli/wp-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmock-requests-transport.php
More file actions
34 lines (27 loc) · 951 Bytes
/
mock-requests-transport.php
File metadata and controls
34 lines (27 loc) · 951 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
use WpOrg\Requests\Transport;
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound
class Mock_Requests_Transport implements Transport {
public $requests = [];
public function request( $url, $headers = [], $data = [], $options = [] ) {
// Simulate retrying.
if (
isset( $options['insecure'] )
&& $options['insecure']
&& isset( $options['verify'] )
&& false !== strpos( $options['verify'], sys_get_temp_dir() )
) {
$options['verify'] = false;
}
$this->requests[] = compact( 'url', 'headers', 'data', 'options' );
return 'HTTP/1.1 418' . "\r\n"
. 'Content-Type: water/leaf-infused' . "\r\n"
. "\r\n\r\n"; // This last line is actually important or the request will error.
}
public function request_multiple( $requests, $options ) {
throw new Exception( 'Method not implemented: ' . __METHOD__ );
}
public static function test( $capabilities = [] ) {
return true;
}
}