Skip to content

Commit 3f53b03

Browse files
committed
Merge branch '2.8' into 3.4
* 2.8: Fix the explanation about registering commands Add a 2nd argument to create()
2 parents f52e8e6 + d8a188e commit 3f53b03

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

console.rst

+10-4
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,16 @@ method. Then you can optionally define a help message and the
6464
Registering the Command
6565
-----------------------
6666

67-
Symfony commands must be registered as services and :doc:`tagged </service_container/tags>`
68-
with the ``console.command`` tag. If the PHP class of your command extends from
69-
:class:`Symfony\\Component\\Console\\Command\\Command`, Symfony does this for
70-
you automatically.
67+
Symfony commands must be registered before using them. In order to be registered
68+
automatically, a command must be:
69+
70+
#. Stored in a directory called ``Command/``;
71+
#. Defined in a class whose name ends with ``Command``;
72+
#. Defined in a class that extends from
73+
:class:`Symfony\\Component\\Console\\Command\\Command`.
74+
75+
If you can't meet these conditions for some command, the alternative is to
76+
manually :doc`register the command as a service </console/commands_as_services>`.
7177

7278
Executing the Command
7379
---------------------

form/unit_testing.rst

+7-4
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,19 @@ The simplest ``TypeTestCase`` implementation looks like the following::
4747
'test2' => 'test2',
4848
);
4949

50-
$form = $this->factory->create(TestedType::class);
50+
$objectToCompare = new TestObject();
51+
// $objectToCompare will retrieve data from the form submission; pass it as the second argument
52+
$form = $this->factory->create(TestedType::class, $objectToCompare);
5153

5254
$object = new TestObject();
5355
// ...populate $object properties with the data stored in $formData
5456

5557
// submit the data to the form directly
5658
$form->submit($formData);
5759

60+
$objectToCompare = $form->getData();
5861
$this->assertTrue($form->isSynchronized());
59-
$this->assertEquals($object, $form->getData());
62+
$this->assertEquals($object, $objectToCompare);
6063

6164
$view = $form->createView();
6265
$children = $view->children;
@@ -73,7 +76,7 @@ First you verify if the ``FormType`` compiles. This includes basic class
7376
inheritance, the ``buildForm()`` function and options resolution. This should
7477
be the first test you write::
7578

76-
$form = $this->factory->create(TestedType::class);
79+
$form = $this->factory->create(TestedType::class, $objectToCompare);
7780

7881
This test checks that none of your data transformers used by the form
7982
failed. The :method:`Symfony\\Component\\Form\\FormInterface::isSynchronized`
@@ -91,7 +94,7 @@ method is only set to ``false`` if a data transformer throws an exception::
9194
Next, verify the submission and mapping of the form. The test below
9295
checks if all the fields are correctly specified::
9396

94-
$this->assertEquals($object, $form->getData());
97+
$this->assertEquals($object, $objectToCompare);
9598

9699
Finally, check the creation of the ``FormView``. You should check if all
97100
widgets you want to display are available in the children property::

0 commit comments

Comments
 (0)