8000 Update unit_testing.rst · symfony/symfony-docs@dcad5eb · GitHub
[go: up one dir, main page]

Skip to content

Commit dcad5eb

Browse files
authored
Update unit_testing.rst
Following https://symfony.com/doc/current/create_framework/index.html tutorial, after The Separation of Concerns part we don't have our old routes /hello or /bye, so this test can't pass. Also we can't run tests with only 'phpunit'
1 parent 884f721 commit dcad5eb

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-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 +1 8000 65,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

0 commit comments

Comments
 (0)
0