8000 Merge branch '3.4' into 4.2 · symfony/symfony-docs@f870911 · GitHub
[go: up one dir, main page]

Skip to content

Commit f870911

Browse files
committed
Merge branch '3.4' into 4.2
* 3.4: Minor tweaks use :: instead of .. code-block:: php do not mock the validator in form type tests updating spacing
2 parents 8dbbad8 + 66716ae commit f870911

File tree

3 files changed

+17
-28
lines changed

3 files changed

+17
-28
lines changed

components/options_resolver.rst

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,11 @@ code. Use the :phpfunction:`array_replace` to fix that::
7373
}
7474
}
7575

76-
Now all four options are guaranteed to be set. But what happens if the user of
77-
the ``Mailer`` class makes a mistake?
78-
79-
.. code-block:: php
76+
Now all four options are guaranteed to be set, but you could still make an error
77+
like the following when using the ``Mailer`` class::
8078

8179
$mailer = new Mailer([
82-
'usernme' => 'johndoe', // usernme misspelled (instead of username)
80+
'usernme' => 'johndoe', // 'username' is wrongly spelled as 'usernme'
8381
]);
8482

8583
No error will be shown. In the best case, the bug will appear during testing,

form/unit_testing.rst

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -182,31 +182,22 @@ allows you to return a list of extensions to register::
182182
namespace App\Tests\Form\Type;
183183

184184
// ...
185-
use App\Form\Type\TestedType;
186185
use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
187-
use Symfony\Component\Form\Form;
188-
use Symfony\Component\Validator\ConstraintViolationList;
189-
use Symfony\Component\Validator\Mapping\ClassMetadata;
190-
use Symfony\Component\Validator\Validator\ValidatorInterface;
186+
use Symfony\Component\Validator\Validation;
191187

192188
class TestedTypeTest extends TypeTestCase
193189
{
194-
private $validator;
195-
196190
protected function getExtensions()
197191
{
198-
$this->validator = $this->createMock(ValidatorInterface::class);
199-
// use getMock() on PHPUnit 5.3 or below
200-
// $this->validator = $this->getMock(ValidatorInterface::class);
201-
$this->validator
202-
->method('validate')
203-
->will($this->returnValue(new ConstraintViolationList()));
204-
$this->validator
205-
->method('getMetadataFor')
206-
->will($this->returnValue(new ClassMetadata(Form::class)));
192+
$validator = Validation::createValidator();
193+
194+
// or if you also need to read constraints from annotations
195+
$validator = Validation::createValidatorBuilder()
196+
->enableAnnotationMapping()
197+
->getValidator();
207198

208199
return [
209-
new ValidatorExtension($this->validator),
200+
new ValidatorExtension($validator),
210201
];
211202
}
212203

logging/monolog_email.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,12 @@ get logged on the server as well as the emails being sent:
212212
type: deduplication
213213
handler: swift
214214
swift:
215-
type: swift_mailer
216-
from_email: 'error@example.com'
217-
to_email: 'error@example.com'
218-
subject: 'An Error Occurred! %%message%%'
219-
level: debug
220-
formatter: monolog.formatter.html
215+
type: swift_mailer
216+
from_email: 'error@example.com'
217+
to_email: 'error@example.com'
218+
subject: 'An Error Occurred! %%message%%'
219+
level: debug
220+
formatter: monolog.formatter.html
221221
content_type: text/html
222222
223223
.. code-block:: xml

0 commit comments

Comments
 (0)
0