You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: user_guide_src/source/testing/overview.rst
+13-3Lines changed: 13 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -285,14 +285,24 @@ Testing CLI Input
285
285
**PhpStreamWrapper** provides a way to write tests for methods that require user input,
286
286
such as ``CLI::prompt()``, ``CLI::wait()``, and ``CLI::input()``.
287
287
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
+
288
293
**Overview of methods**
289
294
290
-
- ``PhpStreamWrapper::register()`` Register the ``PhpStreamWrapper`` to php protocol.
295
+
- ``PhpStreamWrapper::register()`` Register the ``PhpStreamWrapper`` to the ``php`` protocol.
291
296
- ``PhpStreamWrapper::restore()`` Restore the php protocol wrapper back to the PHP built-in wrapper.
292
297
- ``PhpStreamWrapper::setContent()`` Set the input data.
293
298
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
+
294
306
An example demonstrating this inside one of your test cases:
295
307
296
308
.. 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