Page MenuHomeWickedGov Phorge

NullMultiHttpClient.php
No OneTemporary

Size
781 B
Referenced Files
None
Subscribers
None

NullMultiHttpClient.php

<?php
use PHPUnit\Framework\Assert;
use PHPUnit\Framework\AssertionFailedError;
use Wikimedia\Http\MultiHttpClient;
/**
* A simple {@link MultiHttpClient} implementation that can be used to prevent
* HTTP requests in tests. All attempts to execute a request will fail.
*
* Use MockHttpTrait for controlling responses to mock HTTP requests.
*
* @author Daniel Kinzler
* @license GPL-2.0-or-later
*/
class NullMultiHttpClient extends MultiHttpClient {
/**
* Always fails.
*
* @param array $reqs
* @param array $opts
*
* @throws AssertionFailedError always
*/
public function runMulti( array $reqs, array $opts = [] ) {
$urls = implode( ', ', array_column( $reqs, 'url' ) );
Assert::fail( "HTTP requests to {$urls} blocked. Use MockHttpTrait." );
}
}

File Metadata

Mime Type
text/x-php
Expires
Wed, Aug 19, 12:18 (3 w, 2 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
eb/79/a130cb521edb3e0ac7bc7946ae72
Default Alt Text
NullMultiHttpClient.php (781 B)

Event Timeline