Skip to content

Commit dc9a285

Browse files
committed
docs: add explanation about stream wrapper
1 parent c4cefdb commit dc9a285

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

user_guide_src/source/testing/overview.rst

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,14 +285,24 @@ Testing CLI Input
285285
**PhpStreamWrapper** provides a way to write tests for methods that require user input,
286286
such as ``CLI::prompt()``, ``CLI::wait()``, and ``CLI::input()``.
287287

288+
.. note:: The PhpStreamWrapper is a stream wrapper class.
289+
If you don't know PHP's stream wrapper,
290+
see `The streamWrapper class <https://www.php.net/manual/en/class.streamwrapper.php>`_
291+
in the PHP maual.
292+
288293
**Overview of methods**
289294

290-
- ``PhpStreamWrapper::register()`` Register the ``PhpStreamWrapper`` to php protocol.
295+
- ``PhpStreamWrapper::register()`` Register the ``PhpStreamWrapper`` to the ``php`` protocol.
291296
- ``PhpStreamWrapper::restore()`` Restore the php protocol wrapper back to the PHP built-in wrapper.
292297
- ``PhpStreamWrapper::setContent()`` Set the input data.
293298

299+
.. important:: The PhpStreamWrapper is intended for only testing ``php://stdin``.
300+
But when you register it, it handles all the `php protocol <https://www.php.net/manual/en/wrappers.php.php>`_
301+
such as ``php://stdout``, ``php://stderr``, ``php://memory``.
302+
So it is strongly recommended that ``PhpStreamWrapper`` be registered/unregistered
303+
only when needed. Otherwise, it will interfere with other built-in php streams
304+
while registered.
305+
294306
An example demonstrating this inside one of your test cases:
295307

296308
.. literalinclude:: overview/019.php
297-
298-
.. note:: It is strongly recommended that ``PhpStreamWrapper`` be registered/unregistered only when needed. Otherwise, it will interfere with other built-in php streams while registered.

0 commit comments

Comments
 (0)