Infection: Not covered mutant with `switch(true) -> switch(false)` mutation

Created on 7 Sep 2017  Â·  3Comments  Â·  Source: infection/infection

| Question | Answer
| ------------| ---------------
| Infection version | 0.5.2
| Test Framework version | PHPUnit 6.1.0
| PHP version | 7.1.0
| Platform | MacOS
| Github Repo | https://github.com/oxidmod/rest-bundle/tree/repo/mutation-tests

There is an issue with either XDebug or PHPUnit Coverage component that leads to uncovered mutant with 100% code coverage.

--- Original
+++ New
@@ @@
     {
-        switch (true) {
+        switch (false) {
             case $data === null:
                 return new NullResource();
             case is_array($data):
             case $data instanceof \Traversable:
                 return new Collection($data, $this->transformer, $resourceKey);
             default:

I've created an issue in the PHPUnit_Coverage repository to track it: https://github.com/sebastianbergmann/php-code-coverage/issues/552

Temporary solution is to rewrite this code with ifs

Bug False Positive

All 3 comments

There is an issue with either XDebug or PHPUnit Coverage component that leads to uncovered mutant with 100% code coverage.

Looks like it's PHP itself since the same can be seen with phpdbg without Xdebug loaded:

<?php

phpdbg_start_oplog();

switch (true) {
    case false:
        echo 'here';
        break;
}

var_dump(phpdbg_get_executable());
↪  phpdbg -qrr coverage.php 
array(1) {
  '/home/morozov/coverage.php' =>
  array(5) {
    [3] =>
    int(0)
    [6] =>
    int(0)
    [7] =>
    int(0)
    [8] =>
    int(0)
    [11] =>
    int(0)
  }
}

Looks like won't fix according to Derick's explanation: https://bugs.xdebug.org/view.php?id=1479

Closing for now...

Was this page helpful?
0 / 5 - 0 ratings

Related issues

olivernybroe picture olivernybroe  Â·  5Comments

asgrim picture asgrim  Â·  3Comments

vitormelon picture vitormelon  Â·  5Comments

zdenekgebauer picture zdenekgebauer  Â·  8Comments

maks-rafalko picture maks-rafalko  Â·  4Comments