Skip to content

Commit d8a188e

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: Fix the explanation about registering commands Add a 2nd argument to create()
2 parents 2b3c6d9 + 95f9348 commit d8a188e

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

console.rst

Lines changed: 10 additions & 4 deletions
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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,19 @@ The simplest ``TypeTestCase`` implementation looks like the following::
5252
'test2' => 'test2',
5353
);
5454

55-
$form = $this->factory->create(TestedType::class);
55+
$objectToCompare = new TestObject();
56+
// $objectToCompare will retrieve data from the form submission; pass it as the second argument
57+
$form = $this->factory->create(TestedType::class, $objectToCompare);
5658

5759
$object = new TestObject();
5860
// ...populate $object properties with the data stored in $formData
5961

6062
// submit the data to the form directly
6163
$form->submit($formData);
6264

65+
$objectToCompare = $form->getData();
6366
$this->assertTrue($form->isSynchronized());
64-
$this->assertEquals($object, $form->getData());
67+
$this->assertEquals($object, $objectToCompare);
6568

6669
$view = $form->createView();
6770
$children = $view->children;
@@ -78,7 +81,7 @@ First you verify if the ``FormType`` compiles. This includes basic class
7881
inheritance, the ``buildForm()`` function and options resolution. This should
7982
be the first test you write::
8083

81-
$form = $this->factory->create(TestedType::class);
84+
$form = $this->factory->create(TestedType::class, $objectToCompare);
8285

8386
This test checks that none of your data transformers used by the form
8487
failed. The :method:`Symfony\\Component\\Form\\FormInterface::isSynchronized`
@@ -96,7 +99,7 @@ method is only set to ``false`` if a data transformer throws an exception::
9699
Next, verify the submission and mapping of the form. The test below
97100
checks if all the fields are correctly specified::
98101

99-
$this->assertEquals($object, $form->getData());
102+
$this->assertEquals($object, $objectToCompare);
100103

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

0 commit comments

Comments
 (0)