Instead of failing when createGuzzleClient() is called, return a mock which fails when a request is actually dispatched, following the suggestion of the comment. Otherwise PHPUnit fails to start up when RemoteIcuCollation and Shellbox are configured. Change-Id: Iac8d1e73512e7073264e79bbef8e4fa02fedefe2
34 lines
1.1 KiB
PHP
34 lines
1.1 KiB
PHP
<?php
|
|
|
|
use GuzzleHttp\Promise\PromiseInterface;
|
|
use PHPUnit\Framework\Assert;
|
|
use Psr\Http\Message\RequestInterface;
|
|
use Psr\Http\Message\ResponseInterface;
|
|
|
|
class NullGuzzleClient extends \GuzzleHttp\Client {
|
|
public function __construct( $config ) {
|
|
}
|
|
|
|
public function send( RequestInterface $request, array $options = [] ): ResponseInterface {
|
|
$url = $request->getUri();
|
|
Assert::fail( "HTTP request blocked: $url. Use MockHttpTrait." );
|
|
}
|
|
|
|
public function sendAsync( RequestInterface $request, array $options = [] ): PromiseInterface {
|
|
$url = $request->getUri();
|
|
Assert::fail( "HTTP request blocked: $url. Use MockHttpTrait." );
|
|
}
|
|
|
|
public function sendRequest( RequestInterface $request ): ResponseInterface {
|
|
$url = $request->getUri();
|
|
Assert::fail( "HTTP request blocked: $url. Use MockHttpTrait." );
|
|
}
|
|
|
|
public function request( string $method, $uri = '', array $options = [] ): ResponseInterface {
|
|
Assert::fail( "HTTP request blocked: $uri. Use MockHttpTrait." );
|
|
}
|
|
|
|
public function requestAsync( string $method, $uri = '', array $options = [] ): PromiseInterface {
|
|
Assert::fail( "HTTP request blocked: $uri. Use MockHttpTrait." );
|
|
}
|
|
}
|