Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1f12c74

Browse files
committed
Merge branch '2.8' into 3.2
* 2.8: Rewriting the service container docs Minor reword Adding a tip for validation in forms without class Added a note about the .htaccess files included by Symfony apps Made unmapped field example in forms chapter more descriptive [#7507] fix namespace Explain better how to enable the ClockMock annotation
2 parents026f451 +b32f200 commit1f12c74

File tree

6 files changed

+366
-315
lines changed

6 files changed

+366
-315
lines changed

‎components/phpunit_bridge.rst‎

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,25 @@ The :class:`Symfony\\Bridge\\PhpUnit\\ClockMock` class provided by this bridge
215215
allows you to mock the PHP's built-in time functions ``time()``,
216216
``microtime()``, ``sleep()`` and ``usleep()``.
217217

218-
To use the ``ClockMock`` class in your test, you can:
218+
To use the ``ClockMock`` class in your test, add the ``@group time-sensitive``
219+
annotation to its class or methods. This annotation only works when executing
220+
PHPUnit using the ``vendor/bin/simple-phpunit`` script or when registering the
221+
following listener in your PHPUnit configuration:
219222

220-
* (**Recommended**) Add the ``@group time-sensitive`` annotation to its class or
221-
method;
223+
..code-block::xml
224+
225+
<!-- phpunit.xml.dist-->
226+
<!-- ...-->
227+
<listeners>
228+
<listenerclass="\Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
229+
</listeners>
230+
231+
..note::
222232

223-
* Register it manually by calling ``ClockMock::register(__CLASS__)`` and
224-
``ClockMock::withClockMock(true)`` before the test and
225-
``ClockMock::withClockMock(false)`` after the test.
233+
If you don't want to use the ``@group time-sensitive`` annotation, you can
234+
register the ``ClockMock`` class manually by calling
235+
``ClockMock::register(__CLASS__)`` and ``ClockMock::withClockMock(true)``
236+
before the test and ``ClockMock::withClockMock(false)`` after the test.
226237

227238
As a result, the following is guaranteed to work and is no longer a transient
228239
test::

‎form/without_class.rst‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,9 @@ but here's a short example:
106106
..code-block::php
107107
108108
new NotBlank(array('groups' => array('create', 'update')));
109+
110+
..tip::
111+
112+
If the form is not mapped to an object, every object in your array of
113+
submitted data is validated using the ``Symfony\Component\Validator\Constraints\Valid``
114+
constraint, unless you:doc:`disable validation</form/disabling_validation>`.

‎forms.rst‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,8 @@ the choice is ultimately up to you.
666666
{
667667
$builder
668668
->add('task')
669-
->add('dueDate', null, array('mapped' => false))
669+
->add('dueDate')
670+
->add('agreeTerms', CheckboxType::class, array('mapped' => false))
670671
->add('save', SubmitType::class)
671672
;
672673
}
@@ -676,11 +677,11 @@ the choice is ultimately up to you.
676677

677678
The field data can be accessed in a controller with::
678679

679-
$form->get('dueDate')->getData();
680+
$form->get('agreeTerms')->getData();
680681

681682
In addition, the data of an unmapped field can also be modified directly::
682683

683-
$form->get('dueDate')->setData(new \DateTime());
684+
$form->get('agreeTerms')->setData(true);
684685

685686
Final Thoughts
686687
--------------

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp