Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -105,15 +105,8 @@

<!-- These are stand-alone files that are copied into the test run directory and
executed by the child WP-CLI process, not loaded as part of this package.
They declare a class once per supported Requests major version, and their
method signatures are dictated by the transport interface they implement,
Their method signatures are dictated by the transport interface they implement,
so unused parameters cannot be dropped. -->
<rule ref="Generic.Files.OneObjectStructurePerFile">
<exclude-pattern>*/src/Context/templates/*</exclude-pattern>
</rule>
<rule ref="Generic.Classes.DuplicateClassName">
<exclude-pattern>*/src/Context/templates/*</exclude-pattern>
</rule>
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter">
<exclude-pattern>*/src/Context/templates/*</exclude-pattern>
</rule>
Expand Down
25 changes: 14 additions & 11 deletions src/Context/templates/mock-requests.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,23 @@ public static function test( $capabilities = array() ) {
}
}

if ( interface_exists( '\WpOrg\Requests\Transport' ) ) {
class WP_CLI_Tests_Mock_Requests_Transport implements \WpOrg\Requests\Transport {
use WP_CLI_Tests_Mock_Requests_Trait;
}
} else {
class WP_CLI_Tests_Mock_Requests_Transport implements \Requests_Transport {
use WP_CLI_Tests_Mock_Requests_Trait;
}
}

WP_CLI::add_hook(
'http_request_options',
static function ( $options ) {
$options['transport'] = new WP_CLI_Tests_Mock_Requests_Transport();
if ( class_exists( '\WP_CLI\RequestsLibrary' ) && method_exists( '\WP_CLI\RequestsLibrary', 'register_autoloader' ) ) {
\WP_CLI\RequestsLibrary::register_autoloader();
}

if ( interface_exists( '\WpOrg\Requests\Transport' ) ) {
$options['transport'] = new class() implements \WpOrg\Requests\Transport {
use WP_CLI_Tests_Mock_Requests_Trait;
};
} else {
$options['transport'] = new class() implements \Requests_Transport {
use WP_CLI_Tests_Mock_Requests_Trait;
};
}

return $options;
}
);
Expand Down
Loading