Note that there are some explanatory texts on larger screens.

plurals
  1. POReaching 100% Code Coverage with PHPUnit
    primarykey
    data
    text
    <p>I've been in the process of creating a test suite for a project, and while I realize getting 100% coverage isn't <em>the</em> metric one should strive to, there is a strange bit in the code coverage report to which I would like some clarification. </p> <p>See screenshot:</p> <p><img src="https://i.stack.imgur.com/cZfQl.png" alt="enter image description here"></p> <p>Because the last line of the method being tested is a <code>return</code>, the final line (which is just a closing bracket) shows up as never being executed, and as a consequence the whole method is flagged as not executed in the overview. (Either that, or I'm not reading the report correctly.)</p> <p>The complete method: </p> <pre><code>static public function &amp;getDomain($domain = null) { $domain = $domain ?: self::domain(); if (! array_key_exists($domain, self::$domains)) { self::$domains[$domain] = new Config(); } return self::$domains[$domain]; } </code></pre> <p>Is there a reason for this, or is it a glitch?</p> <p>(Yes, I read through <a href="https://stackoverflow.com/questions/7074022/how-to-get-100-code-coverage-with-phpunit">How to get 100% Code Coverage with PHPUnit</a>, different case although similar.)</p> <p>Edit: </p> <p>Trudging on through the report, I noticed the same is true for a <code>switch</code> statement elsewhere in the code. So this behaviour is at least to some extent consistent, but baffling to me none the less.</p> <p>Edit2:</p> <p>I'm running on: PHPUnit 3.6.7, PHP 5.4.0RC5, XDebug 2.2.0-dev on a OS X</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload