| Q | A
| --------------------| ---------------
| php-code-coverage version | 5.2.1
PHP version | 7.0.19
| Driver | Xdebug
| Xdebug version (if used) | v2.5.3
| Installation Method | Composer
| Usage Method | PHPUnit
| PHPUnit version | 6.1.3
Today, after doing a composer update, my coverage guards broke, when phpunit started reporting that my coverage had dropped to 88% from 100%. (I started with phpunit version 5.6.x, and upgraded to phpunit 6.1 after I saw the bug, in hopes of it being fixed, seems to be present in all recent versions including the 5.x line)
Since no code had changed this seemed incorrect (only had done a composer update, no code changes).
Further investigation shows that PHPUnit is incorrectly reporting random arguments in methods and functions as not covered (even though they are).
Example:
In the example above, you can see that 4 tests actually cover that method, but it is saying that 1 argument is not covered. That seems impossible, since I have to call that method with those arguments. Especially since these tests are actually functional tests. Previously, these tests showed full coverage accross all metrics (Line, Functions and Methods, Classes and Traits), now, Lines show 100% but not Functions and Methods or Classes and Traits.
Example of one of the tests:
public function testPostManifestNotification()
{
$payload = ['emails' => [
'[email protected]',
]];
/** @var Branch $branch */
$branch = $this->referenceRepository->getReference('release/COM170401.0');
$path = sprintf(
'/manifests/%s/actions/notify.json',
StringType::create($branch->getFullName())->replace('/', '-')->toString()
);
$this->client->request('POST', $path, $payload);
$response = $this->client->getResponse();
$this->assertEquals(Response::HTTP_ACCEPTED, $response->getStatusCode());
}
As you can see, this is fully a functional test that should cover all the lines. PHPUnit reports they are not covered?
This is causing all my reports and CI to break, since it uses phpunit to determine coverage thresholds.
My phpunit config
<?xml version="1.0" encoding="UTF-8"?>
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.7/phpunit.xsd"
backupGlobals="false"
colors="true"
convertWarningsToExceptions="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
bootstrap="app/autoload.php">
<php>
<ini name="error_reporting" value="-1" />
<server name="KERNEL_DIR" value="app/" />
</php>
<testsuites>
<testsuite name="Isengard Tests">
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory>.</directory>
<exclude>
<directory>./.hooks</directory>
<directory>./app</directory>
<directory>./bin</directory>
<directory>./var</directory>
<directory>./src/*Bundle/Resources</directory>
<directory>./src/*Bundle/DataFixtures</directory>
<directory>./src/AppBundle/Entity</directory>
<directory>./src/*/*Bundle/Resources</directory>
<directory>./src/*/Bundle/*Bundle/Resources</directory>
<directory>./vendor</directory>
<directory>./web</directory>
<directory>./tests</directory>
<file>RoboFile.php</file>
</exclude>
</whitelist>
</filter>
<logging>
<log type="coverage-clover" target="build/phpunit/logs/clover.xml" />
<log type="coverage-crap4j" target="build/phpunit/logs/crap4j.xml" />
<log type="coverage-html" target="build/phpunit/html"/>
<log type="junit" target="build/phpunit/logs/junit.xml" logIncompleteSkipped="false"/>
</logging>
</phpunit>
Relevant composer parts:
"require": {
"php": ">=7.0",
"ext-redis": "*",
"symfony/symfony": "~3.2",
"doctrine/orm": "^2.5",
"doctrine/doctrine-bundle": "^1.6",
"doctrine/doctrine-cache-bundle": "^1.2",
"doctrine/doctrine-migrations-bundle": "^1.2",
"stof/doctrine-extensions-bundle": "^1.2",
"league/tactician-doctrine": "^1.0",
"ramsey/uuid-doctrine": "^1.2",
"symfony/swiftmailer-bundle": "^2.3",
"symfony/monolog-bundle": "~2.11.3",
"symfony/polyfill-apcu": "^1.0",
"sensio/distribution-bundle": "^5.0",
"sensio/framework-extra-bundle": "^3.0.2",
"incenteev/composer-parameter-handler": "^2.0",
"league/tactician-bundle": "^0.4",
"friendsofsymfony/rest-bundle": "~2.2",
"nelmio/api-doc-bundle": "^2.11",
"jms/serializer-bundle": "^1.1",
"jms/di-extra-bundle": "^1.8",
"guzzlehttp/guzzle": "6.2.2",
"mopa/bootstrap-bundle": "~3.0",
"twbs/bootstrap": "~3.3.0",
"symfony/assetic-bundle": "^2.8",
"friendsofsymfony/jsrouting-bundle": "^1.6",
"bmatzner/fontawesome-bundle": "~4.7",
"tdn/php-types": "dev-develop as 3.0.0",
"kzykhys/git": "v0.1.2",
"cache/apcu-adapter": "~0.2",
"cache/redis-adapter": "~0.4",
"cache/cache-bundle": "~0.5",
"cache/adapter-bundle": "~0.4",
"cache/psr-6-doctrine-bridge": "^3.0",
"kachkaev/assets-version-bundle": "~2.0",
"components/jquery": "~3.1",
"components/jqueryui": "~1.12",
"datatables/datatables": "~1.10",
"e-moe/guzzle6-bundle": "~1.1",
"composer/semver": "^1.4",
"paquettg/php-html-parser": "~1.7",
"verbalexpressions/php-verbal-expressions": "dev-master",
"typo3/class-alias-loader": "dev-master"
},
"require-dev": {
"phploc/phploc": "^3.0",
"sensio/generator-bundle": "^3.1",
"dephpend/dephpend": "dev-develop",
"henrikbjorn/lurker": "@stable",
"doctrine/doctrine-fixtures-bundle": "^2.3",
"symfony/phpunit-bridge": "dev-master",
"friendsofphp/php-cs-fixer": "~2.0",
"squizlabs/php_codesniffer": "~2.7",
"phpunit/phpunit": "~6.1",
"sebastian/phpcpd": "~3.0",
"mockery/mockery": "~0.9",
"liip/functional-test-bundle": "~1.7",
"jakub-onderka/php-parallel-lint": "0.*",
"phpmd/phpmd" : "@stable",
"consolidation/robo": "~1.0",
"seld/jsonlint": "~1.6",
"kevinlebrun/colors.php": "0.*",
"rskuipers/php-assumptions": "dev-feature/update-parser",
"povils/phpmnd": "~1.0",
"escapestudios/symfony2-coding-standard": "^2.10",
"tm/tooly-composer-script": "^1.2"
},
"scripts": {
"symfony-scripts": [
"Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget",
"Mopa\\Bundle\\BootstrapBundle\\Composer\\ScriptHandler::postInstallSymlinkTwitterBootstrap",
"Tooly\\ScriptHandler::installPharTools"
],
"post-install-cmd": [
"@symfony-scripts"
],
"post-update-cmd": [
"@symfony-scripts"
]
},
"config": {
"process-timeout": 10000,
"preferred-install": "dist",
"github-protocols": ["https"],
"bin-dir": "bin",
"platform": {
"php": "7.0"
}
},
"extra": {
"symfony-app-dir": "app",
"symfony-bin-dir": "bin",
"symfony-var-dir": "var",
"symfony-web-dir": "web",
"symfony-tests-dir": "tests",
"symfony-assets-install": "relative",
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"tools": {
"phpmd-extension": {
"url": "https://github.com/mi-schi/phpmd-extension/releases/download/stable/phpmd-extension.phar",
"only-dev": true,
"force-replace": true
},
"phpmetrics": {
"url": "https://github.com/phpmetrics/PhpMetrics/releases/download/v2.2.0/phpmetrics.phar",
"only-dev": true,
"force-replace": true
}
},
"typo3/class-alias-loader": {
"class-alias-maps": [
"src/AppBundle/AliasMap.php"
],
"always-add-alias-loader": true
}
},
"repositories": [
{
"type": "git",
"url": "https://github.com/vpassapera/php-assumptions.git"
}
]
Xdebug Config
; Managed by ansible
zend_extension=/opt/remi/php70/root/usr/lib64/php/modules/xdebug.so
xdebug.remote_enable=1
xdebug.remote_autostart=1
xdebug.remote_host=10.10.10.1
xdebug.max_nesting_level=250
xdebug.remote_port=9000
xdebug.idekey=PHPSTORM
[09:47:59] [vagrant@isengard] /vagrant [][develop ✓] → php -i | grep -i "xdebug"
/etc/php.d/15-xdebug.ini,
with Xdebug v2.5.3, Copyright (c) 2002-2017, by Derick Rethans
xdebug
xdebug support => enabled
xdebug.auto_trace => Off => Off
xdebug.cli_color => 0 => 0
xdebug.collect_assignments => Off => Off
xdebug.collect_includes => On => On
xdebug.collect_params => 0 => 0
xdebug.collect_return => Off => Off
xdebug.collect_vars => Off => Off
xdebug.coverage_enable => On => On
xdebug.default_enable => On => On
xdebug.dump.COOKIE => no value => no value
xdebug.dump.ENV => no value => no value
xdebug.dump.FILES => no value => no value
xdebug.dump.GET => no value => no value
xdebug.dump.POST => no value => no value
xdebug.dump.REQUEST => no value => no value
xdebug.dump.SERVER => no value => no value
xdebug.dump.SESSION => no value => no value
xdebug.dump_globals => On => On
xdebug.dump_once => On => On
xdebug.dump_undefined => Off => Off
xdebug.extended_info => On => On
xdebug.file_link_format => no value => no value
xdebug.force_display_errors => Off => Off
xdebug.force_error_reporting => 0 => 0
xdebug.halt_level => 0 => 0
xdebug.idekey => PHPSTORM => PHPSTORM
xdebug.max_nesting_level => 250 => 250
xdebug.max_stack_frames => -1 => -1
xdebug.overload_var_dump => 2 => 2
xdebug.profiler_aggregate => Off => Off
xdebug.profiler_append => Off => Off
xdebug.profiler_enable => Off => Off
xdebug.profiler_enable_trigger => Off => Off
xdebug.profiler_enable_trigger_value => no value => no value
xdebug.profiler_output_dir => /tmp => /tmp
xdebug.profiler_output_name => cachegrind.out.%p => cachegrind.out.%p
xdebug.remote_addr_header => no value => no value
xdebug.remote_autostart => On => On
xdebug.remote_connect_back => Off => Off
xdebug.remote_cookie_expire_time => 3600 => 3600
xdebug.remote_enable => On => On
xdebug.remote_handler => dbgp => dbgp
xdebug.remote_host => 10.10.10.1 => 10.10.10.1
xdebug.remote_log => no value => no value
xdebug.remote_mode => req => req
xdebug.remote_port => 9000 => 9000
xdebug.scream => Off => Off
xdebug.show_error_trace => Off => Off
xdebug.show_exception_trace => Off => Off
xdebug.show_local_vars => Off => Off
xdebug.show_mem_delta => Off => Off
xdebug.trace_enable_trigger => Off => Off
xdebug.trace_enable_trigger_value => no value => no value
xdebug.trace_format => 0 => 0
xdebug.trace_options => 0 => 0
xdebug.trace_output_dir => /tmp => /tmp
xdebug.trace_output_name => trace.%c => trace.%c
xdebug.var_display_max_children => 128 => 128
xdebug.var_display_max_data => 512 => 512
xdebug.var_display_max_depth => 3 => 3
Seems that anywhere I use a mock (i use mockery), or symfony functional tests, phpunit is not honoring that coverage under the Methods & Functions | Classes metrics...it did not that long ago.
MOVED FROM https://github.com/sebastianbergmann/phpunit/issues/2676