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/changelogs/v4.3.0.rst
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,7 +33,8 @@ Others
33
33
Enhancements
34
34
************
35
35
36
-
- Added the ``StreamFilterTrait`` to make it easier to work with capturing data from STDOUT and STDERR streams. See :ref:`testing-overview-stream-filters`.
36
+
- Added the ``StreamFilterTrait`` to make it easier to work with capturing data from STDOUT and STDERR streams. See :ref:`testing-cli-output`.
37
+
- Added the ``PhpStreamWrapper`` to make it easier to work with setting data to ``php://stdin``. See :ref:`testing-cli-input`.
37
38
- Added before and after events to ``BaseModel::insertBatch()`` and ``BaseModel::updateBatch()`` methods. See :ref:`model-events-callbacks`.
38
39
- Added ``Model::allowEmptyInserts()`` method to insert empty data. See :ref:`Using CodeIgniter's Model <model-allow-empty-inserts>`
39
40
- Added ``$routes->useSupportedLocalesOnly(true)`` so that the Router returns 404 Not Found if the locale in the URL is not supported in ``Config\App::$supportedLocales``. See :ref:`Localization <localization-in-routes>`
Copy file name to clipboardExpand all lines: user_guide_src/source/testing/overview.rst
+23-3Lines changed: 23 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -252,10 +252,10 @@ component name:
252
252
253
253
.. note:: All component Factories are reset by default between each test. Modify your test case's ``$setUpMethods`` if you need instances to persist.
254
254
255
-
.. _testing-overview-stream-filters:
255
+
.. _testing-cli-output:
256
256
257
-
Stream Filters
258
-
==============
257
+
Testing CLI Output
258
+
==================
259
259
260
260
**StreamFilterTrait** provides an alternate to these helper methods.
261
261
@@ -276,3 +276,23 @@ See :ref:`Testing Traits <testing-overview-traits>`.
276
276
277
277
If you override the ``setUp()`` or ``tearDown()`` methods in your test, then you must call the ``parent::setUp()`` and
278
278
``parent::tearDown()`` methods respectively to configure the ``StreamFilterTrait``.
279
+
280
+
.. _testing-cli-input:
281
+
282
+
Testing CLI Input
283
+
=================
284
+
285
+
**PhpStreamWrapper** provides a way to write tests for methods that require user input,
286
+
such as ``CLI::prompt()``, ``CLI::wait()``, and ``CLI::input()``.
287
+
288
+
**Overview of methods**
289
+
290
+
- ``PhpStreamWrapper::register()`` Register the ``PhpStreamWrapper`` to php protocol.
291
+
- ``PhpStreamWrapper::restore()`` Restore the php protocol wrapper back to the PHP built-in wrapper.
292
+
- ``PhpStreamWrapper::setContent()`` Set the input data.
293
+
294
+
An example demonstrating this inside one of your test cases:
295
+
296
+
.. 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