Skip to content

Commit e78804b

Browse files
Minor rewords
1 parent 81365f3 commit e78804b

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

components/phpunit_bridge.rst

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -451,22 +451,22 @@ If you have installed the bridge through Composer, you can run it by calling e.g
451451
If you still need to use ``prophecy`` (but not ``symfony/yaml``),
452452
then set the ``SYMFONY_PHPUNIT_REMOVE`` env var to ``symfony/yaml``.
453453

454-
455454
Code coverage listener
456455
----------------------
457456

458457
Use case
459458
~~~~~~~~
460459

461-
By default the code coverage is computed with the following rule: If a line of
462-
code is executed then it is marked as covered. And the test who executes a line
463-
of code is therefore marked as "covering the line of code".
460+
By default the code coverage is computed with the following rule: if a line of
461+
code is executed, then it is marked as covered. And the test which executes a
462+
line of code is therefore marked as "covering the line of code". This can be
463+
misleading.
464464

465-
This can be misleading. Considering the following example::
465+
Consider the following example::
466466

467467
class Bar
468468
{
469-
public function barZ()
469+
public function barMethod()
470470
{
471471
return 'bar';
472472
}
@@ -481,9 +481,9 @@ This can be misleading. Considering the following example::
481481
$this->bar = $bar;
482482
}
483483

484-
public function fooZ()
484+
public function fooMethod()
485485
{
486-
$this->bar->barZ();
486+
$this->bar->barMethod();
487487

488488
return 'bar';
489489
}
@@ -496,21 +496,20 @@ This can be misleading. Considering the following example::
496496
$bar = new Bar();
497497
$foo = new Foo($bar);
498498

499-
$this->assertSame('bar', $foo->barZ());
499+
$this->assertSame('bar', $foo->fooMethod());
500500
}
501501
}
502502

503503

504-
Here the ``FooTest::test`` will execute every lines of code so the code coverage
505-
will be 100%. But the ``Bar`` class is not tested.
506-
507-
The ``CoverageListener`` aim to fix this behavior by adding the ``@covers``
508-
annotation on the test class. If an annotation already exist then the listener
509-
do nothing.
510-
511-
By default the listener try to find the tested class by removing the ``Test`` part
512-
of the classname: ``My\Namespace\Tests\FooTest`` -> ``My\Namespace\Foo``.
504+
The ``FooTest::test`` method executes every single line of code of both ``Foo``
505+
and ``Bar`` classes, but ``Bar`` is not truly tested. The ``CoverageListener``
506+
aims to fix this behavior by adding the appropriate ``@covers`` annotation on
507+
each test class.
513508

509+
If a test class already defines the ``@covers`` annotation, this listener does
510+
nothing. Otherwise, it tries to find the code related to the test by removing
511+
the ``Test`` part of the classname: ``My\Namespace\Tests\FooTest`` ->
512+
``My\Namespace\Foo``.
514513

515514
Installation
516515
~~~~~~~~~~~~
@@ -531,7 +530,8 @@ Add the following configuration to the ``phpunit.xml.dist`` file
531530
</listeners>
532531
</phpunit>
533532
534-
You can also configure a new System Under Test solver:
533+
If the logic followed to find the related code is too simple or doesn't work for
534+
your application, you can use your own SUT (System Under Test) solver:
535535

536536
.. code-block:: xml
537537
@@ -543,10 +543,11 @@ You can also configure a new System Under Test solver:
543543
</listener>
544544
</listeners>
545545

546-
The ``My\Namespace\SutSolver::solve`` should be a callable and will receive the
547-
current test classname as first argument.
546+
The ``My\Namespace\SutSolver::solve`` can be any PHP callable and receives the
547+
current test classname as its first argument.
548548

549-
Finally the listener can add warning when the SUT solver does not find the SUT:
549+
Finally, the listener can also display warning messages when the SUT solver does
550+
not find the SUT:
550551

551552
.. code-block:: xml
552553

0 commit comments

Comments
 (0)