Skip to content

fixed app/console #7106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 63 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
26fdbe0
[Console] Adapt doc for easier testing of commands needing user inputs
chalasr May 28, 2016
173033b
feature #6623 [Console] Adapt doc for easier testing of commands need…
xabbuh Jun 30, 2016
6e4b3a0
[#6623] fix note directive
xabbuh Jun 30, 2016
872bf93
Merge branch '3.1'
xabbuh Jun 30, 2016
5ac8bb3
Merge branch '3.1'
wouterj Jul 1, 2016
34a3166
Routes should be just imported, not mounted
OndraM May 25, 2016
a8a58f7
Merge branch '3.1'
wouterj Jul 2, 2016
3150d2a
added June changelog
wouterj Jul 2, 2016
47bae3b
bug #6708 Routes should be just imported, not mounted (OndraM)
wouterj Jul 4, 2016
669c640
Merge branch '3.1'
wouterj Jul 4, 2016
66fc746
Merge branch '3.1'
wouterj Jul 5, 2016
70cbce1
Merge branch '3.1'
wouterj Jul 8, 2016
3fe2f1d
Merge branch '3.1'
wouterj Jul 8, 2016
39dfbe5
Merge branch '3.1'
wouterj Jul 8, 2016
be5e951
Document the file() controller helper
javiereguiluz Jul 8, 2016
b0b774a
feature #6737 Document the file() controller helper (javiereguiluz)
wouterj Jul 9, 2016
d40985d
[#6737] Fix CS
wouterj Jul 9, 2016
dbaf02c
Merge branch '3.1'
weaverryan Jul 10, 2016
86bb5ac
Fix web/front.php
ranqiangjun Jul 11, 2016
cf68ca7
Merge branch '3.1'
wouterj Jul 13, 2016
d0d6ac4
Merge branch '3.1'
weaverryan Jul 14, 2016
84ac92d
bootstrapping workflow docs
weaverryan Jul 14, 2016
d0ec57e
minor #86 bootstrapping Workflow component docs (weaverryan)
javiereguiluz Jul 15, 2016
3a94824
Minor fixes for the workflow component
javiereguiluz Jul 15, 2016
ae6d6dd
Merge branch '3.1'
wouterj Jul 15, 2016
d0f0072
Merge branch '3.1'
wouterj Jul 15, 2016
1a05686
Merge branch '3.1'
wouterj Jul 15, 2016
b9531fc
Merge branch '3.1'
wouterj Jul 15, 2016
53e29cf
fix version number
xabbuh Jul 15, 2016
a6ae33b
Merge branch '3.1'
wouterj Jul 16, 2016
a9ce0ea
Merge branch '3.1'
wouterj Jul 16, 2016
fb27875
Merge branch '3.1'
xabbuh Jul 20, 2016
d6ec754
Merge branch '3.1'
xabbuh Jul 20, 2016
8204b4f
Merge remote-tracking branch 'mercury/master'
xabbuh Jul 21, 2016
1b532b1
Merge branch '3.1'
xabbuh Jul 21, 2016
299d3b4
Merge branch '3.1'
xabbuh Jul 28, 2016
fb24c74
minor #6748 Fix web/front.php (ranqiangjun)
weaverryan Aug 2, 2016
b97d442
Merge branch '3.1'
weaverryan Aug 2, 2016
c7156e4
Merge branch '3.1'
wouterj Aug 5, 2016
e1f83cc
Merge branch '3.1'
wouterj Aug 5, 2016
42d7888
Added July changelog
wouterj Aug 5, 2016
da458d5
Merge branch '3.1'
wouterj Aug 11, 2016
a7f704c
Merge branch '3.1'
wouterj Aug 17, 2016
c04ac56
Merge branch '3.1'
weaverryan Aug 20, 2016
626ab4f
Merge branch '3.1'
weaverryan Aug 21, 2016
f78d06b
Merge branch '3.1'
wouterj Aug 28, 2016
f0fe739
[WCM][Config] Add ExprBuilder::ifEmpty()
ogizanagi Aug 27, 2016
46825ab
[Bridge/PhpUnit] doc bin/simple-phpunit
nicolas-grekas Sep 12, 2016
c600921
Making changes thanks to Javier!
weaverryan Sep 15, 2016
b386600
feature #6962 [Bridge/PhpUnit] doc bin/simple-phpunit (nicolas-grekas…
weaverryan Sep 15, 2016
8126206
minor #6922 [Config] Add ExprBuilder::ifEmpty() (ogizanagi)
weaverryan Sep 18, 2016
9ad9fba
fixed app/console
andreybolonin Oct 31, 2016
282da61
[Console] Adapt doc for easier testing of commands needing user inputs
chalasr May 28, 2016
6f3e28f
[#6623] fix note directive
xabbuh Jun 30, 2016
798cffa
added June changelog
wouterj Jul 2, 2016
9dc9454
bootstrapping workflow docs
weaverryan Jul 14, 2016
59a5287
Minor fixes for the workflow component
javiereguiluz Jul 15, 2016
4904b12
fix version number
xabbuh Jul 15, 2016
9a99dca
Added July changelog
wouterj Aug 5, 2016
162ba20
[WCM][Config] Add ExprBuilder::ifEmpty()
ogizanagi Aug 27, 2016
6bb16d0
[Bridge/PhpUnit] doc bin/simple-phpunit
nicolas-grekas Sep 12, 2016
7f4a82f
Making changes thanks to Javier!
weaverryan Sep 15, 2016
d04f737
Merge branch 'master' of github.com:andreybolonin/symfony-docs
andreybolonin Nov 2, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ New Documentation
* `#6744 <https://github.com/symfony/symfony-docs/pull/6744>`_ [Form] Ambiguous block prefixes render incorrectly (foaly-nr1)
* `#6611 <https://github.com/symfony/symfony-docs/pull/6611>`_ Discourage the use of controllers as services (javiereguiluz)
* `#5672 <https://github.com/symfony/symfony-docs/pull/5672>`_ Add constants to BC promise (WouterJ)
* `#6737 <https://github.com/symfony/symfony-docs/pull/6737>`_ Document the file() controller helper (javiereguiluz)
* `#6707 <https://github.com/symfony/symfony-docs/pull/6707>`_ Describe serialization config location in cookbook (jcrombez, WouterJ)
* `#6726 <https://github.com/symfony/symfony-docs/pull/6726>`_ Use getParameter method in controllers (peterkokot)
* `#6727 <https://github.com/symfony/symfony-docs/pull/6727>`_ Updated the condition to display console name (mickaelandrieu)
Expand All @@ -204,6 +205,7 @@ Fixed Documentation
* `#6714 <https://github.com/symfony/symfony-docs/pull/6714>`_ UppercaseRot13Transformer wrong class name used (jevgenijusr)
* `#6704 <https://github.com/symfony/symfony-docs/pull/6704>`_ Encountered an error when following the steps for contribution (chancegarcia)
* `#6708 <https://github.com/symfony/symfony-docs/pull/6708>`_ Routes should be just imported, not mounted (OndraM)
* `#6708 <https://github.com/symfony/symfony-docs/pull/6708>`_ Routes should be just imported, not mounted (OndraM)

Minor Documentation Changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -224,6 +226,7 @@ Minor Documentation Changes
* `#100 <https://github.com/symfony/symfony-docs/pull/100>`_ Add file extension to SOAP article (WouterJ)
* `#92 <https://github.com/symfony/symfony-docs/pull/92>`_ Make usage of "The" in the edition list consistent (WouterJ)
* `#91 <https://github.com/symfony/symfony-docs/pull/91>`_ Create a section for "Getting Started" so we can generate a book (javiereguiluz)
* `#86 <https://github.com/symfony/symfony-docs/pull/86>`_ bootstrapping Workflow component docs (weaverryan)
* `#77 <https://github.com/symfony/symfony-docs/pull/77>`_ Proofing the controller chapter (weaverryan)
* `#90 <https://github.com/symfony/symfony-docs/pull/90>`_ Fixed doc build issues (javiereguiluz)
* `#82 <https://github.com/symfony/symfony-docs/pull/82>`_ Bootstrapping property info doc (weaverryan)
Expand Down Expand Up @@ -290,6 +293,7 @@ New Documentation
~~~~~~~~~~~~~~~~~

* `#6515 <https://github.com/symfony/symfony-docs/pull/6515>`_ Added the documentation for the Cache component (javiereguiluz)
* `#6623 <https://github.com/symfony/symfony-docs/pull/6623>`_ [Console] Adapt doc for easier testing of commands needing user inputs (chalasr)
* `#6690 <https://github.com/symfony/symfony-docs/pull/6690>`_ Added an example for a different method of verbosity level usage. (smatyas)
* `#6648 <https://github.com/symfony/symfony-docs/pull/6648>`_ Process: callbacks now allowed when output disabled (avindra)
* `#6587 <https://github.com/symfony/symfony-docs/pull/6587>`_ Updating recommended email settings for monolog (jorgelbg)
Expand Down
1 change: 1 addition & 0 deletions components/config/definition.rst
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,7 @@ the following ways:
- ``ifTrue()``
- ``ifString()``
- ``ifNull()``
- ``ifEmpty()`` (since Symfony 3.2)
- ``ifArray()``
- ``ifInArray()``
- ``ifNotInArray()``
Expand Down
34 changes: 19 additions & 15 deletions components/console/helpers/questionhelper.rst
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ Testing a Command that Expects Input
------------------------------------

If you want to write a unit test for a command which expects some kind of input
from the command line, you need to set the helper input stream::
from the command line, you need to set the inputs that the command expects::

use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Helper\HelperSet;
Expand All @@ -289,26 +289,30 @@ from the command line, you need to set the helper input stream::
// ...
$commandTester = new CommandTester($command);

$helper = $command->getHelper('question');
$helper->setInputStream($this->getInputStream("Test\n"));
// Equals to a user inputting "Test" and hitting ENTER
// If you need to enter a confirmation, "yes\n" will work
$commandTester->setInputs(array('Test'));

// Equals to a user inputting "This", "That" and hitting ENTER
// This can be used for answering two separated questions for instance
$commandTester->setInputs(array('This', 'That'));

// For simulating a positive answer to a confirmation question, adding an
// additional input saying "yes" will work
$commandTester->setInputs(array('yes'));

$commandTester->execute(array('command' => $command->getName()));

// $this->assertRegExp('/.../', $commandTester->getDisplay());
}

protected function getInputStream($input)
{
$stream = fopen('php://memory', 'r+', false);
fputs($stream, $input);
rewind($stream);
By calling :method:`Symfony\\Component\\Console\\Tester\\CommandTester::setInputs`,
you imitate what the console would do internally with all user input through the CLI.
This method takes an array as only argument with, for each input that the command expects,
a string representing what the user would have typed.
This way you can test any user interaction (even complex ones) by passing the appropriate inputs.

return $stream;
}
.. note::

By setting the input stream of the ``QuestionHelper``, you imitate what the
console would do internally with all user input through the CLI. This way
you can test any user interaction (even complex ones) by passing an appropriate
input stream.
The :class:`Symfony\\Component\\Console\\Tester\\CommandTester` automatically
simulates a user hitting ``ENTER`` after each input, no need for passing
an additional input.
34 changes: 33 additions & 1 deletion components/phpunit_bridge.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ It comes with the following features:

* Provides a ``ClockMock`` helper class for time-sensitive tests.

* Provides a modified version of phpunit that does not embed ``symfony/yaml`` nor
``prophecy`` to prevent any conflicts with these dependencies.

Installation
------------

You can install the component in 2 different ways:

* :doc:`Install it via Composer </components/using_components>`
(``symfony/phpunit-bridge`` on `Packagist`_); as a dev dependency;
(``symfony/phpunit-bridge`` on `Packagist`_); as a ``dev`` dependency;

* Use the official Git repository (https://github.com/symfony/phpunit-bridge).

Expand Down Expand Up @@ -326,6 +329,35 @@ namespaces in the ``phpunit.xml`` file, as done for example in the
</listeners>
</phpunit>

Modified PHPUnit script
-----------------------

.. versionadded:: 3.2
The modified PHPUnit script script was introduced in Symfony 3.2.

This bridge provides a modified version of PHPUnit that you can call by using
its ``bin/simple-phpunit`` command. It has the following features:

* Does not embed ``symfony/yaml`` nor ``prophecy`` to prevent any conflicts with
these dependencies;
* Uses PHPUnit 4.8 when run with PHP <=5.5 and PHPUnit 5.1 when run with PHP >=5.6;
* Collects and replays skipped tests when the ``SYMFONY_PHPUNIT_SKIPPED_TESTS``
env var is defined: the env var should specify a file name that will be used for
storing skipped tests on a first run, and replay them on the second run;
* Parallelizes test suites execution when given a directory as argument, scanning
this directory for ``phpunit.xml.dist`` files up to ``SYMFONY_PHPUNIT_MAX_DEPTH``
levels (specified as an env var, defaults to ``3``);

The script writes the modified PHPUnit it builds in a directory that can be
configured by the ``SYMFONY_PHPUNIT_DIR`` env var, or in the same directory as
the ``simple-phpunit`` if it is not provided.

If you have installed the bridge through Composer, you can run it by calling e.g.:

.. code-block:: bash

$ vendor/bin/simple-phpunit

.. _PHPUnit: https://phpunit.de
.. _`PHPUnit event listener`: https://phpunit.de/manual/current/en/extending-phpunit.html#extending-phpunit.PHPUnit_Framework_TestListener
.. _`PHP error handler`: http://php.net/manual/en/book.errorfunc.php
Expand Down
24 changes: 24 additions & 0 deletions components/workflow.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.. index::
single: Workflow
single: Components; Workflow

The Workflow Component
======================

The Workflow component provides tools for managing a workflow or finite state
machine.

.. versionadded:: 3.2
The Workflow component was introduced in Symfony 3.2.

Installation
------------

You can install the component in 2 different ways:

* :doc:`Install it via Composer </components/using_components>` (``symfony/workflow`` on `Packagist`_);
* Use the official Git repository (https://github.com/symfony/workflow).

For more information, see the code in the Git Repository.

.. _Packagist: https://packagist.org/packages/symfony/workflow
42 changes: 38 additions & 4 deletions controller.rst
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,12 @@ There are special classes that make certain kinds of responses easier:
:class:`Symfony\\Component\\HttpFoundation\\StreamedResponse`.
See :ref:`streaming-response`.

.. seealso::

Now that you know the basics you can continue your research on Symfony
``Request`` and ``Response`` object in the
:ref:`HttpFoundation component documentation <component-http-foundation-request>`.

JSON Helper
~~~~~~~~~~~

Expand All @@ -527,11 +533,39 @@ If the :doc:`serializer service </serializer>` is enabled in your
application, contents passed to ``json()`` are encoded with it. Otherwise,
the :phpfunction:`json_encode` function is used.

.. seealso::
File helper
~~~~~~~~~~~

Now that you know the basics you can continue your research on Symfony
``Request`` and ``Response`` object in the
:ref:`HttpFoundation component documentation <component-http-foundation-request>`.
.. versionadded:: 3.2
The ``file()`` helper was introduced in Symfony 3.2.

You can use the :method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::file`
helper to serve a file from inside a controller::

public function fileAction()
{
// send the file contents and force the browser to download it
return $this->file('/path/to/some_file.pdf');
}

The ``file()`` helper provides some arguments to configure its behavior::

use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;

public function fileAction()
{
// load the file from the filesystem
$file = new File('/path/to/some_file.pdf');

return $this->file($file);

// rename the downloaded file
return $this->file($file, 'custom_name.pdf');

// display the file contents in the browser instead of downloading it
return $this->file('invoice_3241.pdf', 'my_invoice.pdf', ResponseHeaderBag::DISPOSITION_INLINE);
}

Final Thoughts
--------------
Expand Down