Open Journal Systems  3.3.0
Guzzle\Tests\Http\Server Class Reference

Public Member Functions

 __construct ($port=null)
 
 enqueue ($responses)
 
 flush ()
 
 getPort ()
 
 getReceivedRequests ($hydrate=false)
 
 getUrl ()
 
 isRunning ()
 
 start ()
 
 stop ()
 

Data Fields

const DEFAULT_PORT = 8124
 
const REQUEST_DELIMITER = "\n----[request]\n"
 

Detailed Description

The Server class is used to control a scripted webserver using node.js that will respond to HTTP requests with queued responses.

Queued responses will be served to requests using a FIFO order. All requests received by the server are stored on the node.js server and can be retrieved by calling {

See also
Server::getReceivedRequests()}.

Mock responses that don't require data to be transmitted over HTTP a great for testing. Mock response, however, cannot test the actual sending of an HTTP request using cURL. This test server allows the simulation of any number of HTTP request response transactions to test the actual sending of requests over the wire without having to leave an internal network.

Definition at line 27 of file Server.php.

Constructor & Destructor Documentation

◆ __construct()

Guzzle\Tests\Http\Server::__construct (   $port = null)

Create a new scripted server

Parameters
int$portPort to listen on (defaults to 8124)

Definition at line 55 of file Server.php.

References Guzzle\Tests\Http\Server\DEFAULT_PORT, and Guzzle\Tests\Http\Server\getUrl().

Member Function Documentation

◆ enqueue()

Guzzle\Tests\Http\Server::enqueue (   $responses)

Queue an array of responses or a single response on the server.

Any currently queued responses will be overwritten. Subsequent requests on the server will return queued responses in FIFO order.

Parameters
array | Response$responsesA single or array of Responses to queue
Exceptions
BadResponseException

Definition at line 80 of file Server.php.

References Guzzle\Http\Message\Response\fromMessage().

◆ flush()

Guzzle\Tests\Http\Server::flush ( )

Flush the received requests from the server

Exceptions
RuntimeException

Definition at line 66 of file Server.php.

◆ getPort()

Guzzle\Tests\Http\Server::getPort ( )

Get the port that the server is listening on

Returns
int

Definition at line 139 of file Server.php.

Referenced by Guzzle\Tests\Http\Server\getUrl().

◆ getReceivedRequests()

Guzzle\Tests\Http\Server::getReceivedRequests (   $hydrate = false)

Get all of the received requests

Parameters
bool$hydrateSet to TRUE to turn the messages into actual {
See also
RequestInterface} objects. If $hydrate is FALSE, requests will be returned as strings.
Returns
array
Exceptions
RuntimeException

Definition at line 154 of file Server.php.

References Guzzle\Http\Message\RequestFactory\getInstance().

◆ getUrl()

Guzzle\Tests\Http\Server::getUrl ( )

Get the URL to the server

Returns
string

Definition at line 129 of file Server.php.

References Guzzle\Tests\Http\Server\getPort().

Referenced by Guzzle\Tests\Http\Server\__construct().

◆ isRunning()

Guzzle\Tests\Http\Server::isRunning ( )

Check if the server is running

Returns
bool

Definition at line 109 of file Server.php.

Referenced by Guzzle\Tests\Http\Server\start(), and Guzzle\Tests\Http\Server\stop().

◆ start()

Guzzle\Tests\Http\Server::start ( )

Start running the node.js server in the background

Definition at line 170 of file Server.php.

References Guzzle\Tests\Http\Server\isRunning().

◆ stop()

Guzzle\Tests\Http\Server::stop ( )

Stop running the node.js server

Definition at line 191 of file Server.php.

References Guzzle\Tests\Http\Server\isRunning().

Field Documentation

◆ DEFAULT_PORT

const Guzzle\Tests\Http\Server::DEFAULT_PORT = 8124

Definition at line 29 of file Server.php.

Referenced by Guzzle\Tests\Http\Server\__construct().

◆ REQUEST_DELIMITER

const Guzzle\Tests\Http\Server::REQUEST_DELIMITER = "\n----[request]\n"

Definition at line 30 of file Server.php.


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