Description
When running tests such that the coverage increases opposite to the alphabetical ordering of the classes causes the complexity scatter chart on the dashboard to show the wrong values in the tooltips (on hover/click).
Taking a look at https://github.com/msbit/php-code-coverage-class-complexity-tooltip-ordering, if we run the following:
XDEBUG_MODE=coverage vendor/bin/phpunit --filter decreasing_coverage
then the tooltip for A shows Coverage: 33%, for B 67% and for C 100%, whereas the actual coverage values (as shown when clicking on the tooltips) are in the opposite order. Running the other test, via:
XDEBUG_MODE=coverage vendor/bin/phpunit --filter increasing_coverage
shows the correct tooltips.
It looks like the tooltip code presumes that the data will be in coverage order by this point, and indeed adding:
usort($result['class'], fn($a, $b) => intval($a[0] - $b[0]));
before:
$class = json_encode($result['class']);
here results in the correct behaviour in this specific case (it ignores the other axis, complexity, so is likely not general enough).