trait InteractsWithServer

Provides test server integration testing support.

Features:

  • Opt-in skip: Skips unless TEST_SERVER_HOST is set
  • Fast-fail: Fails if the configured test server is unreachable

Usage: Add use InteractsWithServer; to your test case. Declare protected int $serverPort = 19510; on the class to set the port. Set TEST_SERVER_HOST to opt into server integration tests.

Methods

void
setUpInteractsWithServer()

Set up server connection check.

bool
canConnectToServer()

Check if we can connect to the server.

string
getServerHost()

Get the server host.

int
getServerPort()

Get the server port.

Details

at line 29
protected void setUpInteractsWithServer()

Set up server connection check.

Server integration tests are opt-in via TEST_SERVER_HOST. The port comes from the test case's $serverPort property.

Return Value

void

at line 49
protected bool canConnectToServer()

Check if we can connect to the server.

Return Value

bool

at line 66
protected string getServerHost()

Get the server host.

Return Value

string

at line 76
protected int getServerPort()

Get the server port.

Classes using this trait must declare protected int $serverPort.

Return Value

int