Doug Wilbourne
Doug Wilbourne

Reputation: 145

PHP - how to configure stream context to include STREAM_REPORT_ERRORS flag for vfsStream

I am trying to test code that will catch errors in file i/o operations. For the purposes of this question, let's say I am testing php's fopen verb.

I am using vfsStream to mock a file system.

The signature for the StreamWrapper::stream_open method in the vfsStream package is

public function stream_open(string $path, string $mode, int $options, ?string $opened_path = null): bool

I want to use the STREAM_REPORT_ERRORS flag as an option when stream_open gets called.

Here's where I am lost: am I supposed to pass a stream context in as an argument to the fopen call? For example

$use_include_path = false;
$options = [
    'file' => [.... what goes here ... something like 'options' => STREAM_REPORT_ERRORS??? ]
];
$context = stream_context_create($options);
$handle = fopen('some/path', 'r', $use_include_path, $context);

OR

am I supposed to set an option on the vfsStream wrapper itself just after vfsStream::setUp runs and registers the wrapper? And if so, how do I set that option?

thanks in advance

Upvotes: 0

Views: 12

Answers (0)

Related Questions