Skip to content

Commit a43bf8c

Browse files
Merge remote-tracking branch 'upstream/master' into popover-delay
2 parents 5535aeb + 2540de0 commit a43bf8c

File tree

59 files changed

+335
-272
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+335
-272
lines changed

.gitignore

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
build/api
2-
build/code-browser
3-
build/coverage
4-
build/logs
5-
build/pdepend
6-
cache.properties
71
/tests/_files/tmp
82
/vendor
93
/composer.lock
10-
/composer.phar
114
/.idea
125
/.php_cs.cache
6+

.travis.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
11
language: php
22

33
php:
4-
- 5.6
5-
- 7.0
6-
- nightly
4+
- 7.0
5+
- 7.1
6+
- nightly
7+
8+
env:
9+
matrix:
10+
- DRIVER="xdebug"
11+
- DRIVER="phpdbg"
712

813
sudo: false
914

1015
before_install:
11-
- composer self-update
16+
- composer self-update
17+
- composer clear-cache
1218

1319
install:
14-
- travis_retry composer install --no-interaction --prefer-source
20+
- travis_retry composer update --no-interaction --no-ansi --no-progress --no-suggest --optimize-autoloader --prefer-stable
1521

1622
script:
17-
18-
- vendor/bin/phpunit --configuration build
23+
- if [[ "$DRIVER" = 'phpdbg' ]]; then phpdbg -qrr vendor/bin/phpunit; fi
24+
- if [[ "$DRIVER" = 'xdebug' ]]; then vendor/bin/phpunit; fi
1925

2026
notifications:
2127
email: false

ChangeLog-4.0.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,24 @@
22

33
All notable changes of the PHP_CodeCoverage 4.0 release series are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
44

5+
## [4.0.5] - 2017-01-20
6+
7+
### Fixed
8+
9+
* Fixed formatting of executed lines percentage for classes in file view
10+
11+
## [4.0.4] - 2016-12-20
12+
13+
### Changed
14+
15+
* Implemented [#432](https://github.com/sebastianbergmann/php-code-coverage/issues/432): Change how files with no executable lines are displayed in the HTML report
16+
17+
## [4.0.3] - 2016-11-28
18+
19+
### Changed
20+
21+
* The check for unintentionally covered code is no longer performed for `@medium` and `@large` tests
22+
523
## [4.0.2] - 2016-11-01
624

725
### Fixed
@@ -20,6 +38,9 @@ All notable changes of the PHP_CodeCoverage 4.0 release series are documented in
2038

2139
* This component now uses namespaces
2240

41+
[4.0.5]: https://github.com/sebastianbergmann/php-code-coverage/compare/4.0.4...4.0.5
42+
[4.0.4]: https://github.com/sebastianbergmann/php-code-coverage/compare/4.0.3...4.0.4
43+
[4.0.3]: https://github.com/sebastianbergmann/php-code-coverage/compare/4.0.2...4.0.3
2344
[4.0.2]: https://github.com/sebastianbergmann/php-code-coverage/compare/4.0.1...4.0.2
2445
[4.0.1]: https://github.com/sebastianbergmann/php-code-coverage/compare/4.0.0...4.0.1
2546
[4.0.0]: https://github.com/sebastianbergmann/php-code-coverage/compare/3.3...4.0.0

ChangeLog-5.0.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Changes in PHP_CodeCoverage 5.0
2+
3+
All notable changes of the PHP_CodeCoverage 5.0 release series are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
4+
5+
## [5.0.0] - 2017-02-03
6+
7+
### Removed
8+
9+
* This component is no longer supported on PHP 5
10+
11+
12+
[5.0.0]: https://github.com/sebastianbergmann/php-code-coverage/compare/4.0...5.0.0
13+

build.xml

Lines changed: 17 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,21 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project name="PHP_CodeCoverage">
3-
<target name="clean" description="Cleanup build artifacts">
4-
<delete dir="${basedir}/vendor"/>
5-
<delete file="${basedir}/composer.lock"/>
2+
<project name="php-code-coverage" default="setup">
3+
<target name="setup" depends="clean,composer"/>
64

7-
<delete>
8-
<fileset dir="${basedir}/build">
9-
<include name="**/*.phar" />
10-
</fileset>
11-
</delete>
12-
</target>
5+
<target name="clean" description="Cleanup build artifacts">
6+
<delete dir="${basedir}/vendor"/>
7+
<delete file="${basedir}/composer.lock"/>
8+
</target>
139

14-
<target name="composer" depends="clean" description="Install dependencies with Composer">
15-
<tstamp>
16-
<format property="thirty.days.ago" pattern="MM/dd/yyyy hh:mm aa" offset="-30" unit="day"/>
17-
</tstamp>
18-
<delete>
19-
<fileset dir="${basedir}">
20-
<include name="composer.phar" />
21-
<date datetime="${thirty.days.ago}" when="before"/>
22-
</fileset>
23-
</delete>
24-
25-
<get src="https://getcomposer.org/composer.phar" dest="${basedir}/composer.phar" skipexisting="true"/>
26-
27-
<exec executable="php">
28-
<arg value="composer.phar"/>
29-
<arg value="install"/>
30-
</exec>
31-
</target>
32-
33-
<target name="phpcs" description="Find coding standard violations using PHP_CodeSniffer">
34-
<exec executable="phpcs">
35-
<arg value="--standard=PSR2" />
36-
<arg value="--extensions=php" />
37-
<arg path="${basedir}/src" />
38-
<arg path="${basedir}/tests" />
39-
</exec>
40-
</target>
10+
<target name="composer" depends="clean" description="Install dependencies with Composer">
11+
<exec executable="composer" taskname="composer">
12+
<arg value="update"/>
13+
<arg value="--no-interaction"/>
14+
<arg value="--no-progress"/>
15+
<arg value="--no-ansi"/>
16+
<arg value="--no-suggest"/>
17+
<arg value="--optimize-autoloader"/>
18+
<arg value="--prefer-stable"/>
19+
</exec>
20+
</target>
4121
</project>

composer.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,22 @@
2020
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
2121
"irc": "irc://irc.freenode.net/phpunit"
2222
},
23+
"minimum-stability": "dev",
2324
"require": {
24-
"php": "^5.6 || ^7.0",
25-
"phpunit/php-file-iterator": "~1.3",
25+
"php": "^7.0",
26+
"phpunit/php-file-iterator": "^1.3",
2627
"phpunit/php-token-stream": "^1.4.2",
27-
"phpunit/php-text-template": "~1.2",
28-
"sebastian/code-unit-reverse-lookup": "~1.0",
29-
"sebastian/environment": "^1.3.2 || ^2.0",
30-
"sebastian/version": "~1.0|~2.0"
28+
"phpunit/php-text-template": "^1.2",
29+
"sebastian/code-unit-reverse-lookup": "^1.0",
30+
"sebastian/environment": "^2.0",
31+
"sebastian/version": "^2.0"
3132
},
3233
"require-dev": {
33-
"phpunit/phpunit": "^5.4",
34-
"ext-xdebug": ">=2.1.4"
34+
"phpunit/phpunit": "^6.0",
35+
"ext-xdebug": "^2.5"
3536
},
3637
"suggest": {
3738
"ext-dom": "*",
38-
"ext-xdebug": ">=2.4.0",
3939
"ext-xmlwriter": "*"
4040
},
4141
"autoload": {
@@ -45,7 +45,7 @@
4545
},
4646
"extra": {
4747
"branch-alias": {
48-
"dev-master": "4.0.x-dev"
48+
"dev-master": "5.0.x-dev"
4949
}
5050
}
5151
}
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/5.3/phpunit.xsd"
4-
bootstrap="../tests/bootstrap.php"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/6.0/phpunit.xsd"
4+
bootstrap="tests/bootstrap.php"
55
backupGlobals="false"
66
verbose="true">
77
<testsuite>
8-
<directory suffix="Test.php">../tests/tests</directory>
8+
<directory suffix="Test.php">tests/tests</directory>
99
</testsuite>
1010

1111
<filter>
1212
<whitelist processUncoveredFilesFromWhitelist="true">
13-
<directory suffix=".php">../src</directory>
13+
<directory suffix=".php">src</directory>
1414
</whitelist>
1515
</filter>
16+
17+
<php>
18+
<ini name="serialize_precision" value="14"/>
19+
</php>
1620
</phpunit>
21+

src/CodeCoverage.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
namespace SebastianBergmann\CodeCoverage;
1212

13+
use PHPUnit\Framework\TestCase;
14+
use PHPUnit\Runner\PhptTestCase;
1315
use SebastianBergmann\CodeCoverage\Driver\Driver;
1416
use SebastianBergmann\CodeCoverage\Driver\Xdebug;
1517
use SebastianBergmann\CodeCoverage\Driver\HHVM;
@@ -340,20 +342,20 @@ public function append(array $data, $id = null, $append = true, $linesToBeCovere
340342
$size = 'unknown';
341343
$status = null;
342344

343-
if ($id instanceof \PHPUnit_Framework_TestCase) {
345+
if ($id instanceof TestCase) {
344346
$_size = $id->getSize();
345347

346-
if ($_size == \PHPUnit_Util_Test::SMALL) {
348+
if ($_size == \PHPUnit\Util\Test::SMALL) {
347349
$size = 'small';
348-
} elseif ($_size == \PHPUnit_Util_Test::MEDIUM) {
350+
} elseif ($_size == \PHPUnit\Util\Test::MEDIUM) {
349351
$size = 'medium';
350-
} elseif ($_size == \PHPUnit_Util_Test::LARGE) {
352+
} elseif ($_size == \PHPUnit\Util\Test::LARGE) {
351353
$size = 'large';
352354
}
353355

354356
$status = $id->getStatus();
355357
$id = get_class($id) . '::' . $id->getName();
356-
} elseif ($id instanceof \PHPUnit_Extensions_PhptTestCase) {
358+
} elseif ($id instanceof PhptTestCase) {
357359
$size = 'large';
358360
$id = $id->getName();
359361
}
@@ -618,7 +620,9 @@ private function applyCoversAnnotationFilter(array &$data, $linesToBeCovered, ar
618620
return;
619621
}
620622

621-
if ($this->checkForUnintentionallyCoveredCode) {
623+
if ($this->checkForUnintentionallyCoveredCode &&
624+
(!$this->currentId instanceof TestCase ||
625+
(!$this->currentId->isMedium() && !$this->currentId->isLarge()))) {
622626
$this->performUnintentionallyCoveredCodeCheck(
623627
$data,
624628
$linesToBeCovered,

src/Node/File.php

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,23 @@ class File extends AbstractNode
6060
/**
6161
* @var int
6262
*/
63-
private $numTestedTraits = 0;
63+
private $numClasses = null;
6464

6565
/**
6666
* @var int
6767
*/
6868
private $numTestedClasses = 0;
6969

70+
/**
71+
* @var int
72+
*/
73+
private $numTraits = null;
74+
75+
/**
76+
* @var int
77+
*/
78+
private $numTestedTraits = 0;
79+
7080
/**
7181
* @var int
7282
*/
@@ -223,7 +233,21 @@ public function getNumExecutedLines()
223233
*/
224234
public function getNumClasses()
225235
{
226-
return count($this->classes);
236+
if ($this->numClasses === null) {
237+
$this->numClasses = 0;
238+
239+
foreach ($this->classes as $class) {
240+
foreach ($class['methods'] as $method) {
241+
if ($method['executableLines'] > 0) {
242+
$this->numClasses++;
243+
244+
continue 2;
245+
}
246+
}
247+
}
248+
}
249+
250+
return $this->numClasses;
227251
}
228252

229253
/**
@@ -243,7 +267,21 @@ public function getNumTestedClasses()
243267
*/
244268
public function getNumTraits()
245269
{
246-
return count($this->traits);
270+
if ($this->numTraits === null) {
271+
$this->numTraits = 0;
272+
273+
foreach ($this->traits as $trait) {
274+
foreach ($trait['methods'] as $method) {
275+
if ($method['executableLines'] > 0) {
276+
$this->numTraits++;
277+
278+
continue 2;
279+
}
280+
}
281+
}
282+
}
283+
284+
return $this->numTraits;
247285
}
248286

249287
/**
@@ -484,14 +522,14 @@ protected function calculateStatistics()
484522
if ($trait['executableLines'] > 0) {
485523
$trait['coverage'] = ($trait['executedLines'] /
486524
$trait['executableLines']) * 100;
525+
526+
if ($trait['coverage'] == 100) {
527+
$this->numTestedClasses++;
528+
}
487529
} else {
488530
$trait['coverage'] = 100;
489531
}
490532

491-
if ($trait['coverage'] == 100) {
492-
$this->numTestedClasses++;
493-
}
494-
495533
$trait['crap'] = $this->crap(
496534
$trait['ccn'],
497535
$trait['coverage']
@@ -518,14 +556,14 @@ protected function calculateStatistics()
518556
if ($class['executableLines'] > 0) {
519557
$class['coverage'] = ($class['executedLines'] /
520558
$class['executableLines']) * 100;
559+
560+
if ($class['coverage'] == 100) {
561+
$this->numTestedClasses++;
562+
}
521563
} else {
522564
$class['coverage'] = 100;
523565
}
524566

525-
if ($class['coverage'] == 100) {
526-
$this->numTestedClasses++;
527-
}
528-
529567
$class['crap'] = $this->crap(
530568
$class['ccn'],
531569
$class['coverage']

0 commit comments

Comments
 (0)