-
-
Notifications
You must be signed in to change notification settings - Fork 384
Closed
Description
| Q | A |
|---|---|
| php-code-coverage version | 6.0.1 |
| PHP version | 7.1.14 |
| Driver | Xdebug 2.6.0 / PHPDBG 0.5.0 (both tested and both show the issue) |
| Xdebug version (if used) | 2.6.0 |
| Installation Method | Composer |
| Usage Method | PHPUnit |
| PHPUnit version (if used) | 7.0.2 |
Basic sample code
<?php
class manager {
public function get_component_list() {
return ['a'];
}
public function export_user_data() {
foreach ($this->get_component_list() as $item) {
if (false) {
echo "Test\n";
}
if (false) {
echo "Test\n";
}
if (false) {
echo "Test\n";
echo "Test\n";
}
}
return true;
}
}
Basic sample testcase
<?php
require_once('manager.php');
class test extends \PHPUnit\Framework\TestCase {
public function test_export_user_data_unmocked() {
$manager = new manager();
$this->assertTrue($manager->export_user_data());
}
}
Test commands
2040 phpunitcoverbug:master> phpdbg -qrr ./vendor/bin/phpunit --whitelist manager.php --coverage-html coverage/ test.php
PHPUnit 7.0.2 by Sebastian Bergmann and contributors.
. 1 / 1 (100%)
Time: 23 ms, Memory: 6.00MB
OK (1 test, 1 assertion)
Generating code coverage report in HTML format ... done
XDebug:
2043 phpunitcoverbug:master> xphp71 ./vendor/bin/phpunit --whitelist manager.php --coverage-html coverage/ test.php
PHPUnit 7.0.2 by Sebastian Bergmann and contributors.
. 1 / 1 (100%)
Time: 48 ms, Memory: 4.00MB
OK (1 test, 1 assertion)
Generating code coverage report in HTML format ... done
Expected result
None of the echo lines are covered
Actual result
The final echo line covered.
Adding another copy of the if test moves which lines are covered.
Other notes
Originally replicate against php-code-coverage 5.3.0, PHP 7.1.14, XDebug 2.6.0 and PHPUnit 6.4.4.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
