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())
);
}
/**
......
......@@ -173,6 +173,7 @@ public function removeFileFromWhitelist($filename)
* Checks whether a filename is a real 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]);
}
}
}
}
......
......@@ -6,7 +6,6 @@
*/
class CoverageTwoDefaultClassAnnotations
{
/**
* @covers Foo\CoveredClass::<public>
*/
......
......@@ -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();
$trait = false;
$traitEndLine = false;
$interface = false;
......@@ -395,11 +395,11 @@ protected function parse()
);
if ($token instanceof PHP_Token_CLASS) {
$class = $token->getName();
$classEndLine = $token->getEndLine();
$class[] = $token->getName();
$classEndLine[] = $token->getEndLine();
if ($class != 'anonymous class') {
$this->classes[$class] = $tmp;
if ($class[count($class)-1] != 'anonymous class') {
$this->classes[$class[count($class)-1]] = $tmp;
}
} else {
$trait = $token->getName();
......@@ -421,7 +421,7 @@ protected function parse()
'file' => $this->filename
);
if ($class === false &&
if (empty($class) &&
$trait === false &&
$interface === false) {
$this->functions[$name] = $tmp;
......@@ -431,11 +431,11 @@ protected function parse()
$tmp['startLine'],
$tmp['endLine']
);
} elseif ($class !== false && $class != 'anonymous class') {
$this->classes[$class]['methods'][$name] = $tmp;
} elseif (!empty($class) && $class[count($class)-1] != 'anonymous class') {
$this->classes[$class[count($class)-1]]['methods'][$name] = $tmp;
$this->addFunctionToMap(
$class . '::' . $name,
$class[count($class)-1] . '::' . $name,
$tmp['startLine'],
$tmp['endLine']
);
......@@ -453,10 +453,10 @@ protected function parse()
break;
case 'PHP_Token_CLOSE_CURLY':
if ($classEndLine !== false &&
$classEndLine == $token->getLine()) {
$class = false;
$classEndLine = false;
if (!empty($classEndLine) &&
$classEndLine[count($classEndLine)-1] == $token->getLine()) {
array_pop($classEndLine);
array_pop($class);
} elseif ($traitEndLine !== false &&
$traitEndLine == $token->getLine()) {
$trait = false;
......
......@@ -93,4 +93,20 @@ public function testAnonymousClassesAreHandledCorrectly()
$this->assertEquals(array('class_with_method_that_declares_anonymous_class'), array_keys($classes));
}
/**
* @requires PHP 7
* @ticket https://github.com/sebastianbergmann/php-token-stream/issues/52
*/
public function testAnonymousClassesAreHandledCorrectly2()
{
$ts = new PHP_Token_Stream(TEST_FILES_PATH . 'class_with_method_that_declares_anonymous_class2.php');
$classes = $ts->getClasses();
$this->assertEquals(array('Test'), array_keys($classes));
$this->assertEquals(array('methodOne', 'methodTwo'), array_keys($classes['Test']['methods']));
$this->assertEmpty($ts->getFunctions());
}
}
<?php
class Test {
public function methodOne() {
$foo = new class {
public function method_in_anonymous_class() {
return true;
}
};
return $foo->method_in_anonymous_class();
}
public function methodTwo() {
return false;
}
}
......@@ -1110,7 +1110,7 @@ private function getClassMethods($className)
$methods = array();
foreach ($class->getMethods() as $method) {
if ($method->isPublic() || $method->isAbstract()) {
if (($method->isPublic() || $method->isAbstract()) && !in_array($method->getName(), $methods)) {
$methods[] = $method->getName();
}
}
......
......@@ -183,4 +183,18 @@ public function testGetMockForSingletonWithUnserializeFail()
$mock = $this->generator->getMock('SingletonClass', array('doSomething'), array(), '', false);
}
/**
* ReflectionClass::getMethods for SoapClient on PHP 5.3 produces PHP Fatal Error
* @runInSeparateProcess
*/
public function testGetMockForSoapClientReflectionMethodsDuplication()
{
if (version_compare(PHP_VERSION, '5.4.0', '>=')) {
$this->markTestSkipped('Only for PHP < 5.4.0');
}
$mock = $this->generator->getMock('SoapClient', array(), array(), '', false);
$this->assertInstanceOf('SoapClient', $mock);
}
}
<?php
$finder = Symfony\CS\Finder\DefaultFinder::create()
->files()
->in('build')
->in('src')
->in('tests')
->name('*.php')
->name('*.phpt');
return Symfony\CS\Config\Config::create()
->level(\Symfony\CS\FixerInterface::NONE_LEVEL)
->fixers(
array(
'duplicate_semicolon',
'empty_return',
'extra_empty_lines',
'join_function',
'list_commas',
'no_blank_lines_after_class_opening',
'no_empty_lines_after_phpdocs',
'phpdoc_indent',
'phpdoc_no_access',
'phpdoc_no_empty_return',
'phpdoc_no_package',
'phpdoc_params',
'phpdoc_scalar',
'phpdoc_to_comment',
'phpdoc_trim',
'return',
'self_accessor',
'single_quote',
'spaces_before_semicolon',
'spaces_cast',
'ternary_spaces',
'trim_array_spaces',
'unused_use',
'whitespacy_lines',
'align_double_arrow',
'align_equals',
'concat_with_spaces'
)
)
->finder($finder);
......@@ -24,7 +24,7 @@ install:
script:
- ./phpunit
- ./phpunit --configuration ./build/travis-ci-fail.xml > /dev/null; if [ $? -eq 0 ]; then echo "SHOULD FAIL"; exit 1; else echo "fail checked"; fi;
- ./phpunit --configuration ./build/travis-ci-fail.xml > /dev/null; if [ $? -eq 0 ]; then echo "SHOULD FAIL"; false; else echo "fail checked"; fi;
- xmllint --noout --schema phpunit.xsd phpunit.xml.dist
- xmllint --noout --schema phpunit.xsd tests/_files/configuration.xml
- xmllint --noout --schema phpunit.xsd tests/_files/configuration_empty.xml
......
# Contributing to PHPUnit
## Contributor Code of Conduct
Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.
## Workflow
* Fork the project.
* Make your bug fix or feature addition.
* Add tests for it. This is important so we don't break it in a future version unintentionally.
* Send a pull request. Bonus points for topic branches.
Pull requests for bug fixes must be based on the current stable branch whereas pull requests for new features must be based on `master`.
Please make sure that you have [set up your user name and email address](http://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup) for use with Git. Strings such as `silly nick name <root@localhost>` look really stupid in the commit history of a project.
Pull requests for bug fixes must be based on the current stable branch whereas pull requests for new features must be based on the current alpha branch (when `5.0` is the current stable branch, then `5.1` is the current beta branch and `5.2` is the current alpha branch).
We are trying to keep backwards compatibility breaks in PHPUnit to an absolute minimum. Please take this into account when proposing changes.
Due to time constraints, we are not always able to respond as quickly as we would like. Please do not take delays personal and feel free to remind us if you feel that we forgot to respond.
## Coding Guidelines
This project comes with a configuration file for [php-cs-fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer) (`.php_cs`) that you can use to (re)format your sourcecode for compliance with this project's coding guidelines:
```bash
$ wget http://get.sensiolabs.org/php-cs-fixer.phar
$ php php-cs-fixer.phar fix
```
## Using PHPUnit from a Git checkout
The following commands can be used to perform the initial checkout of PHPUnit:
git clone git://github.com/sebastianbergmann/phpunit.git
cd phpunit
```bash
$ git clone git://github.com/sebastianbergmann/phpunit.git
$ cd phpunit
```
Retrieve PHPUnit's dependencies using [Composer](http://getcomposer.org/):
wget http://getcomposer.org/composer.phar
php composer.phar install
```bash
$ wget http://getcomposer.org/composer.phar
$ php composer.phar install
```
The `phpunit` script can be used to invoke the PHPUnit test runner:
The `phpunit` script can be used to invoke the PHPUnit test runner.
```bash
$ ./phpunit --version
```