10000 Merge branch '4.3' into 4.4 · symfony/symfony-docs@50aac70 · GitHub
[go: up one dir, main page]

Skip to content

Commit 50aac70

Browse files
committed
Merge branch '4.3' into 4.4
* 4.3: Update unit_testing.rst Update events.rst
2 parents 8e4224f + ae58be2 commit 50aac70

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

create_framework/unit_testing.rst

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ resolver. Modify the framework to make use of them::
4949
namespace Simplex;
5050

5151
// ...
52-
52+
53+
use Calendar\Controller\LeapYearController;
5354
use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface;
5455
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
5556
use Symfony\Component\Routing\Matcher\UrlMatcherInterface;
@@ -125,7 +126,7 @@ Execute this test by running ``phpunit`` in the ``example.com`` directory:
125126

126127
.. code-block:: terminal
127128
128-
$ phpunit
129+
$ ./vendor/bin/phpunit
129130
130131
.. note::
131132

@@ -164,11 +165,9 @@ Response::
164165
->expects($this->once())
165166
->method('match')
166167
->will($this->returnValue([
167-
'_route' => 'foo',
168-
'name' => 'Fabien',
169-
'_controller' => function ($name) {
170-
return new Response('Hello '.$name);
171-
}
168+
'_route' => 'is_leap_year/{year}',
169+
'year' => '2000',
170+
'_controller' => [new LeapYearController(), 'index']
172171
]))
173172
;
174173
$matcher
@@ -196,7 +195,7 @@ coverage feature (you need to enable `XDebug`_ first):
196195

197196
.. code-block:: terminal
198197
199-
$ phpunit --coverage-html=cov/
198+
$ ./vendor/bin/phpunit --coverage-html=cov/
200199
201200
Open ``example.com/cov/src/Simplex/Framework.php.html`` in a browser and check
202201
that all the lines for the Framework class are green (it means that they have
@@ -206,7 +205,7 @@ Alternatively you can output the result directly to the console:
206205

207206
.. code-block:: terminal
208207
209-
$ phpunit --coverage-text
208+
$ ./vendor/bin/phpunit --coverage-text
210209
211210
Thanks to the clean object-oriented code that we have written so far, we have
212211
been able to write unit-tests to cover all possible use cases of our

reference/events.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ Typically, this is used to map URL routing parameters to their corresponding
8787
named arguments; or pass the current request when the ``Request`` type-hint is
8888
found::
8989

90+
use Symfony\Component\HttpKernel\Event\ControllerArgumentsEvent;
91+
9092
public function onKernelControllerArguments(ControllerArgumentsEvent $event)
9193
{
9294
// ...
@@ -149,6 +151,8 @@ This event is dispatched after the controller or any ``kernel.view`` listener
149151
returns a ``Response`` object. It's useful to modify or replace the response
150152
before sending it back (e.g. add/modify HTTP headers, add cookies, etc.)::
151153

154+
use Symfony\Component\HttpKernel\Event\ResponseEvent;
155+
152156
public function onKernelResponse(ResponseEvent $event)
153157
{
154158
$response = $event->getResponse();
@@ -176,6 +180,8 @@ This event is dispatched after the ``kernel.response`` event. It's useful to res
176180
the global state of the application (for example, the translator listener resets
177181
the translator's locale to the one of the parent request)::
178182

183+
use Symfony\Component\HttpKernel\Event\FinishRequestEvent;
184+
179185
public function onKernelFinishRequest(FinishRequestEvent $event)
180186
{
181187
if (null === $parentRequest = $this->requestStack->getParentRequest()) {

0 commit comments

Comments
 (0)
0