ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sabre\HTTP\ClientMock Class Reference
+ Inheritance diagram for Sabre\HTTP\ClientMock:
+ Collaboration diagram for Sabre\HTTP\ClientMock:

Public Member Functions

 createCurlSettingsArray (RequestInterface $request)
 Making this method public. More...
 
 parseCurlResult ($response, $curlHandle)
 Making this method public. More...
 
 doRequest (RequestInterface $request)
 This method is responsible for performing a single request. More...
 
- Public Member Functions inherited from Sabre\HTTP\Client
 __construct ()
 Initializes the client. More...
 
 send (RequestInterface $request)
 Sends a request to a HTTP server, and returns a response. More...
 
 sendAsync (RequestInterface $request, callable $success=null, callable $error=null)
 Sends a HTTP request asynchronously. More...
 
 poll ()
 This method checks if any http requests have gotten results, and if so, call the appropriate success or error handlers. More...
 
 wait ()
 Processes every HTTP request in the queue, and waits till they are all completed. More...
 
 setThrowExceptions ($throwExceptions)
 If this is set to true, the Client will automatically throw exceptions upon HTTP errors. More...
 
 addCurlSetting ($name, $value)
 Adds a CURL setting. More...
 
- Public Member Functions inherited from Sabre\Event\EventEmitterInterface
 on ($eventName, callable $callBack, $priority=100)
 Subscribe to an event. More...
 
 once ($eventName, callable $callBack, $priority=100)
 Subscribe to an event exactly once. More...
 
 emit ($eventName, array $arguments=[], callable $continueCallBack=null)
 Emits an event. More...
 
 listeners ($eventName)
 Returns the list of listeners for an event. More...
 
 removeListener ($eventName, callable $listener)
 Removes a specific listener from an event. More...
 
 removeAllListeners ($eventName=null)
 Removes all listeners. More...
 

Protected Member Functions

 curlStuff ($curlHandle)
 Returns a bunch of information about a curl request. More...
 
 curlExec ($curlHandle)
 Calls curl_exec. More...
 
- Protected Member Functions inherited from Sabre\HTTP\Client
 doRequest (RequestInterface $request)
 This method is responsible for performing a single request. More...
 
 createCurlSettingsArray (RequestInterface $request)
 Turns a RequestInterface object into an array with settings that can be fed to curl_setopt. More...
 
 parseCurlResult ($response, $curlHandle)
 Parses the result of a curl call in a format that's a bit more convenient to work with. More...
 
 sendAsyncInternal (RequestInterface $request, callable $success, callable $error, $retryCount=0)
 Sends an asynchronous HTTP request. More...
 
 curlExec ($curlHandle)
 Calls curl_exec. More...
 
 curlStuff ($curlHandle)
 Returns a bunch of information about a curl request. More...
 

Protected Attributes

 $persistedSettings = []
 
- Protected Attributes inherited from Sabre\HTTP\Client
 $curlSettings = []
 
 $throwExceptions = false
 
 $maxRedirects = 5
 

Additional Inherited Members

- Data Fields inherited from Sabre\HTTP\Client
const STATUS_SUCCESS = 0
 
const STATUS_CURLERROR = 1
 
const STATUS_HTTPERROR = 2
 

Detailed Description

Definition at line 379 of file ClientTest.php.

Member Function Documentation

◆ createCurlSettingsArray()

Sabre\HTTP\ClientMock::createCurlSettingsArray ( RequestInterface  $request)

Making this method public.

We are also going to persist all settings this method generates. While the underlying object doesn't behave exactly the same, it helps us simulate what curl does internally, and helps us identify problems with settings that are set by some methods and not correctly reset by other methods after subsequent use. forces

Reimplemented from Sabre\HTTP\Client.

Definition at line 393 of file ClientTest.php.

393 {
394
395 $settings = parent::createCurlSettingsArray($request);
396 $settings = $settings + $this->persistedSettings;
397 $this->persistedSettings = $settings;
398 return $settings;
399
400 }
foreach($paths as $path) $request
Definition: asyncclient.php:32

References Sabre\HTTP\ClientMock\$persistedSettings, and $request.

◆ curlExec()

Sabre\HTTP\ClientMock::curlExec (   $curlHandle)
protected

Calls curl_exec.

This method exists so it can easily be overridden and mocked.

Parameters
resource$curlHandle
Returns
string

Reimplemented from Sabre\HTTP\Client.

Definition at line 460 of file ClientTest.php.

460 {
461
462 $return = null;
463 $this->emit('curlExec', [&$return]);
464
465 // If nothing modified $return, we're using the default behavior.
466 if (is_null($return)) {
467 return parent::curlExec($curlHandle);
468 } else {
469 return $return;
470 }
471
472 }
emit($eventName, array $arguments=[], callable $continueCallBack=null)
Emits an event.

References Sabre\HTTP\Client\$curlHandle, and Sabre\Event\EventEmitterInterface\emit().

+ Here is the call graph for this function:

◆ curlStuff()

Sabre\HTTP\ClientMock::curlStuff (   $curlHandle)
protected

Returns a bunch of information about a curl request.

This method exists so it can easily be overridden and mocked.

Parameters
resource$curlHandle
Returns
array

Reimplemented from Sabre\HTTP\Client.

Definition at line 438 of file ClientTest.php.

438 {
439
440 $return = null;
441 $this->emit('curlStuff', [&$return]);
442
443 // If nothing modified $return, we're using the default behavior.
444 if (is_null($return)) {
445 return parent::curlStuff($curlHandle);
446 } else {
447 return $return;
448 }
449
450 }

References Sabre\HTTP\Client\$curlHandle, and Sabre\Event\EventEmitterInterface\emit().

+ Here is the call graph for this function:

◆ doRequest()

Sabre\HTTP\ClientMock::doRequest ( RequestInterface  $request)

This method is responsible for performing a single request.

Parameters
RequestInterface$request
Returns
ResponseInterface

Reimplemented from Sabre\HTTP\Client.

Definition at line 416 of file ClientTest.php.

416 {
417
418 $response = null;
419 $this->emit('doRequest', [$request, &$response]);
420
421 // If nothing modified $response, we're using the default behavior.
422 if (is_null($response)) {
423 return parent::doRequest($request);
424 } else {
425 return $response;
426 }
427
428 }
$response

References $request, $response, and Sabre\Event\EventEmitterInterface\emit().

+ Here is the call graph for this function:

◆ parseCurlResult()

Sabre\HTTP\ClientMock::parseCurlResult (   $response,
  $curlHandle 
)

Making this method public.

Reimplemented from Sabre\HTTP\Client.

Definition at line 404 of file ClientTest.php.

404 {
405
406 return parent::parseCurlResult($response, $curlHandle);
407
408 }

References Sabre\HTTP\Client\$curlHandle, and $response.

Field Documentation

◆ $persistedSettings

Sabre\HTTP\ClientMock::$persistedSettings = []
protected

Definition at line 381 of file ClientTest.php.

Referenced by Sabre\HTTP\ClientMock\createCurlSettingsArray().


The documentation for this class was generated from the following file: