Skip to content

Update unit_testing.rst #12409

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 3, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions create_framework/unit_testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ resolver. Modify the framework to make use of them::
namespace Simplex;

// ...


use Calendar\Controller\LeapYearController;
use Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface;
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
use Symfony\Component\Routing\Matcher\UrlMatcherInterface;
Expand Down Expand Up @@ -125,7 +126,7 @@ Execute this test by running ``phpunit`` in the ``example.com`` directory:

.. code-block:: terminal

$ phpunit
$ ./vendor/bin/phpunit

.. note::

Expand Down Expand Up @@ -164,11 +165,9 @@ Response::
->expects($this->once())
->method('match')
->will($this->returnValue([
'_route' => 'foo',
'name' => 'Fabien',
'_controller' => function ($name) {
return new Response('Hello '.$name);
}
'_route' => 'is_leap_year/{year}',
'year' => '2000',
'_controller' => [new LeapYearController(), 'index']
]))
;
$matcher
Expand Down Expand Up @@ -196,7 +195,7 @@ coverage feature (you need to enable `XDebug`_ first):

.. code-block:: terminal

$ phpunit --coverage-html=cov/
$ ./vendor/bin/phpunit --coverage-html=cov/

Open ``example.com/cov/src/Simplex/Framework.php.html`` in a browser and check
that all the lines for the Framework class are green (it means that they have
Expand All @@ -206,7 +205,7 @@ Alternatively you can output the result directly to the console:

.. code-block:: terminal

$ phpunit --coverage-text
$ ./vendor/bin/phpunit --coverage-text

Thanks to the clean object-oriented code that we have written so far, we have
been able to write unit-tests to cover all possible use cases of our
Expand Down