Commit cc51b6ef authored by webchick's avatar webchick

Issue #2568595 by hussainweb, dawehner: Upgrade PHPUnit to latest 4.8.x

parent 1e4c4c3f
......@@ -5,6 +5,7 @@
"This file is @generated automatically"
],
"hash": "8c9fdf621ce53640f24b24749e59717c",
"content-hash": "f38613812a285c03a1a18458384fe0b1",
"packages": [
{
"name": "composer/installers",
......@@ -2622,16 +2623,16 @@
},
{
"name": "phpunit/php-code-coverage",
"version": "2.2.2",
"version": "2.2.3",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "2d7c03c0e4e080901b8f33b2897b0577be18a13c"
"reference": "ef1ca6835468857944d5c3b48fa503d5554cff2f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2d7c03c0e4e080901b8f33b2897b0577be18a13c",
"reference": "2d7c03c0e4e080901b8f33b2897b0577be18a13c",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ef1ca6835468857944d5c3b48fa503d5554cff2f",
"reference": "ef1ca6835468857944d5c3b48fa503d5554cff2f",
"shasum": ""
},
"require": {
......@@ -2680,7 +2681,7 @@
"testing",
"xunit"
],
"time": "2015-08-04 03:42:39"
"time": "2015-09-14 06:51:16"
},
{
"name": "phpunit/php-file-iterator",
......@@ -2813,16 +2814,16 @@
},
{
"name": "phpunit/php-token-stream",
"version": "1.4.6",
"version": "1.4.8",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-token-stream.git",
"reference": "3ab72c62e550370a6cd5dc873e1a04ab57562f5b"
"reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/3ab72c62e550370a6cd5dc873e1a04ab57562f5b",
"reference": "3ab72c62e550370a6cd5dc873e1a04ab57562f5b",
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da",
"reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da",
"shasum": ""
},
"require": {
......@@ -2858,20 +2859,20 @@
"keywords": [
"tokenizer"
],
"time": "2015-08-16 08:51:00"
"time": "2015-09-15 10:49:45"
},
{
"name": "phpunit/phpunit",
"version": "4.8.6",
"version": "4.8.10",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "2246830f4a1a551c67933e4171bf2126dc29d357"
"reference": "463163747474815c5ccd4ae12b5b355ec12158e8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/2246830f4a1a551c67933e4171bf2126dc29d357",
"reference": "2246830f4a1a551c67933e4171bf2126dc29d357",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/463163747474815c5ccd4ae12b5b355ec12158e8",
"reference": "463163747474815c5ccd4ae12b5b355ec12158e8",
"shasum": ""
},
"require": {
......@@ -2930,20 +2931,20 @@
"testing",
"xunit"
],
"time": "2015-08-24 04:09:38"
"time": "2015-10-01 09:14:30"
},
{
"name": "phpunit/phpunit-mock-objects",
"version": "2.3.7",
"version": "2.3.8",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
"reference": "5e2645ad49d196e020b85598d7c97e482725786a"
"reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/5e2645ad49d196e020b85598d7c97e482725786a",
"reference": "5e2645ad49d196e020b85598d7c97e482725786a",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/ac8e7a3db35738d56ee9a76e78a4e03d97628983",
"reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983",
"shasum": ""
},
"require": {
......@@ -2986,7 +2987,7 @@
"mock",
"xunit"
],
"time": "2015-08-19 09:14:08"
"time": "2015-10-02 06:51:40"
},
{
"name": "sebastian/comparator",
......
......@@ -34,7 +34,7 @@
"behat/mink": "~1.6",
"behat/mink-goutte-driver": "~1.2",
"mikey179/vfsStream": "~1.2",
"phpunit/phpunit": "4.8.*",
"phpunit/phpunit": "~4.8",
"symfony/css-selector": "2.7.*"
},
"replace": {
......
../phpunit/phpunit/phpunit
\ No newline at end of file
#!/usr/bin/env sh
SRC_DIR="`pwd`"
cd "`dirname "$0"`"
cd '../phpunit/phpunit'
BIN_TARGET="`pwd`/phpunit"
cd "$SRC_DIR"
"$BIN_TARGET" "$@"
This diff is collapsed.
......@@ -2,6 +2,15 @@
All notable changes of the PHP_CodeCoverage 2.2 release series are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.
## [2.2.3] - 2015-09-14
### Fixed
* Fixed [#368](https://github.com/sebastianbergmann/php-code-coverage/pull/368): Blacklists and whitelists are not merged when merging data sets
* Fixed [#370](https://github.com/sebastianbergmann/php-code-coverage/issues/370): Confusing statistics for source file that declares a class without methods
* Fixed [#372](https://github.com/sebastianbergmann/php-code-coverage/pull/372): Nested classes and functions are not handled correctly
* Fixed [#382](https://github.com/sebastianbergmann/php-code-coverage/issues/382): Crap4J report generates incorrect XML logfile
## [2.2.2] - 2015-08-04
### Added
......@@ -33,6 +42,7 @@ All notable changes of the PHP_CodeCoverage 2.2 release series are documented in
* The dedicated driver for HHVM, `PHP_CodeCoverage_Driver_HHVM` has been removed
[2.2.3]: https://github.com/sebastianbergmann/php-code-coverage/compare/2.2.3...2.2.3
[2.2.2]: https://github.com/sebastianbergmann/php-code-coverage/compare/2.2.1...2.2.2
[2.2.1]: https://github.com/sebastianbergmann/php-code-coverage/compare/2.2.0...2.2.1
[2.2.0]: https://github.com/sebastianbergmann/php-code-coverage/compare/2.1...2.2.0
......
......@@ -7,8 +7,19 @@
## Requirements
* PHP 5.3.3 is required but using the latest version of PHP is highly recommended
* [Xdebug](http://xdebug.org/) 2.1.3 is required but using the latest version of Xdebug is highly recommended
PHP 5.3.3 is required but using the latest version of PHP is highly recommended
### PHP 5
[Xdebug](http://xdebug.org/) is the only source of raw code coverage data supported for PHP 5. Version 2.1.3 of Xdebug is required but using the latest version is highly recommended.
### PHP 7
[phpdbg](http://phpdbg.com/docs) is currently the only source of raw code coverage data supported for PHP 7. Once Xdebug has been updated for PHP 7 it, too, will be supported.
### HHVM
A version of HHVM that implements the Xdebug API for code coverage (`xdebug_*_code_coverage()`) is required.
## Installation
......@@ -16,7 +27,7 @@ To add PHP_CodeCoverage as a local, per-project dependency to your project, simp
{
"require": {
"phpunit/php-code-coverage": "~2.0"
"phpunit/php-code-coverage": "^2"
}
}
......@@ -37,4 +48,3 @@ $writer->process($coverage, '/tmp/clover.xml');
$writer = new PHP_CodeCoverage_Report_HTML;
$writer->process($coverage, '/tmp/code-coverage-report');
```
......@@ -340,6 +340,14 @@ public function append(array $data, $id = null, $append = true, $linesToBeCovere
*/
public function merge(PHP_CodeCoverage $that)
{
$this->filter->setBlacklistedFiles(
array_merge($this->filter->getBlacklistedFiles(), $that->filter()->getBlacklistedFiles())
);
$this->filter->setWhitelistedFiles(
array_merge($this->filter->getWhitelistedFiles(), $that->filter()->getWhitelistedFiles())
);
foreach ($that->data as $file => $lines) {
if (!isset($this->data[$file])) {
if (!$this->filter->isFiltered($file)) {
......@@ -364,13 +372,6 @@ public function merge(PHP_CodeCoverage $that)
$this->tests = array_merge($this->tests, $that->getTests());
$this->filter->setBlacklistedFiles(
array_merge($this->filter->getBlacklistedFiles(), $that->filter()->getBlacklistedFiles())
);
$this->filter->setWhitelistedFiles(
array_merge($this->filter->getWhitelistedFiles(), $that->filter()->getWhitelistedFiles())
);
}
/**
......
......@@ -172,7 +172,8 @@ public function removeFileFromWhitelist($filename)
/**
* Checks whether a filename is a real filename.
*
* @param string $filename
* @param string $filename
* @return bool
*/
public function isFile($filename)
{
......
......@@ -116,7 +116,7 @@ public function process(PHP_CodeCoverage $coverage, $target = null, $name = null
if ($fullMethodCount > 0) {
$crapMethodPercent = $this->roundValue((100 * $fullCrapMethodCount) / $fullMethodCount);
} else {
$crapMethodPercent = '';
$crapMethodPercent = 0;
}
$stats->appendChild($document->createElement('crapMethodPercent', $crapMethodPercent));
......
......@@ -58,7 +58,7 @@ abstract class PHP_CodeCoverage_Report_HTML_Renderer
*/
public function __construct($templatePath, $generator, $date, $lowUpperBound, $highLowerBound)
{
$version = new SebastianBergmann\Version('2.2.2', dirname(dirname(dirname(dirname(__DIR__)))));
$version = new SebastianBergmann\Version('2.2.3', dirname(dirname(dirname(dirname(__DIR__)))));
$this->templatePath = $templatePath;
$this->generator = $generator;
......@@ -76,9 +76,6 @@ public function __construct($templatePath, $generator, $date, $lowUpperBound, $h
protected function renderItemTemplate(Text_Template $template, array $data)
{
$numSeparator = ' / ';
$classesBar = ' ';
$classesLevel = 'None';
$classesNumber = ' ';
if (isset($data['numClasses']) && $data['numClasses'] > 0) {
$classesLevel = $this->getColorLevel($data['testedClassesPercent']);
......@@ -89,12 +86,12 @@ protected function renderItemTemplate(Text_Template $template, array $data)
$classesBar = $this->getCoverageBar(
$data['testedClassesPercent']
);
} else {
$classesLevel = 'success';
$classesNumber = '0' . $numSeparator . '0';
$classesBar = $this->getCoverageBar(100);
}
$methodsBar = ' ';
$methodsLevel = 'None';
$methodsNumber = ' ';
if ($data['numMethods'] > 0) {
$methodsLevel = $this->getColorLevel($data['testedMethodsPercent']);
......@@ -104,12 +101,13 @@ protected function renderItemTemplate(Text_Template $template, array $data)
$methodsBar = $this->getCoverageBar(
$data['testedMethodsPercent']
);
} else {
$methodsLevel = 'success';
$methodsNumber = '0' . $numSeparator . '0';
$methodsBar = $this->getCoverageBar(100);
$data['testedMethodsPercentAsString'] = '100.00%';
}
$linesBar = ' ';
$linesLevel = 'None';
$linesNumber = ' ';
if ($data['numExecutableLines'] > 0) {
$linesLevel = $this->getColorLevel($data['linesExecutedPercent']);
......@@ -119,6 +117,11 @@ protected function renderItemTemplate(Text_Template $template, array $data)
$linesBar = $this->getCoverageBar(
$data['linesExecutedPercent']
);
} else {
$linesLevel = 'success';
$linesNumber = '0' . $numSeparator . '0';
$linesBar = $this->getCoverageBar(100);
$data['linesExecutedPercentAsString'] = '100.00%';
}
$template->setVar(
......
......@@ -351,6 +351,8 @@ public function getNumTestedFunctions()
*/
protected function calculateStatistics()
{
$classStack = $functionStack = array();
if ($this->cacheTokens) {
$tokens = PHP_Token_Stream_CachingFactory::get($this->getPath());
} else {
......@@ -367,6 +369,10 @@ protected function calculateStatistics()
if (isset($this->startLines[$lineNumber])) {
// Start line of a class.
if (isset($this->startLines[$lineNumber]['className'])) {
if (isset($currentClass)) {
$classStack[] = &$currentClass;
}
$currentClass = &$this->startLines[$lineNumber];
} // Start line of a trait.
elseif (isset($this->startLines[$lineNumber]['traitName'])) {
......@@ -376,12 +382,15 @@ protected function calculateStatistics()
$currentMethod = &$this->startLines[$lineNumber];
} // Start line of a function.
elseif (isset($this->startLines[$lineNumber]['functionName'])) {
if (isset($currentFunction)) {
$functionStack[] = &$currentFunction;
}
$currentFunction = &$this->startLines[$lineNumber];
}
}
if (isset($this->coverageData[$lineNumber]) &&
$this->coverageData[$lineNumber] !== null) {
if (isset($this->coverageData[$lineNumber])) {
if (isset($currentClass)) {
$currentClass['executableLines']++;
}
......@@ -425,6 +434,13 @@ protected function calculateStatistics()
// End line of a class.
if (isset($this->endLines[$lineNumber]['className'])) {
unset($currentClass);
if ($classStack) {
end($classStack);
$key = key($classStack);
$currentClass = &$classStack[$key];
unset($classStack[$key]);
}
} // End line of a trait.
elseif (isset($this->endLines[$lineNumber]['traitName'])) {
unset($currentTrait);
......@@ -434,6 +450,13 @@ protected function calculateStatistics()
} // End line of a function.
elseif (isset($this->endLines[$lineNumber]['functionName'])) {
unset($currentFunction);
if ($functionStack) {
end($functionStack);
$key = key($functionStack);
$currentFunction = &$functionStack[$key];
unset($functionStack[$key]);
}
}
}
}
......
......@@ -60,68 +60,68 @@ public function testSomething()
'BankAccount' => array(
'methods' => array(
'getBalance' => array(
'signature' => 'getBalance()',
'startLine' => 6,
'endLine' => 9,
'signature' => 'getBalance()',
'startLine' => 6,
'endLine' => 9,
'executableLines' => 1,
'executedLines' => 1,
'ccn' => 1,
'coverage' => 100,
'crap' => '1',
'link' => 'BankAccount.php.html#6',
'methodName' => 'getBalance'
'executedLines' => 1,
'ccn' => 1,
'coverage' => 100,
'crap' => '1',
'link' => 'BankAccount.php.html#6',
'methodName' => 'getBalance'
),
'setBalance' => array(
'signature' => 'setBalance($balance)',
'startLine' => 11,
'endLine' => 18,
'signature' => 'setBalance($balance)',
'startLine' => 11,
'endLine' => 18,
'executableLines' => 5,
'executedLines' => 0,
'ccn' => 2,
'coverage' => 0,
'crap' => 6,
'link' => 'BankAccount.php.html#11',
'methodName' => 'setBalance'
'executedLines' => 0,
'ccn' => 2,
'coverage' => 0,
'crap' => 6,
'link' => 'BankAccount.php.html#11',
'methodName' => 'setBalance'
),
'depositMoney' => array(
'signature' => 'depositMoney($balance)',
'startLine' => 20,
'endLine' => 25,
'signature' => 'depositMoney($balance)',
'startLine' => 20,
'endLine' => 25,
'executableLines' => 2,
'executedLines' => 2,
'ccn' => 1,
'coverage' => 100,
'crap' => '1',
'link' => 'BankAccount.php.html#20',
'methodName' => 'depositMoney'
'executedLines' => 2,
'ccn' => 1,
'coverage' => 100,
'crap' => '1',
'link' => 'BankAccount.php.html#20',
'methodName' => 'depositMoney'
),
'withdrawMoney' => array(
'signature' => 'withdrawMoney($balance)',
'startLine' => 27,
'endLine' => 32,
'signature' => 'withdrawMoney($balance)',
'startLine' => 27,
'endLine' => 32,
'executableLines' => 2,
'executedLines' => 2,
'ccn' => 1,
'coverage' => 100,
'crap' => '1',
'link' => 'BankAccount.php.html#27',
'methodName' => 'withdrawMoney'
'executedLines' => 2,
'ccn' => 1,
'coverage' => 100,
'crap' => '1',
'link' => 'BankAccount.php.html#27',
'methodName' => 'withdrawMoney'
),
),
'startLine' => 2,
'startLine' => 2,
'executableLines' => 10,
'executedLines' => 5,
'ccn' => 5,
'coverage' => 50,
'crap' => '8.12',
'package' => array(
'namespace' => '',
'executedLines' => 5,
'ccn' => 5,
'coverage' => 50,
'crap' => '8.12',
'package' => array(
'namespace' => '',
'fullPackage' => '',
'category' => '',
'package' => '',
'subpackage' => ''
'category' => '',
'package' => '',
'subpackage' => ''
),
'link' => 'BankAccount.php.html#2',
'link' => 'BankAccount.php.html#2',
'className' => 'BankAccount'
)
),
......@@ -146,7 +146,7 @@ public function testBuildDirectoryStructure()
$this->assertEquals(
array(
'src' => array(
'Money.php/f' => array(),
'Money.php/f' => array(),
'MoneyBag.php/f' => array()
)
),
......@@ -181,12 +181,12 @@ public function reducePathsProvider()
return array(
array(
array(
'Money.php' => array(),
'Money.php' => array(),
'MoneyBag.php' => array()
),
'/home/sb/Money',
array(
'/home/sb/Money/Money.php' => array(),
'/home/sb/Money/Money.php' => array(),
'/home/sb/Money/MoneyBag.php' => array()
)
),
......@@ -206,14 +206,14 @@ public function reducePathsProvider()
),
array(
array(
'Money.php' => array(),
'MoneyBag.php' => array(),
'Money.php' => array(),
'MoneyBag.php' => array(),
'Cash.phar/Cash.php' => array(),
),
'/home/sb/Money',
array(
'/home/sb/Money/Money.php' => array(),
'/home/sb/Money/MoneyBag.php' => array(),
'/home/sb/Money/Money.php' => array(),
'/home/sb/Money/MoneyBag.php' => array(),
'phar:///home/sb/Money/Cash.phar/Cash.php' => array(),
),
),
......
......@@ -276,10 +276,10 @@ public function testCollect()
$this->assertEquals(
array(
'BankAccountTest::testBalanceIsInitiallyZero' => array('size' => $size, 'status' => null),
'BankAccountTest::testBalanceCannotBecomeNegative' => array('size' => $size, 'status' => null),
'BankAccountTest::testBalanceIsInitiallyZero' => array('size' => $size, 'status' => null),
'BankAccountTest::testBalanceCannotBecomeNegative' => array('size' => $size, 'status' => null),
'BankAccountTest::testBalanceCannotBecomeNegative2' => array('size' => $size, 'status' => null),
'BankAccountTest::testDepositWithdrawMoney' => array('size' => $size, 'status' => null)
'BankAccountTest::testDepositWithdrawMoney' => array('size' => $size, 'status' => null)
),
$coverage->getTests()
);
......
......@@ -20,8 +20,8 @@ protected function getXdebugDataForBankAccount()
return array(
array(
TEST_FILES_PATH . 'BankAccount.php' => array(
8 => 1,
9 => -2,
8 => 1,
9 => -2,
13 => -1,
14 => -1,
15 => -1,
......@@ -37,7 +37,7 @@ protected function getXdebugDataForBankAccount()
),
array(
TEST_FILES_PATH . 'BankAccount.php' => array(
8 => 1,
8 => 1,
13 => 1,
16 => 1,
29 => 1,
......@@ -45,7 +45,7 @@ protected function getXdebugDataForBankAccount()
),
array(
TEST_FILES_PATH . 'BankAccount.php' => array(
8 => 1,
8 => 1,
13 => 1,
16 => 1,
22 => 1,
......@@ -53,7 +53,7 @@ protected function getXdebugDataForBankAccount()
),
array(
TEST_FILES_PATH . 'BankAccount.php' => array(
8 => 1,
8 => 1,
13 => 1,
14 => 1,
15 => 1,
......@@ -214,7 +214,7 @@ protected function getExpectedDataArrayForBankAccount()
0 => 'BankAccountTest::testBalanceIsInitiallyZero',
1 => 'BankAccountTest::testDepositWithdrawMoney'
),
9 => null,
9 => null,
13 => array(),
14 => array(),
15 => array(),
......
......@@ -6,7 +6,6 @@
*/
class CoverageTwoDefaultClassAnnotations
{
/**
* @covers Foo\CoveredClass::<public>
*/
......
......@@ -15,6 +15,6 @@ function &foo($bar)
{
$baz = function () {};
$a = true ? true : false;
$b = "{$a}";
$c = "${b}";
$b = "{$a}";
$c = "${b}";
}
......@@ -13,6 +13,6 @@ function &foo($bar)
{
$baz = function () {};
$a = true ? true : false;
$b = "{$a}";
$c = "${b}";
$b = "{$a}";
$c = "${b}";
}
......@@ -6,19 +6,24 @@ php:
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm
before_script:
matrix:
allow_failures:
- php: hhvm
sudo: false
before_install:
- composer self-update
- composer install --no-interaction --prefer-source --dev
install:
- travis_retry composer install --no-interaction --prefer-source
script:
- ./vendor/bin/phpunit --configuration ./build/phpunit.xml
matrix:
allow_failures:
- php: hhvm
notifications:
email: false
webhooks:
......
......@@ -352,8 +352,8 @@ protected function parse()
$this->classes = array();
$this->traits = array();
$this->functions = array();
$class = false;
$classEndLine = false;
$class = array();
$classEndLine = array();