class FakeStream implements StreamInterface (View source)

Properties

protected string[] $buffer

Lines queued for testing; each call to fgets() pops the next line.

protected string[] $written

Data that has been "written" to this fake stream (for assertion).

protected array|null $connection

The connection info.

protected array $meta

The mock meta info.

Methods

feed(array|string $lines)

Feed a line to the stream buffer with a newline character.

feedRaw(array|string $lines)

Feed a raw line to the stream buffer.

setMeta(string $attribute, mixed $value)

Set the timed out status.

bool
open(string $transport = null, string $host = null, int $port = null, int $timeout = null, array $options = [])

Open the underlying stream.

void
close()

Close the underlying stream.

string|false
read(int $length)

Read data from the stream.

string|false
fgets()

Read a single line from the stream.

int|false
fwrite(string $data)

Write data to the stream.

array
meta()

Return meta info (like stream_get_meta_data).

bool
opened()

Determine if the stream is open.

bool
setTimeout(int $seconds)

Set the timeout on the stream.

bool|int
setSocketSetCrypto(bool $enabled, int|null $method)

Set encryption state on an already connected socked.

void
assertWritten(string $string)

Assert that the given data was written to the stream.

Details

FakeStream feed(array|string $lines)

Feed a line to the stream buffer with a newline character.

Parameters

array|string $lines

Return Value

FakeStream

FakeStream feedRaw(array|string $lines)

Feed a raw line to the stream buffer.

Parameters

array|string $lines

Return Value

FakeStream

FakeStream setMeta(string $attribute, mixed $value)

Set the timed out status.

Parameters

string $attribute
mixed $value

Return Value

FakeStream

bool open(string $transport = null, string $host = null, int $port = null, int $timeout = null, array $options = [])

Open the underlying stream.

Parameters

string $transport
string $host
int $port
int $timeout
array $options

Return Value

bool

void close()

Close the underlying stream.

Return Value

void

string|false read(int $length)

Read data from the stream.

Parameters

int $length

Return Value

string|false

string|false fgets()

Read a single line from the stream.

Return Value

string|false

int|false fwrite(string $data)

Write data to the stream.

Parameters

string $data

Return Value

int|false

array meta()

Return meta info (like stream_get_meta_data).

Return Value

array

bool opened()

Determine if the stream is open.

Return Value

bool

bool setTimeout(int $seconds)

Set the timeout on the stream.

Parameters

int $seconds

Return Value

bool

bool|int setSocketSetCrypto(bool $enabled, int|null $method)

Set encryption state on an already connected socked.

Parameters

bool $enabled
int|null $method

Return Value

bool|int

void assertWritten(string $string)

Assert that the given data was written to the stream.

Parameters

string $string

Return Value

void