wiki.techinc.nl/tests/phpunit/mocks/NullMultiHttpClient.php
Daniel Kinzler aea8cb17bd Re-apply: "PHPUnit: prevent HTTP requests"
This reverts commit c17ddfd786.

This time, also: Trying to get mock http to work in parser test

Bug: T262443
Change-Id: Id708cdfa3d3c27f30543c6bf212df96e6b0a69e1
2020-10-09 16:19:31 +02:00

29 lines
676 B
PHP

<?php
use PHPUnit\Framework\Assert;
use PHPUnit\Framework\AssertionFailedError;
/**
* 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 = [] ) {
Assert::fail( "HTTP request blocked. Use MockHttpTrait." );
}
}