From fd99212904139dca8a4bef46cdeb2b2a8d721a8f Mon Sep 17 00:00:00 2001 From: Sam-Burns Date: Mon, 31 Jul 2017 14:07:48 +0100 Subject: [PATCH 01/57] Bumping PhpSpec version --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index b5794fd..ab41110 100644 --- a/composer.json +++ b/composer.json @@ -24,12 +24,12 @@ "docs": "https://github.com/leanphp/phpspec-code-coverage#phpspec-code-coverage" }, "require": { - "php": "~5.6||~7.0", - "phpspec/phpspec": "~3.0", + "php": "^7.0", + "phpspec/phpspec": "^4.0", "phpunit/php-code-coverage": "~4.0||~5.0" }, "require-dev": { - "bossa/phpspec2-expect": "~2.0" + "bossa/phpspec2-expect": "^3.0" }, "suggest": { "ext-xdebug": "Install Xdebug to generate phpspec code coverage if you are not using phpdbg" From ed2b2cf55e9c633a3032a10aa5adde49703e40e1 Mon Sep 17 00:00:00 2001 From: Sam-Burns Date: Mon, 31 Jul 2017 14:08:51 +0100 Subject: [PATCH 02/57] Removing PHP 5 build - version not supported by PhpSpec 4 --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 46b1f5d..2373b5f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,7 @@ language: php matrix: include: - - php: 5.6 - - php: 5.6 + - php: 7.0 env: deps=low - php: 7.0 - php: 7.1 From 414fbf48d2f6055add3774578e726f29edde1c53 Mon Sep 17 00:00:00 2001 From: Sam-Burns Date: Mon, 31 Jul 2017 14:16:24 +0100 Subject: [PATCH 03/57] Fix use of ConsoleIO --- spec/Listener/CodeCoverageListenerSpec.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/Listener/CodeCoverageListenerSpec.php b/spec/Listener/CodeCoverageListenerSpec.php index f465755..f8fbf40 100644 --- a/spec/Listener/CodeCoverageListenerSpec.php +++ b/spec/Listener/CodeCoverageListenerSpec.php @@ -38,6 +38,8 @@ function it_should_run_all_reports( 'php' => $php ); + $io->isVerbose()->willReturn(false); + $this->beConstructedWith($io, $coverage, $reports); $this->setOptions(array( 'format' => array('clover', 'php'), From 7f4816eff13ba55744103108acc9c04be9d58dd3 Mon Sep 17 00:00:00 2001 From: Sam-Burns Date: Mon, 31 Jul 2017 15:03:39 +0100 Subject: [PATCH 04/57] Adding reference to PhpSpec 4 to docs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index be5480c..10f2294 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ package with compatible version numbers for stable releases. - PHP 5.6+ or PHP 7+ - [Xdebug][3] or [phpdbg][4] extension enabled (PHP 7+ is required for code generation to work with [phpdbg][4]). -- [PhpSpec v3][2] +- [PhpSpec v3 or v4][2] ## Change Log From 668b9777ead9872a43d58bfa16a8f2feeb63294c Mon Sep 17 00:00:00 2001 From: ek9 Date: Tue, 17 Oct 2017 16:34:12 +0200 Subject: [PATCH 05/57] v4.0.0 - PhpSpec v4 and PHP 7+ - Update README, CHANGELOG + branch-alias --- CHANGELOG.md | 8 ++++++++ README.md | 3 +-- composer.json | 1 + 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bf0dbb..e854059 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,14 @@ documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [4.0.0] - 2017-10-17 - PhpSpec v4 / PHP 7+ release + +This release adds support for PhpSpec v4. As a result of this, PHP requirement +has also been updated to PHP 7+. + +- Added PhpSpec4 support #10 +- Extension requires PHP7+ (due to PhpSpec v4 depending on it) #10 + ## [3.1.1] - 2017-10-17 - Maintenance release for PhpSpec v3 - PHPSpec version is now included when generating XML report #12 diff --git a/README.md b/README.md index 46ca59a..e3a19da 100644 --- a/README.md +++ b/README.md @@ -19,10 +19,9 @@ package with compatible version numbers for stable releases. ## Requirements -- PHP 5.6+ or PHP 7+ +- PHP 7+ (for [PhpSpec][2] v4+) or PHP 5.6+ (for [PhpSpec][2] v3) - [Xdebug][3] or [phpdbg][4] extension enabled (PHP 7+ is required for code generation to work with [phpdbg][4]). -- [PhpSpec v3 or v4][2] ## Change Log diff --git a/composer.json b/composer.json index a8d4fe7..e135720 100644 --- a/composer.json +++ b/composer.json @@ -40,6 +40,7 @@ }, "extra": { "branch-alias": { + "dev-master": "4.x-dev", "dev-v3": "3.x-dev" } }, From 4b60b39b2f0d21be6338832b7d467b1955c9dbfd Mon Sep 17 00:00:00 2001 From: ek9 Date: Tue, 17 Oct 2017 16:43:27 +0200 Subject: [PATCH 06/57] CHANGELOG: fix link to v4.0.0 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e854059..89e059c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,7 @@ as [leanphp/phpspec-code-coverage][0]. - Support configuring a blacklist of files to be excluded from code coverage reports (`blaclist_files` option). +[4.0.0]: https://github.com/leanphp/phpspec-code-coverage/releases/tag/v4.0.0 [3.1.1]: https://github.com/leanphp/phpspec-code-coverage/releases/tag/v3.1.1 [3.1.0]: https://github.com/leanphp/phpspec-code-coverage/releases/tag/v3.1.0 [3.0.1]: https://github.com/leanphp/phpspec-code-coverage/releases/tag/v3.0.1 From cd1504da82140391f9c45eeeca10ece7bc42e6d9 Mon Sep 17 00:00:00 2001 From: ek9 Date: Tue, 17 Oct 2017 16:44:36 +0200 Subject: [PATCH 07/57] README: fix configuration option markdown syntax (links not working) --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e3a19da..189e9dd 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ extensions: This will sufficient to enable Code Coverage generation by using defaults provided by the extension. This extension supports various [configuration -options](#Configuration Options). For a fully annotated example configuration +options](#Options). For a fully annotated example configuration file check [Configuration section](#Configuration). ## Usage @@ -64,8 +64,7 @@ using more recent versions of PHP. Run `phpspec` via [phpdbg][4]: You can see fully annotated `phpspec.yml` example file below, which can be used as a starting point to further customize the defaults of the extension. The -configuration file below has all of the [Configuration Options](#Configuration -Options). +configuration file below has all of the [Configuration Options](#Options). ```yaml # phpspec.yml @@ -128,7 +127,7 @@ extensions: #- lib/bootstrap.php ``` -### Configuration Options +### Options * `format` (optional) a list of formats in which code coverage should be generated. Can be one or many of: `clover`, `php`, `text`, `html`, `xml` (default From 6a4ba6f2edfab32e27c55595f7513311c559600f Mon Sep 17 00:00:00 2001 From: ek9 Date: Wed, 18 Oct 2017 14:13:08 +0200 Subject: [PATCH 08/57] README: remove pre-release badge --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 189e9dd..a653679 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,6 @@ phpspec-code-coverage [![Total Downloads](https://img.shields.io/packagist/dt/leanphp/phpspec-code-coverage.svg?style=flat-square)](https://packagist.org/packages/leanphp/phpspec-code-coverage) [![Travis](https://img.shields.io/travis/leanphp/phpspec-code-coverage.svg?style=flat-square)](https://travis-ci.org/leanphp/phpspec-code-coverage) [![AppVeyor](https://img.shields.io/appveyor/ci/leanphp/phpspec-code-coverage/master.svg?style=flat-square)](https://ci.appveyor.com/project/leanphp/phpspec-code-coverage) -[![Pre Release](https://img.shields.io/packagist/vpre/leanphp/phpspec-code-coverage.svg?style=flat-square)](https://packagist.org/packages/leanphp/phpspec-code-coverage) [phpspec-code-coverage][0] is a [PhpSpec][2] extension that generates Code Coverage reports for [PhpSpec][2] tests. From 3401c37db1193cacc5d874799f49caa5d55168fb Mon Sep 17 00:00:00 2001 From: Anyqax Date: Sun, 19 Nov 2017 19:05:49 +0100 Subject: [PATCH 09/57] Fix composer phpunit/php-code-coverage requirement In commit a5ae5a66340ffd1c7892ae50d226252fb41248f9 a dependency for SebastianBergmann\CodeCoverage\Version was added which is only available since phpunit/php-code-coverage 5.0. This removes 4.0 from the allowed phpunit/php-code-coverage versions. --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e135720..47aa2f0 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ "require": { "php": "^7.0", "phpspec/phpspec": "^4.0", - "phpunit/php-code-coverage": "~4.0||~5.0" + "phpunit/php-code-coverage": "~5.0" }, "require-dev": { "bossa/phpspec2-expect": "^3.0" From 620141d458e8c824d2f42980118ce931187d4d73 Mon Sep 17 00:00:00 2001 From: Andrey Bolonin Date: Thu, 25 Jan 2018 17:57:34 +0200 Subject: [PATCH 10/57] Update .travis.yml --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 2373b5f..2894d95 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ matrix: env: deps=low - php: 7.0 - php: 7.1 + - php: 7.2 cache: directories: From 06aa4ded0026e29b9d6be134d26f99950652de17 Mon Sep 17 00:00:00 2001 From: ek9 Date: Sat, 17 Mar 2018 13:40:23 +0000 Subject: [PATCH 11/57] CHANGELOG.md update + add memory_limit info to README --- CHANGELOG.md | 8 ++++++++ README.md | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 89e059c..d068b49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,14 @@ documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [4.x.x] + +- `phpunit/php-code-coverage` dependency version requirement has been updated + from `~4.0|~5.0` to `~5.0` as we do not support version `4.0` anymore. +- Updated README with information regarding `memory_limit` when generating code + coverage reports. +- PHP 7.2 has been added to travis test matrix + ## [4.0.0] - 2017-10-17 - PhpSpec v4 / PHP 7+ release This release adds support for PhpSpec v4. As a result of this, PHP requirement diff --git a/README.md b/README.md index a653679..a042147 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,10 @@ If you execute `phpspec run` command, you will see code coverage generated in `c $ bin/phpspec run +**Note!** When generating Code Coverage reports make sure PHP processes run via +CLI are not memory limited (i.e. `memory_limit` set to `-1` in +`/etc/php/cli/php.ini`). + ### Running with phpdbg This extension now supports [phpdbg][4], which results in faster execution when From d9adb9993d2b3f039b7ad2b650f5b15cafd9aa4c Mon Sep 17 00:00:00 2001 From: ek9 Date: Sat, 17 Mar 2018 13:41:41 +0000 Subject: [PATCH 12/57] v4.1.0 --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d068b49..3bf2654 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## [4.x.x] +## [4.1.0] - 2018-03-17 - `phpunit/php-code-coverage` dependency version requirement has been updated from `~4.0|~5.0` to `~5.0` as we do not support version `4.0` anymore. @@ -75,6 +75,7 @@ as [leanphp/phpspec-code-coverage][0]. - Support configuring a blacklist of files to be excluded from code coverage reports (`blaclist_files` option). +[4.1.0]: https://github.com/leanphp/phpspec-code-coverage/releases/tag/v4.0.0 [4.0.0]: https://github.com/leanphp/phpspec-code-coverage/releases/tag/v4.0.0 [3.1.1]: https://github.com/leanphp/phpspec-code-coverage/releases/tag/v3.1.1 [3.1.0]: https://github.com/leanphp/phpspec-code-coverage/releases/tag/v3.1.0 From 889424ec7352331f8d1d6db37512c8a60876f975 Mon Sep 17 00:00:00 2001 From: ek9 Date: Sun, 18 Mar 2018 15:34:21 +0000 Subject: [PATCH 13/57] appveyor: update PHP test matrix --- .appveyor.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index 215be98..bb56608 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -5,7 +5,10 @@ platform: x64 clone_folder: c:\projects\behat-code-coverage environment: - PHP_DOWNLOAD_FILE: 'php-7.1.2-nts-Win32-VC14-x86.zip' + matrix: + - PHP_VERSION: "7.0" + - PHP_VERSION: "7.1" + - PHP_VERSION: "7.2" #branches: #only: From 37d33f1582c34ab5dd6efd4001e053ef4742e33d Mon Sep 17 00:00:00 2001 From: ek9 Date: Sun, 18 Mar 2018 15:37:05 +0000 Subject: [PATCH 14/57] appveyor: update PHP test matrix --- .appveyor.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index bb56608..687a4db 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -6,9 +6,11 @@ clone_folder: c:\projects\behat-code-coverage environment: matrix: - - PHP_VERSION: "7.0" - - PHP_VERSION: "7.1" - - PHP_VERSION: "7.2" + PHP_DOWNLOAD_FILE: 'php-7.0.27-nts-Win32-VC14-x86.zip' + PHP_DOWNLOAD_FILE: 'php-7.1.2-nts-Win32-VC14-x86.zip' + PHP_DOWNLOAD_FILE: 'php-7.2.2-nts-Win32-VC14-x86.zip' + + #branches: #only: From f72fb736adf06f010e21d72c89afb424134fadbc Mon Sep 17 00:00:00 2001 From: ek9 Date: Sun, 18 Mar 2018 15:37:33 +0000 Subject: [PATCH 15/57] appveyor: update PHP test matrix --- .appveyor.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 687a4db..49eb48e 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -6,9 +6,9 @@ clone_folder: c:\projects\behat-code-coverage environment: matrix: - PHP_DOWNLOAD_FILE: 'php-7.0.27-nts-Win32-VC14-x86.zip' - PHP_DOWNLOAD_FILE: 'php-7.1.2-nts-Win32-VC14-x86.zip' - PHP_DOWNLOAD_FILE: 'php-7.2.2-nts-Win32-VC14-x86.zip' + - PHP_DOWNLOAD_FILE: 'php-7.0.27-nts-Win32-VC14-x86.zip' + - PHP_DOWNLOAD_FILE: 'php-7.1.2-nts-Win32-VC14-x86.zip' + - PHP_DOWNLOAD_FILE: 'php-7.2.2-nts-Win32-VC14-x86.zip' From 1c7baf505fc68718ec4b5251e34d6aef382227bf Mon Sep 17 00:00:00 2001 From: ek9 Date: Sun, 18 Mar 2018 15:43:22 +0000 Subject: [PATCH 16/57] appveyor: update PHP test matrix --- .appveyor.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 49eb48e..2a69217 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -6,9 +6,9 @@ clone_folder: c:\projects\behat-code-coverage environment: matrix: - - PHP_DOWNLOAD_FILE: 'php-7.0.27-nts-Win32-VC14-x86.zip' - - PHP_DOWNLOAD_FILE: 'php-7.1.2-nts-Win32-VC14-x86.zip' - - PHP_DOWNLOAD_FILE: 'php-7.2.2-nts-Win32-VC14-x86.zip' + - PHP_DOWNLOAD_FILE: 'php-7.0.20-nts-Win32-VC14-x86.zip' + - PHP_DOWNLOAD_FILE: 'php-7.1.1-nts-Win32-VC14-x86.zip' + - PHP_DOWNLOAD_FILE: 'php-7.2.1-nts-Win32-VC14-x86.zip' From e5e24b1af086bb76838346b281c07ed67d45ea98 Mon Sep 17 00:00:00 2001 From: ek9 Date: Sun, 18 Mar 2018 15:44:19 +0000 Subject: [PATCH 17/57] appveyor: update PHP test matrix --- .appveyor.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 2a69217..9b5502d 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -5,12 +5,7 @@ platform: x64 clone_folder: c:\projects\behat-code-coverage environment: - matrix: - - PHP_DOWNLOAD_FILE: 'php-7.0.20-nts-Win32-VC14-x86.zip' - - PHP_DOWNLOAD_FILE: 'php-7.1.1-nts-Win32-VC14-x86.zip' - - PHP_DOWNLOAD_FILE: 'php-7.2.1-nts-Win32-VC14-x86.zip' - - + PHP_DOWNLOAD_FILE: 'php-7.2.2-nts-Win32-VC14-x86.zip' #branches: #only: From 5e1e0b5475edb0da0143849faacd49f36b70fa9c Mon Sep 17 00:00:00 2001 From: ek9 Date: Sun, 18 Mar 2018 16:00:01 +0000 Subject: [PATCH 18/57] appveyor: update testing script according to phpunit/phpunit --- .appveyor.yml | 71 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 48 insertions(+), 23 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 9b5502d..611906a 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -3,9 +3,27 @@ build: false shallow_clone: false platform: x64 clone_folder: c:\projects\behat-code-coverage +pull_requests: + do_not_increment_build_number: true environment: - PHP_DOWNLOAD_FILE: 'php-7.2.2-nts-Win32-VC14-x86.zip' + COMPOSER_ROOT_VERSION: '7.0-dev' + matrix: + - PHP_VERSION: '7.2.0-Win32-VC15-x86' + DEPENDENCIES: '--prefer-lowest' + XDEBUG_VERSION: '2.6.0-7.2-vc15' + - PHP_VERSION: '7.2.0-Win32-VC15-x86' + DEPENDENCIES: '' + XDEBUG_VERSION: '2.6.0-7.2-vc15' + - PHP_VERSION: '7.1.12-Win32-VC14-x86' + DEPENDENCIES: '--prefer-lowest' + XDEBUG_VERSION: '2.6.0-7.1-vc14' + - PHP_VERSION: '7.1.12-Win32-VC14-x86' + DEPENDENCIES: '' + XDEBUG_VERSION: '2.6.0-7.1-vc14' + +matrix: + fast_finish: true #branches: #only: @@ -14,40 +32,47 @@ environment: skip_commits: message: /\[ci skip\]/ - #cache: - #- c:\php -> appveyor.yml - #- c:\php\composer.bat +cache: + - c:\php -> appveyor.yml + - '%LOCALAPPDATA%\Composer\files' init: - - SET PATH=c:\php;%PATH% + - SET PATH=c:\php\%PHP_VERSION%;%PATH% - SET COMPOSER_NO_INTERACTION=1 - SET PHP=1 - SET ANSICON=121x90 (121x90) - git config --global core.autocrlf input install: - - IF EXIST c:\php (SET PHP=0) ELSE (mkdir c:\php) - - cd c:\php - - IF %PHP%==1 appveyor DownloadFile http://windows.php.net/downloads/releases/archives/%PHP_DOWNLOAD_FILE% - - IF %PHP%==1 7z x %PHP_DOWNLOAD_FILE% -y > 7z.log - - IF %PHP%==1 echo @php %%~dp0composer.phar %%* > composer.bat - - appveyor DownloadFile https://getcomposer.org/composer.phar - - copy php.ini-production php.ini /Y - - echo date.timezone="UTC" >> php.ini - - echo extension_dir=ext >> php.ini - - echo extension=php_openssl.dll >> php.ini - - echo extension=php_curl.dll >> php.ini - - echo extension=php_mbstring.dll >> php.ini - - echo extension=php_fileinfo.dll >> php.ini - # Xdebug - - IF %PHP%==1 appveyor DownloadFile https://xdebug.org/files/php_xdebug-2.5.1-7.1-vc14-nts-x86_64.dll - - mv php_xdebug-2.5.1-7.1-vc14-nts-x86_64.dll ext\ - - echo zend_extension="php_xdebug-2.5.1-7.1-vc14-nts-x86_64.dll" >> php.ini + - IF NOT EXIST c:\php mkdir c:\php + - IF NOT EXIST c:\php\%PHP_VERSION% mkdir c:\php\%PHP_VERSION% + - cd c:\php\%PHP_VERSION% + - IF NOT EXIST php-installed.txt appveyor DownloadFile http://windows.php.net/downloads/releases/archives/php-%PHP_VERSION%.zip + - IF NOT EXIST php-installed.txt 7z x php-%PHP_VERSION%.zip -y >nul + - IF NOT EXIST php-installed.txt del /Q *.zip + - IF NOT EXIST php-installed.txt copy /Y php.ini-development php.ini + - IF NOT EXIST php-installed.txt echo max_execution_time=1200 >> php.ini + - IF NOT EXIST php-installed.txt echo date.timezone="UTC" >> php.ini + - IF NOT EXIST php-installed.txt echo extension_dir=ext >> php.ini + - IF NOT EXIST php-installed.txt echo extension=php_curl.dll >> php.ini + - IF NOT EXIST php-installed.txt echo extension=php_openssl.dll >> php.ini + - IF NOT EXIST php-installed.txt echo extension=php_mbstring.dll >> php.ini + - IF NOT EXIST php-installed.txt echo extension=php_fileinfo.dll >> php.ini + - IF NOT EXIST php-installed.txt echo extension=php_mysqli.dll >> php.ini + - IF NOT EXIST php-installed.txt echo extension=php_pdo_sqlite.dll >> php.ini + - IF NOT EXIST php-installed.txt echo zend.assertions=1 >> php.ini + - IF NOT EXIST php-installed.txt echo assert.exception=On >> php.ini + - IF NOT EXIST php-installed.txt appveyor DownloadFile https://getcomposer.org/composer.phar + - IF NOT EXIST php-installed.txt echo @php %%~dp0composer.phar %%* > composer.bat + - IF NOT EXIST php-installed.txt type nul >> php-installed.txt + - IF %PHP%==1 appveyor DownloadFile https://xdebug.org/files/php_xdebug-%XDEBUG_VERSION%.dll + - mv php_xdebug-%XDEBUG_VERSION%.dll ext\ + - echo zend_extension="php_xdebug-%XDEBUG_VERSION%.dll" >> php.ini - echo xdebug.remote_enable=true >> php.ini - echo xdebug.remote_autostart=true >> php.ini - cd c:\projects\behat-code-coverage - composer self-update - - composer install --no-progress --ansi + - composer install --no-progress --no-ansi --no-interaction --no-suggest --optimize-autoloader --prefer-stable %DEPENDENCIES% test_script: - cd c:\projects\behat-code-coverage From 7d0be2335fa5a2e2b67325b931a3aa4c401ddc13 Mon Sep 17 00:00:00 2001 From: ek9 Date: Sun, 18 Mar 2018 16:03:44 +0000 Subject: [PATCH 19/57] appveyor: use https to download --- .appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index 611906a..a3626b6 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -47,7 +47,7 @@ install: - IF NOT EXIST c:\php mkdir c:\php - IF NOT EXIST c:\php\%PHP_VERSION% mkdir c:\php\%PHP_VERSION% - cd c:\php\%PHP_VERSION% - - IF NOT EXIST php-installed.txt appveyor DownloadFile http://windows.php.net/downloads/releases/archives/php-%PHP_VERSION%.zip + - IF NOT EXIST php-installed.txt appveyor DownloadFile https://windows.php.net/downloads/releases/archives/php-%PHP_VERSION%.zip - IF NOT EXIST php-installed.txt 7z x php-%PHP_VERSION%.zip -y >nul - IF NOT EXIST php-installed.txt del /Q *.zip - IF NOT EXIST php-installed.txt copy /Y php.ini-development php.ini From 8707c4b35cf95d431048d5791a22e9fd4cdb6155 Mon Sep 17 00:00:00 2001 From: ek9 Date: Sun, 18 Mar 2018 16:05:48 +0000 Subject: [PATCH 20/57] appveyor: use curl to download --- .appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index a3626b6..901ded9 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -47,7 +47,7 @@ install: - IF NOT EXIST c:\php mkdir c:\php - IF NOT EXIST c:\php\%PHP_VERSION% mkdir c:\php\%PHP_VERSION% - cd c:\php\%PHP_VERSION% - - IF NOT EXIST php-installed.txt appveyor DownloadFile https://windows.php.net/downloads/releases/archives/php-%PHP_VERSION%.zip + - IF NOT EXIST php-installed.txt curl -fsS -o php-%PHP_VERSION%.zip https://windows.php.net/downloads/releases/archives/php-%PHP_VERSION%.zip - IF NOT EXIST php-installed.txt 7z x php-%PHP_VERSION%.zip -y >nul - IF NOT EXIST php-installed.txt del /Q *.zip - IF NOT EXIST php-installed.txt copy /Y php.ini-development php.ini From 5b84237e73cb3edd2bcf576f43c5eb4db0589f8b Mon Sep 17 00:00:00 2001 From: ek9 Date: Sun, 18 Mar 2018 16:07:20 +0000 Subject: [PATCH 21/57] appveyor: fix composer argument --- .appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index 901ded9..a87658c 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -72,7 +72,7 @@ install: - echo xdebug.remote_autostart=true >> php.ini - cd c:\projects\behat-code-coverage - composer self-update - - composer install --no-progress --no-ansi --no-interaction --no-suggest --optimize-autoloader --prefer-stable %DEPENDENCIES% + - composer install --no-progress --no-ansi --no-interaction --no-suggest --optimize-autoloader --prefer-dist %DEPENDENCIES% test_script: - cd c:\projects\behat-code-coverage From c84b2fa9b7ea049fb4b47ad35bbf102c14d21e63 Mon Sep 17 00:00:00 2001 From: ek9 Date: Sun, 18 Mar 2018 16:11:04 +0000 Subject: [PATCH 22/57] appveoyr: fix --prefer-lowest --- .appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index a87658c..a44d050 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -72,7 +72,7 @@ install: - echo xdebug.remote_autostart=true >> php.ini - cd c:\projects\behat-code-coverage - composer self-update - - composer install --no-progress --no-ansi --no-interaction --no-suggest --optimize-autoloader --prefer-dist %DEPENDENCIES% + - composer update --no-progress --no-ansi --no-interaction --no-suggest --optimize-autoloader --prefer-stable %DEPENDENCIES% test_script: - cd c:\projects\behat-code-coverage From daf107a4074efd6e3526e041f5b4a9ef821cc41f Mon Sep 17 00:00:00 2001 From: ek9 Date: Sun, 18 Mar 2018 16:22:31 +0000 Subject: [PATCH 23/57] fix minimum dependency --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 47aa2f0..795c8b9 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,8 @@ "require": { "php": "^7.0", "phpspec/phpspec": "^4.0", - "phpunit/php-code-coverage": "~5.0" + "phpunit/php-code-coverage": "~5.0", + "sebastian/comparator": "~2.0" }, "require-dev": { "bossa/phpspec2-expect": "^3.0" From e10ae4c01a0a5628b9523332f286d1c83a5ea205 Mon Sep 17 00:00:00 2001 From: ek9 Date: Sun, 18 Mar 2018 16:23:37 +0000 Subject: [PATCH 24/57] appveyor: run standard tests before lowdep tests --- .appveyor.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index a44d050..83e553c 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -10,16 +10,16 @@ environment: COMPOSER_ROOT_VERSION: '7.0-dev' matrix: - PHP_VERSION: '7.2.0-Win32-VC15-x86' - DEPENDENCIES: '--prefer-lowest' + DEPENDENCIES: '' XDEBUG_VERSION: '2.6.0-7.2-vc15' - PHP_VERSION: '7.2.0-Win32-VC15-x86' - DEPENDENCIES: '' + DEPENDENCIES: '--prefer-lowest' XDEBUG_VERSION: '2.6.0-7.2-vc15' - PHP_VERSION: '7.1.12-Win32-VC14-x86' - DEPENDENCIES: '--prefer-lowest' + DEPENDENCIES: '' XDEBUG_VERSION: '2.6.0-7.1-vc14' - PHP_VERSION: '7.1.12-Win32-VC14-x86' - DEPENDENCIES: '' + DEPENDENCIES: '--prefer-lowest' XDEBUG_VERSION: '2.6.0-7.1-vc14' matrix: From b0d82fe1f47f16c1381977bff44143ff33a38c83 Mon Sep 17 00:00:00 2001 From: ek9 Date: Sun, 18 Mar 2018 16:34:55 +0000 Subject: [PATCH 25/57] appveyor: update dir structure to phpspec-code-coverage --- .appveyor.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 83e553c..131de7a 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -2,7 +2,7 @@ version: '{branch}-{build}' build: false shallow_clone: false platform: x64 -clone_folder: c:\projects\behat-code-coverage +clone_folder: c:\projects\phpspec-code-coverage pull_requests: do_not_increment_build_number: true @@ -70,11 +70,11 @@ install: - echo zend_extension="php_xdebug-%XDEBUG_VERSION%.dll" >> php.ini - echo xdebug.remote_enable=true >> php.ini - echo xdebug.remote_autostart=true >> php.ini - - cd c:\projects\behat-code-coverage + - cd c:\projects\phpspec-code-coverage - composer self-update - composer update --no-progress --no-ansi --no-interaction --no-suggest --optimize-autoloader --prefer-stable %DEPENDENCIES% test_script: - - cd c:\projects\behat-code-coverage + - cd c:\projects\phpspec-code-coverage - phpdbg -qrr vendor\phpspec\phpspec\bin\phpspec run -vvv From 42cfd2ce55195e6b64dd86822dfbddae9be68ca4 Mon Sep 17 00:00:00 2001 From: ek9 Date: Sun, 18 Mar 2018 23:24:27 +0000 Subject: [PATCH 26/57] add --skip-coverage - fixes #11 related to PR #20 --- CHANGELOG.md | 8 +++++++- README.md | 2 +- src/CodeCoverageExtension.php | 19 ++++++++++++++++++- src/Listener/CodeCoverageListener.php | 4 ++-- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bf2654..1ae7233 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [4.1.1] - 2018-03-18 + +- Added `--skip-coverage` option which can skip code coverage generation during + PhpSpec test run. + ## [4.1.0] - 2018-03-17 - `phpunit/php-code-coverage` dependency version requirement has been updated @@ -75,7 +80,8 @@ as [leanphp/phpspec-code-coverage][0]. - Support configuring a blacklist of files to be excluded from code coverage reports (`blaclist_files` option). -[4.1.0]: https://github.com/leanphp/phpspec-code-coverage/releases/tag/v4.0.0 +[4.1.1]: https://github.com/leanphp/phpspec-code-coverage/releases/tag/v4.1.1 +[4.1.0]: https://github.com/leanphp/phpspec-code-coverage/releases/tag/v4.1.0 [4.0.0]: https://github.com/leanphp/phpspec-code-coverage/releases/tag/v4.0.0 [3.1.1]: https://github.com/leanphp/phpspec-code-coverage/releases/tag/v3.1.1 [3.1.0]: https://github.com/leanphp/phpspec-code-coverage/releases/tag/v3.1.0 diff --git a/README.md b/README.md index a042147..f74e5e7 100644 --- a/README.md +++ b/README.md @@ -155,7 +155,7 @@ extensions: ## Authors -Copyright (c) 2017 ek9 (https://ek9.co). +Copyright (c) 2017-2018 ek9 (https://ek9.co). Copyright (c) 2013-2016 Henrik Bjornskov, for portions of code from [henrikbjorn/phpspec-code-coverage][1] project. diff --git a/src/CodeCoverageExtension.php b/src/CodeCoverageExtension.php index 4cca90d..07dd9fc 100644 --- a/src/CodeCoverageExtension.php +++ b/src/CodeCoverageExtension.php @@ -8,6 +8,7 @@ use SebastianBergmann\CodeCoverage\Filter; use SebastianBergmann\CodeCoverage\Report; use SebastianBergmann\CodeCoverage\Version; +use Symfony\Component\Console\Input\InputOption; /** * Injects a Event Subscriber into the EventDispatcher. @@ -22,6 +23,13 @@ class CodeCoverageExtension implements \PhpSpec\Extension */ public function load(ServiceContainer $container, array $params = []) { + foreach ($container->getByTag('console.commands') as $command) { + if ($command->getName() == 'run') { + $command->addOption('skip-coverage', null, InputOption::VALUE_NONE, 'Skip code coverage generation'); + } + } + + $container->define('code_coverage.filter', function () { return new Filter(); }); @@ -96,10 +104,19 @@ public function load(ServiceContainer $container, array $params = []) }); $container->define('event_dispatcher.listeners.code_coverage', function ($container) { + + $skipCoverage = false; + $input = $container->get('console.input'); + if ($input->getOption('skip-coverage')) { + $skipCoverage = true; + } + + $listener = new CodeCoverageListener( $container->get('console.io'), $container->get('code_coverage'), - $container->get('code_coverage.reports') + $container->get('code_coverage.reports'), + $skipCoverage ); $listener->setOptions($container->getParam('code_coverage', array())); diff --git a/src/Listener/CodeCoverageListener.php b/src/Listener/CodeCoverageListener.php index 240401f..46ae252 100644 --- a/src/Listener/CodeCoverageListener.php +++ b/src/Listener/CodeCoverageListener.php @@ -20,7 +20,7 @@ class CodeCoverageListener implements EventSubscriberInterface private $options; private $enabled; - public function __construct(ConsoleIO $io, CodeCoverage $coverage, array $reports) + public function __construct(ConsoleIO $io, CodeCoverage $coverage, array $reports, $skipCoverage = false) { $this->io = $io; $this->coverage = $coverage; @@ -34,7 +34,7 @@ public function __construct(ConsoleIO $io, CodeCoverage $coverage, array $report 'format' => array('html'), ); - $this->enabled = extension_loaded('xdebug') || (PHP_SAPI === 'phpdbg'); + $this->enabled = !$skipCoverage && (extension_loaded('xdebug') || (PHP_SAPI === 'phpdbg')); } /** From 48f6630af1adbba9c6fa135c9ab917e0435a8fa9 Mon Sep 17 00:00:00 2001 From: ek9 Date: Sun, 18 Mar 2018 23:30:27 +0000 Subject: [PATCH 27/57] rename --skip-coverage to --no-coverage this makes it compatible to phpunit v6/v7 --- CHANGELOG.md | 2 +- src/CodeCoverageExtension.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ae7233..52551d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [4.1.1] - 2018-03-18 -- Added `--skip-coverage` option which can skip code coverage generation during +- Added `--no-coverage` option which can skip code coverage generation during PhpSpec test run. ## [4.1.0] - 2018-03-17 diff --git a/src/CodeCoverageExtension.php b/src/CodeCoverageExtension.php index 07dd9fc..e275c01 100644 --- a/src/CodeCoverageExtension.php +++ b/src/CodeCoverageExtension.php @@ -25,7 +25,7 @@ public function load(ServiceContainer $container, array $params = []) { foreach ($container->getByTag('console.commands') as $command) { if ($command->getName() == 'run') { - $command->addOption('skip-coverage', null, InputOption::VALUE_NONE, 'Skip code coverage generation'); + $command->addOption('no-coverage', null, InputOption::VALUE_NONE, 'Skip code coverage generation'); } } @@ -107,7 +107,7 @@ public function load(ServiceContainer $container, array $params = []) $skipCoverage = false; $input = $container->get('console.input'); - if ($input->getOption('skip-coverage')) { + if ($input->getOption('no-coverage')) { $skipCoverage = true; } From e1e9e0429ef86c90e867af87bce2040e04a86d30 Mon Sep 17 00:00:00 2001 From: ek9 Date: Sun, 18 Mar 2018 23:46:32 +0000 Subject: [PATCH 28/57] v4.1.1 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52551d8..6208f6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## [4.1.1] - 2018-03-18 +## [4.1.1] - 2018-03-19 - Added `--no-coverage` option which can skip code coverage generation during PhpSpec test run. From 25c2bdc066b100e6c6ba5e4a8bc5dcc6d57edfb2 Mon Sep 17 00:00:00 2001 From: ek9 Date: Sun, 18 Mar 2018 22:40:04 +0000 Subject: [PATCH 29/57] update phpunit/php-code-coverage to ~6.0 additionally disable broken phpspec test --- CHANGELOG.md | 4 ++++ composer.json | 2 +- spec/Listener/CodeCoverageListenerSpec.php | 7 +++++++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6208f6b..43b5a06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## 4.2.x-dev - 2018-03-19 + +- Updated `phpunit/php-code-coverage` dependency from `~5.0` to `~6.0`. + ## [4.1.1] - 2018-03-19 - Added `--no-coverage` option which can skip code coverage generation during diff --git a/composer.json b/composer.json index 795c8b9..c5a6a66 100644 --- a/composer.json +++ b/composer.json @@ -26,8 +26,8 @@ "require": { "php": "^7.0", "phpspec/phpspec": "^4.0", - "phpunit/php-code-coverage": "~5.0", "sebastian/comparator": "~2.0" + "phpunit/php-code-coverage": "~6.0" }, "require-dev": { "bossa/phpspec2-expect": "^3.0" diff --git a/spec/Listener/CodeCoverageListenerSpec.php b/spec/Listener/CodeCoverageListenerSpec.php index f8fbf40..e95a5d7 100644 --- a/spec/Listener/CodeCoverageListenerSpec.php +++ b/spec/Listener/CodeCoverageListenerSpec.php @@ -15,6 +15,12 @@ */ class CodeCoverageListenerSpec extends ObjectBehavior { + /** + * Disabled due to tests breaking as php-code-coverage marked their classes + * final and we cannot mock them. The tests should be converted into proper + * functional (integration) tests instead. This file is left for reference. + * + * @see https://github.com/leanphp/phpspec-code-coverage/issues/19 function let(ConsoleIO $io, CodeCoverage $coverage) { $this->beConstructedWith($io, $coverage, array()); @@ -176,4 +182,5 @@ function it_should_correctly_handle_black_listed_files_and_directories( $this->beforeSuite($event); } + */ } From ca62343266d78faff6d6ab6b72489d198db31240 Mon Sep 17 00:00:00 2001 From: ek9 Date: Sun, 18 Mar 2018 22:45:55 +0000 Subject: [PATCH 30/57] composer.json typo fix --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c5a6a66..f145fa3 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ "require": { "php": "^7.0", "phpspec/phpspec": "^4.0", - "sebastian/comparator": "~2.0" + "sebastian/comparator": "~2.0", "phpunit/php-code-coverage": "~6.0" }, "require-dev": { From 1e8d489831dbbd6c0d344f060561773ace720259 Mon Sep 17 00:00:00 2001 From: ek9 Date: Sun, 18 Mar 2018 22:49:13 +0000 Subject: [PATCH 31/57] travis: remove PHP 7.0 from test matrix --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2894d95..a4026db 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,8 @@ language: php matrix: include: - - php: 7.0 - env: deps=low - - php: 7.0 - php: 7.1 + env: deps=low - php: 7.2 cache: From 1f5d6251116e980997924af414160dc30e4e19d0 Mon Sep 17 00:00:00 2001 From: ek9 Date: Sun, 18 Mar 2018 22:51:09 +0000 Subject: [PATCH 32/57] v4.2.0 - PHP 7.1, phpspec 4.2, php-code-coverage 6.0 --- CHANGELOG.md | 2 ++ composer.json | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 43b5a06..4d105ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## 4.2.x-dev - 2018-03-19 - Updated `phpunit/php-code-coverage` dependency from `~5.0` to `~6.0`. +- Updated PHP requirement from `^7.0` to `^7.1` +- Updated `phpspec/phpspec` dependency from `~4.0` to `^4.2` ## [4.1.1] - 2018-03-19 diff --git a/composer.json b/composer.json index f145fa3..2e6e6d8 100644 --- a/composer.json +++ b/composer.json @@ -24,9 +24,8 @@ "docs": "https://github.com/leanphp/phpspec-code-coverage#phpspec-code-coverage" }, "require": { - "php": "^7.0", - "phpspec/phpspec": "^4.0", - "sebastian/comparator": "~2.0", + "php": "^7.1", + "phpspec/phpspec": "^4.2", "phpunit/php-code-coverage": "~6.0" }, "require-dev": { From 4788c9ffe5db139df46c83bdc94f4c0f3e16b7fb Mon Sep 17 00:00:00 2001 From: ek9 Date: Sun, 18 Mar 2018 22:52:27 +0000 Subject: [PATCH 33/57] travis: have depslow tests for both PHP 7.1 and 7.2 --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index a4026db..239be55 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,13 @@ language: php matrix: include: + - php: 7.1 - php: 7.1 env: deps=low - php: 7.2 + - php: 7.2 + env: deps=low + cache: directories: From 824abcb84718a04eba08aeaf60b28472f7437a7e Mon Sep 17 00:00:00 2001 From: ek9 Date: Sun, 18 Mar 2018 23:39:43 +0000 Subject: [PATCH 34/57] appveyor: mkdir build/coverage if not exists --- .appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.appveyor.yml b/.appveyor.yml index 131de7a..bfccf75 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -71,6 +71,7 @@ install: - echo xdebug.remote_enable=true >> php.ini - echo xdebug.remote_autostart=true >> php.ini - cd c:\projects\phpspec-code-coverage + - IF NOT EXIST build\coverage mkdir build\coverage - composer self-update - composer update --no-progress --no-ansi --no-interaction --no-suggest --optimize-autoloader --prefer-stable %DEPENDENCIES% From 71b160683e9a87f880dadb7a7201642abf3c1b54 Mon Sep 17 00:00:00 2001 From: ek9 Date: Sun, 18 Mar 2018 23:57:31 +0000 Subject: [PATCH 35/57] Add examples to readme - fix #5 --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index f74e5e7..1abcd33 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,9 @@ used as a single metric defining how good your tests are. **Note!** This is a maintained fork of [henrikbjorn/phpspec-code-coverage][1] package with compatible version numbers for stable releases. +![phpspec-code-coverage console report](https://i.imgur.com/BU10ZAV.png) +![phpspec-code-coverage HTML report](https://i.imgur.com/AcoJ5.png) + ## Requirements - PHP 7+ (for [PhpSpec][2] v4+) or PHP 5.6+ (for [PhpSpec][2] v3) From ef87a93a7c2443a889b786f055b85e476a694c1a Mon Sep 17 00:00:00 2001 From: ek9 Date: Sun, 18 Mar 2018 23:58:22 +0000 Subject: [PATCH 36/57] Add examples to readme - fix #5 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1abcd33..abcf0a8 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ used as a single metric defining how good your tests are. package with compatible version numbers for stable releases. ![phpspec-code-coverage console report](https://i.imgur.com/BU10ZAV.png) -![phpspec-code-coverage HTML report](https://i.imgur.com/AcoJ5.png) +![phpspec-code-coverage HTML report](https://i.imgur.com/6xAcoJ5.png) ## Requirements From 9bcf320740c2bacb6e9ad6f17178f5b078dab36d Mon Sep 17 00:00:00 2001 From: ek9 Date: Sun, 18 Mar 2018 23:59:26 +0000 Subject: [PATCH 37/57] Add examples to readme - fix #5 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index abcf0a8..a186540 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ used as a single metric defining how good your tests are. package with compatible version numbers for stable releases. ![phpspec-code-coverage console report](https://i.imgur.com/BU10ZAV.png) -![phpspec-code-coverage HTML report](https://i.imgur.com/6xAcoJ5.png) +![phpspec-code-coverage HTML report](https://i.imgur.com/6xACR1g.png) ## Requirements From 803d56d2d7114445191a105aa6d4b3d26f9c6365 Mon Sep 17 00:00:00 2001 From: ek9 Date: Mon, 19 Mar 2018 00:17:28 +0000 Subject: [PATCH 38/57] v4.2.0 --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d105ac..3b4a972 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## 4.2.x-dev - 2018-03-19 +## [4.2.0] - 2018-03-19 - Updated `phpunit/php-code-coverage` dependency from `~5.0` to `~6.0`. - Updated PHP requirement from `^7.0` to `^7.1` @@ -86,6 +86,7 @@ as [leanphp/phpspec-code-coverage][0]. - Support configuring a blacklist of files to be excluded from code coverage reports (`blaclist_files` option). +[4.2.0]: https://github.com/leanphp/phpspec-code-coverage/releases/tag/v4.2.0 [4.1.1]: https://github.com/leanphp/phpspec-code-coverage/releases/tag/v4.1.1 [4.1.0]: https://github.com/leanphp/phpspec-code-coverage/releases/tag/v4.1.0 [4.0.0]: https://github.com/leanphp/phpspec-code-coverage/releases/tag/v4.0.0 From 3fc727b56e1b9d6c7891269f2cd3ceb3a41c323c Mon Sep 17 00:00:00 2001 From: ek9 Date: Mon, 19 Mar 2018 12:43:52 +0000 Subject: [PATCH 39/57] Add Symfony Coding Standard & PHP CodeSniffer to require-dev #21 - Add `escapestudios/symfony2-coding-standard` to require-dev - Add `squizlabs/php_codesniffer` to require-dev - Add `phpcs.xml` as a default PHP CodeSniffer configuration --- composer.json | 4 +++- phpcs.xml | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 phpcs.xml diff --git a/composer.json b/composer.json index 2e6e6d8..cfebd2e 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,9 @@ "phpunit/php-code-coverage": "~6.0" }, "require-dev": { - "bossa/phpspec2-expect": "^3.0" + "bossa/phpspec2-expect": "^3.0", + "escapestudios/symfony2-coding-standard": "^3.1", + "squizlabs/php_codesniffer": "^3.2" }, "suggest": { "ext-xdebug": "Install Xdebug to generate phpspec code coverage if you are not using phpdbg" diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..0498173 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,20 @@ + + + + LeanPHP Coding Standard + + + src + + + test + tests + *Spec.php + + + + > + + + + From 94fe5388f118c777e66093dfae931df7e6f68315 Mon Sep 17 00:00:00 2001 From: ek9 Date: Mon, 19 Mar 2018 12:46:39 +0000 Subject: [PATCH 40/57] Add PHP CodeSniffer to travis & appveyor --- .appveyor.yml | 3 ++- .travis.yml | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index bfccf75..dc9f293 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -77,5 +77,6 @@ install: test_script: - cd c:\projects\phpspec-code-coverage - - phpdbg -qrr vendor\phpspec\phpspec\bin\phpspec run -vvv + - bin\phpcs + - phpdbg -qrr vendor\phpspec\phpspec\bin\phpspec run --no-code-generation -vvv diff --git a/.travis.yml b/.travis.yml index 239be55..0dca4cb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,7 @@ before_script: script: - composer validate - composer update + - bin/phpcs - bin/phpspec run --no-code-generation install: From c6019029275abe9438760474fd13ff3daffe2781 Mon Sep 17 00:00:00 2001 From: ek9 Date: Mon, 19 Mar 2018 13:08:03 +0000 Subject: [PATCH 41/57] Fix Code Styling errors (Add PHP Docblock + minor cleanup) --- src/CodeCoverageExtension.php | 14 ++++++++++--- src/Listener/CodeCoverageListener.php | 29 ++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/CodeCoverageExtension.php b/src/CodeCoverageExtension.php index e275c01..b557c8c 100644 --- a/src/CodeCoverageExtension.php +++ b/src/CodeCoverageExtension.php @@ -1,5 +1,12 @@ getByTag('console.commands') as $command) { - if ($command->getName() == 'run') { + if ($command->getName() === 'run') { $command->addOption('no-coverage', null, InputOption::VALUE_NONE, 'Skip code coverage generation'); } } @@ -48,7 +55,7 @@ public function load(ServiceContainer $container, array $params = []) } if (isset($options['output'])) { - if (!is_array($options['output']) && count($options['format']) == 1) { + if (!is_array($options['output']) && count($options['format']) === 1) { $format = $options['format'][0]; $options['output'] = array($format => $options['output']); } @@ -100,6 +107,7 @@ public function load(ServiceContainer $container, array $params = []) } $container->setParam('code_coverage', $options); + return $reports; }); diff --git a/src/Listener/CodeCoverageListener.php b/src/Listener/CodeCoverageListener.php index 46ae252..c743119 100644 --- a/src/Listener/CodeCoverageListener.php +++ b/src/Listener/CodeCoverageListener.php @@ -1,5 +1,12 @@ io = $io; @@ -40,6 +53,8 @@ public function __construct(ConsoleIO $io, CodeCoverage $coverage, array $report /** * Note: We use array_map() instead of array_walk() because the latter expects * the callback to take the value as the first and the index as the seconds parameter. + * + * @param SuiteEvent $event */ public function beforeSuite(SuiteEvent $event) { @@ -67,6 +82,9 @@ public function beforeSuite(SuiteEvent $event) ); } + /** + * @param ExampleEvent $event + */ public function beforeExample(ExampleEvent $event) { if (!$this->enabled) { @@ -83,6 +101,9 @@ public function beforeExample(ExampleEvent $event) $this->coverage->start($name); } + /** + * @param ExampleEvent $event + */ public function afterExample(ExampleEvent $event) { if (!$this->enabled) { @@ -92,6 +113,9 @@ public function afterExample(ExampleEvent $event) $this->coverage->stop(); } + /** + * @param SuiteEvent $event + */ public function afterSuite(SuiteEvent $event) { if (!$this->enabled) { @@ -120,6 +144,9 @@ public function afterSuite(SuiteEvent $event) } } + /** + * @param [] $options + */ public function setOptions(array $options) { $this->options = $options + $this->options; From 36d3e3426e4534cb2bdad1f83ea9f152b16e2117 Mon Sep 17 00:00:00 2001 From: Scrutinizer Auto-Fixer Date: Mon, 19 Mar 2018 13:39:37 +0000 Subject: [PATCH 42/57] Scrutinizer Auto-Fixes This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com --- src/CodeCoverageExtension.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/CodeCoverageExtension.php b/src/CodeCoverageExtension.php index b557c8c..0cb6b52 100644 --- a/src/CodeCoverageExtension.php +++ b/src/CodeCoverageExtension.php @@ -37,15 +37,15 @@ public function load(ServiceContainer $container, array $params = []) } - $container->define('code_coverage.filter', function () { + $container->define('code_coverage.filter', function() { return new Filter(); }); - $container->define('code_coverage', function ($container) { + $container->define('code_coverage', function($container) { return new CodeCoverage(null, $container->get('code_coverage.filter')); }); - $container->define('code_coverage.options', function ($container) use ($params) { + $container->define('code_coverage.options', function($container) use ($params) { $options = !empty($params) ? $params : $container->getParam('code_coverage'); if (!isset($options['format'])) { @@ -74,7 +74,7 @@ public function load(ServiceContainer $container, array $params = []) return $options; }); - $container->define('code_coverage.reports', function ($container) { + $container->define('code_coverage.reports', function($container) { $options = $container->get('code_coverage.options'); $reports = array(); @@ -84,10 +84,10 @@ public function load(ServiceContainer $container, array $params = []) $reports['clover'] = new Report\Clover(); break; case 'php': - $reports['php'] = new Report\PHP(); + $reports['php'] = new Report\PHP(); break; case 'text': - $reports['text'] = new Report\Text( + $reports['text'] = new Report\Text( $options['lower_upper_bound'], $options['high_lower_bound'], $options['show_uncovered_files'], @@ -95,7 +95,7 @@ public function load(ServiceContainer $container, array $params = []) ); break; case 'xml': - $reports['xml'] = new Report\Xml\Facade(Version::id()); + $reports['xml'] = new Report\Xml\Facade(Version::id()); break; case 'crap4j': $reports['crap4j'] = new Report\Crap4j(); @@ -111,7 +111,7 @@ public function load(ServiceContainer $container, array $params = []) return $reports; }); - $container->define('event_dispatcher.listeners.code_coverage', function ($container) { + $container->define('event_dispatcher.listeners.code_coverage', function($container) { $skipCoverage = false; $input = $container->get('console.input'); From 78113dc4a7da06dd3578b9f2a0331d98e673fc16 Mon Sep 17 00:00:00 2001 From: ek9 Date: Mon, 19 Mar 2018 13:51:52 +0000 Subject: [PATCH 43/57] fix PHP CodeSniffer error --- src/CodeCoverageExtension.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/CodeCoverageExtension.php b/src/CodeCoverageExtension.php index 0cb6b52..dd144a7 100644 --- a/src/CodeCoverageExtension.php +++ b/src/CodeCoverageExtension.php @@ -37,15 +37,15 @@ public function load(ServiceContainer $container, array $params = []) } - $container->define('code_coverage.filter', function() { + $container->define('code_coverage.filter', function () { return new Filter(); }); - $container->define('code_coverage', function($container) { + $container->define('code_coverage', function ($container) { return new CodeCoverage(null, $container->get('code_coverage.filter')); }); - $container->define('code_coverage.options', function($container) use ($params) { + $container->define('code_coverage.options', function ($container) use ($params) { $options = !empty($params) ? $params : $container->getParam('code_coverage'); if (!isset($options['format'])) { @@ -74,7 +74,7 @@ public function load(ServiceContainer $container, array $params = []) return $options; }); - $container->define('code_coverage.reports', function($container) { + $container->define('code_coverage.reports', function ($container) { $options = $container->get('code_coverage.options'); $reports = array(); @@ -111,7 +111,7 @@ public function load(ServiceContainer $container, array $params = []) return $reports; }); - $container->define('event_dispatcher.listeners.code_coverage', function($container) { + $container->define('event_dispatcher.listeners.code_coverage', function ($container) { $skipCoverage = false; $input = $container->get('console.input'); From 38dcfb2154a4c84892f1dae648e2d694552746f0 Mon Sep 17 00:00:00 2001 From: ek9 Date: Mon, 19 Mar 2018 13:38:38 +0000 Subject: [PATCH 44/57] fix dockblock to (scrutinizer) --- src/Listener/CodeCoverageListener.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Listener/CodeCoverageListener.php b/src/Listener/CodeCoverageListener.php index c743119..f166f26 100644 --- a/src/Listener/CodeCoverageListener.php +++ b/src/Listener/CodeCoverageListener.php @@ -30,7 +30,7 @@ class CodeCoverageListener implements EventSubscriberInterface /** * @param ConsoleIO $io * @param CodeCoverage $coverage - * @param [] $reports + * @param array $reports * @param boolean $skipCoverage */ public function __construct(ConsoleIO $io, CodeCoverage $coverage, array $reports, $skipCoverage = false) @@ -145,7 +145,7 @@ public function afterSuite(SuiteEvent $event) } /** - * @param [] $options + * @param array $options */ public function setOptions(array $options) { From 4b5574d99e25001ddc819d636ce12c187fcaccd0 Mon Sep 17 00:00:00 2001 From: ek9 Date: Mon, 19 Mar 2018 13:41:33 +0000 Subject: [PATCH 45/57] README: add scrutinizer-ci badge --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index a186540..84dce15 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ phpspec-code-coverage [![License](https://img.shields.io/packagist/l/leanphp/phpspec-code-coverage.svg?style=flat-square)](#LICENSE) [![Latest Stable Version](https://img.shields.io/packagist/v/leanphp/phpspec-code-coverage.svg?style=flat-square)](https://packagist.org/packages/leanphp/phpspec-code-coverage) [![Total Downloads](https://img.shields.io/packagist/dt/leanphp/phpspec-code-coverage.svg?style=flat-square)](https://packagist.org/packages/leanphp/phpspec-code-coverage) +[![Scrutinizer Code +Quality](https://scrutinizer-ci.com/g/leanphp/phpspec-code-coverage/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/leanphp/phpspec-code-coverage/?branch=master) [![Travis](https://img.shields.io/travis/leanphp/phpspec-code-coverage.svg?style=flat-square)](https://travis-ci.org/leanphp/phpspec-code-coverage) [![AppVeyor](https://img.shields.io/appveyor/ci/leanphp/phpspec-code-coverage/master.svg?style=flat-square)](https://ci.appveyor.com/project/leanphp/phpspec-code-coverage) From 1640c8afa7d24cf62b1c25d3a1bee45be416133e Mon Sep 17 00:00:00 2001 From: ek9 Date: Mon, 19 Mar 2018 14:01:47 +0000 Subject: [PATCH 46/57] add .scrutinizer.yml --- .scrutinizer.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .scrutinizer.yml diff --git a/.scrutinizer.yml b/.scrutinizer.yml new file mode 100644 index 0000000..71de164 --- /dev/null +++ b/.scrutinizer.yml @@ -0,0 +1,25 @@ +build: + nodes: + analysis: + project_setup: + override: + - 'true' + tests: + override: + - php-scrutinizer-run + - + command: phpcs-run + use_website_config: true + environment: + node: + version: 6.0.0 +filter: + excluded_paths: + - 'spec/*' +checks: + php: true +coding_style: + php: { } +tools: + php_cs_fixer: + config: { level: Symfony } # or psr1 if you would just like to get fixes for PSR1 From e23f2800e3bfae0d2d3db61a5493407a0e9ca751 Mon Sep 17 00:00:00 2001 From: ek9 Date: Mon, 19 Mar 2018 18:01:58 +0000 Subject: [PATCH 47/57] Minor cleanup + PHPDoc Update + require-dev cleanup - Minor code improvements / cleanup - PHPDoc update - Cleanup require-dev --- CHANGELOG.md | 5 +++ composer.json | 1 - spec/CodeCoverageExtensionSpec.php | 15 +++++++-- spec/Listener/CodeCoverageListenerSpec.php | 1 + src/CodeCoverageExtension.php | 11 ++++--- src/Listener/CodeCoverageListener.php | 36 +++++++++++++--------- 6 files changed, 46 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b4a972..dddb154 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## 4.x-dev + +- Cleanup development dependencies +- Minor code improvements + ## [4.2.0] - 2018-03-19 - Updated `phpunit/php-code-coverage` dependency from `~5.0` to `~6.0`. diff --git a/composer.json b/composer.json index cfebd2e..1875e5e 100644 --- a/composer.json +++ b/composer.json @@ -29,7 +29,6 @@ "phpunit/php-code-coverage": "~6.0" }, "require-dev": { - "bossa/phpspec2-expect": "^3.0", "escapestudios/symfony2-coding-standard": "^3.1", "squizlabs/php_codesniffer": "^3.2" }, diff --git a/spec/CodeCoverageExtensionSpec.php b/spec/CodeCoverageExtensionSpec.php index af69aeb..5c969d5 100644 --- a/spec/CodeCoverageExtensionSpec.php +++ b/spec/CodeCoverageExtensionSpec.php @@ -22,7 +22,9 @@ function it_should_use_html_format_by_default() $this->load($container, []); $options = $container->get('code_coverage.options'); - expect($options['format'])->toBe(array('html')); + if ($options['format'] !== ['html']) { + throw new Exception("Default format is not html"); + } } function it_should_transform_format_into_array() @@ -32,7 +34,10 @@ function it_should_transform_format_into_array() $this->load($container); $options = $container->get('code_coverage.options'); - expect($options['format'])->toBe(array('html')); + if ($options['format'] !== ['html']) { + throw new Exception("Default format is not transformed to an array"); + } + } function it_should_use_singular_output() @@ -42,6 +47,10 @@ function it_should_use_singular_output() $this->load($container); $options = $container->get('code_coverage.options'); - expect($options['output'])->toBe(array('foo' => 'test')); + if ($options['output'] !== ['foo' => 'test']) { + throw new Exception("Default format is not singular output"); + } + + } } diff --git a/spec/Listener/CodeCoverageListenerSpec.php b/spec/Listener/CodeCoverageListenerSpec.php index e95a5d7..ac8e54c 100644 --- a/spec/Listener/CodeCoverageListenerSpec.php +++ b/spec/Listener/CodeCoverageListenerSpec.php @@ -21,6 +21,7 @@ class CodeCoverageListenerSpec extends ObjectBehavior * functional (integration) tests instead. This file is left for reference. * * @see https://github.com/leanphp/phpspec-code-coverage/issues/19 + * function let(ConsoleIO $io, CodeCoverage $coverage) { $this->beConstructedWith($io, $coverage, array()); diff --git a/src/CodeCoverageExtension.php b/src/CodeCoverageExtension.php index dd144a7..9cb15c3 100644 --- a/src/CodeCoverageExtension.php +++ b/src/CodeCoverageExtension.php @@ -2,14 +2,17 @@ /** * This file is part of the leanphp/phpspec-code-coverage package * + * @author ek9 + * @license MIT + * * For the full copyright and license information, please see the LICENSE file * that was distributed with this source code. * - * @license MIT */ namespace LeanPHP\PhpSpec\CodeCoverage; use LeanPHP\PhpSpec\CodeCoverage\Listener\CodeCoverageListener; +use PhpSpec\Extension; use PhpSpec\ServiceContainer; use SebastianBergmann\CodeCoverage\CodeCoverage; use SebastianBergmann\CodeCoverage\Filter; @@ -18,12 +21,12 @@ use Symfony\Component\Console\Input\InputOption; /** - * Injects a Event Subscriber into the EventDispatcher. + * Injects Code Coverage Event Subscriber into the EventDispatcher. * The Subscriber will add Code Coverage information before each example * * @author Henrik Bjornskov */ -class CodeCoverageExtension implements \PhpSpec\Extension +class CodeCoverageExtension implements Extension { /** * {@inheritDoc} @@ -36,7 +39,6 @@ public function load(ServiceContainer $container, array $params = []) } } - $container->define('code_coverage.filter', function () { return new Filter(); }); @@ -119,7 +121,6 @@ public function load(ServiceContainer $container, array $params = []) $skipCoverage = true; } - $listener = new CodeCoverageListener( $container->get('console.io'), $container->get('code_coverage'), diff --git a/src/Listener/CodeCoverageListener.php b/src/Listener/CodeCoverageListener.php index f166f26..15d6517 100644 --- a/src/Listener/CodeCoverageListener.php +++ b/src/Listener/CodeCoverageListener.php @@ -2,10 +2,12 @@ /** * This file is part of the leanphp/phpspec-code-coverage package * + * @author ek9 + * @license MIT + * * For the full copyright and license information, please see the LICENSE file * that was distributed with this source code. * - * @license MIT */ namespace LeanPHP\PhpSpec\CodeCoverage\Listener; @@ -26,6 +28,7 @@ class CodeCoverageListener implements EventSubscriberInterface private $io; private $options; private $enabled; + private $skipCoverage; /** * @param ConsoleIO $io @@ -47,7 +50,8 @@ public function __construct(ConsoleIO $io, CodeCoverage $coverage, array $report 'format' => array('html'), ); - $this->enabled = !$skipCoverage && (extension_loaded('xdebug') || (PHP_SAPI === 'phpdbg')); + $this->enabled = extension_loaded('xdebug') || (PHP_SAPI === 'phpdbg'); + $this->skipCoverage = $skipCoverage; } /** @@ -58,7 +62,7 @@ public function __construct(ConsoleIO $io, CodeCoverage $coverage, array $report */ public function beforeSuite(SuiteEvent $event) { - if (!$this->enabled) { + if (!$this->enabled || $this->skipCoverage) { return; } @@ -87,7 +91,7 @@ public function beforeSuite(SuiteEvent $event) */ public function beforeExample(ExampleEvent $event) { - if (!$this->enabled) { + if (!$this->enabled || $this->skipCoverage) { return; } @@ -106,7 +110,7 @@ public function beforeExample(ExampleEvent $event) */ public function afterExample(ExampleEvent $event) { - if (!$this->enabled) { + if (!$this->enabled || $this->skipCoverage) { return; } @@ -118,9 +122,13 @@ public function afterExample(ExampleEvent $event) */ public function afterSuite(SuiteEvent $event) { - if (!$this->enabled) { + if (!$this->enabled || $this->skipCoverage) { if ($this->io && $this->io->isVerbose()) { - $this->io->writeln('Did not detect Xdebug extension or phpdbg. No code coverage will be generated.'); + if (!$this->enabled) { + $this->io->writeln('No code coverage will be generated as neither Xdebug nor phpdbg was detected.'); + } elseif ($this->skipCoverage) { + $this->io->writeln('Skipping code coverage generation'); + } } return; @@ -155,13 +163,13 @@ public function setOptions(array $options) /** * {@inheritDoc} */ - public static function getSubscribedEvents() + public static function getSubscribedEvents(): array { - return array( - 'beforeExample' => array('beforeExample', -10), - 'afterExample' => array('afterExample', -10), - 'beforeSuite' => array('beforeSuite', -10), - 'afterSuite' => array('afterSuite', -10), - ); + return [ + 'beforeExample' => ['beforeExample', -10], + 'afterExample' => ['afterExample', -10], + 'beforeSuite' => ['beforeSuite', -10], + 'afterSuite' => ['afterSuite', -10], + ]; } } From 20f94499172ed3f175766929e2013fed019556b4 Mon Sep 17 00:00:00 2001 From: ek9 Date: Mon, 19 Mar 2018 18:03:11 +0000 Subject: [PATCH 48/57] fix PHPDoc blocks (phpcs) --- src/CodeCoverageExtension.php | 1 + src/Listener/CodeCoverageListener.php | 1 + 2 files changed, 2 insertions(+) diff --git a/src/CodeCoverageExtension.php b/src/CodeCoverageExtension.php index 9cb15c3..47b656b 100644 --- a/src/CodeCoverageExtension.php +++ b/src/CodeCoverageExtension.php @@ -3,6 +3,7 @@ * This file is part of the leanphp/phpspec-code-coverage package * * @author ek9 + * * @license MIT * * For the full copyright and license information, please see the LICENSE file diff --git a/src/Listener/CodeCoverageListener.php b/src/Listener/CodeCoverageListener.php index 15d6517..88dd7b1 100644 --- a/src/Listener/CodeCoverageListener.php +++ b/src/Listener/CodeCoverageListener.php @@ -3,6 +3,7 @@ * This file is part of the leanphp/phpspec-code-coverage package * * @author ek9 + * * @license MIT * * For the full copyright and license information, please see the LICENSE file From c7eab6104d4b8f0fb1f8f4d13f3e63c4b4d65a11 Mon Sep 17 00:00:00 2001 From: ek9 Date: Tue, 20 Mar 2018 21:57:32 +0000 Subject: [PATCH 49/57] appveyor: cache vendor dir --- .appveyor.yml | 1 + LICENSE | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index dc9f293..5a93e76 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -34,6 +34,7 @@ skip_commits: cache: - c:\php -> appveyor.yml + - c:\projects\phpspec-code-coverage\vendor - '%LOCALAPPDATA%\Composer\files' init: diff --git a/LICENSE b/LICENSE index c4312be..e07374a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2017 ek9 (https://ek9.co). +Copyright (c) 2017-2018 ek9 (https://ek9.co). Copyright (c) 2013-2016 Henrik Bjornskov, for portions of code from henrikbjorn/phpspec-code-coverage project. From d5042cf839d21af49b296531ae1e19a84d7471f0 Mon Sep 17 00:00:00 2001 From: Bruce Date: Wed, 21 Mar 2018 12:05:30 +0100 Subject: [PATCH 50/57] Fix missing check for 'no-coverage' option Executing 'bin/phpspec describe ...' gives the following error : "The 'no-coverage' option does not exist." --- src/CodeCoverageExtension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CodeCoverageExtension.php b/src/CodeCoverageExtension.php index e275c01..6cef0b5 100644 --- a/src/CodeCoverageExtension.php +++ b/src/CodeCoverageExtension.php @@ -107,7 +107,7 @@ public function load(ServiceContainer $container, array $params = []) $skipCoverage = false; $input = $container->get('console.input'); - if ($input->getOption('no-coverage')) { + if (!$input->hasOption('no-coverage') || $input->getOption('no-coverage')) { $skipCoverage = true; } From 82495f5326638f3bdc43c0a878df3965feffb032 Mon Sep 17 00:00:00 2001 From: ek9 Date: Wed, 21 Mar 2018 12:11:23 +0000 Subject: [PATCH 51/57] Add --no-coverage to all phpspec commands - fixes #30 --- src/CodeCoverageExtension.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/CodeCoverageExtension.php b/src/CodeCoverageExtension.php index 6cef0b5..03a14cc 100644 --- a/src/CodeCoverageExtension.php +++ b/src/CodeCoverageExtension.php @@ -24,12 +24,9 @@ class CodeCoverageExtension implements \PhpSpec\Extension public function load(ServiceContainer $container, array $params = []) { foreach ($container->getByTag('console.commands') as $command) { - if ($command->getName() == 'run') { - $command->addOption('no-coverage', null, InputOption::VALUE_NONE, 'Skip code coverage generation'); - } + $command->addOption('no-coverage', null, InputOption::VALUE_NONE, 'Skip code coverage generation'); } - $container->define('code_coverage.filter', function () { return new Filter(); }); @@ -107,7 +104,7 @@ public function load(ServiceContainer $container, array $params = []) $skipCoverage = false; $input = $container->get('console.input'); - if (!$input->hasOption('no-coverage') || $input->getOption('no-coverage')) { + if ($input->hasOption('no-coverage') && $input->getOption('no-coverage')) { $skipCoverage = true; } From ebb7777fcc64173f5b13eff7b2579a63f58fb0ad Mon Sep 17 00:00:00 2001 From: ek9 Date: Wed, 21 Mar 2018 12:12:49 +0000 Subject: [PATCH 52/57] CHANGELOG v4.1.2 --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6208f6b..32e5246 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [4.1.2] - 2018-03-21 + +- Fix `--no-coverage` option introducing errors when running non `run` commands. +- `--no-coverage` option is now available to all phpspec commands (not only + `run`). (#30) + ## [4.1.1] - 2018-03-19 - Added `--no-coverage` option which can skip code coverage generation during @@ -80,6 +86,7 @@ as [leanphp/phpspec-code-coverage][0]. - Support configuring a blacklist of files to be excluded from code coverage reports (`blaclist_files` option). +[4.1.2]: https://github.com/leanphp/phpspec-code-coverage/releases/tag/v4.1.2 [4.1.1]: https://github.com/leanphp/phpspec-code-coverage/releases/tag/v4.1.1 [4.1.0]: https://github.com/leanphp/phpspec-code-coverage/releases/tag/v4.1.0 [4.0.0]: https://github.com/leanphp/phpspec-code-coverage/releases/tag/v4.0.0 From 5ebc6478cb467cdf10d245f27b9fea614e7cf536 Mon Sep 17 00:00:00 2001 From: ek9 Date: Wed, 21 Mar 2018 15:32:35 +0000 Subject: [PATCH 53/57] v4.2.1 --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c6356e3..b777f9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,8 +6,9 @@ documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## 4.x-dev +## [4.2.1] - 2018-03-21 +- Integrate fixes from 4.1.2 (`--no-coverage` option bugfix) - Cleanup development dependencies - Minor code improvements @@ -97,6 +98,7 @@ as [leanphp/phpspec-code-coverage][0]. - Support configuring a blacklist of files to be excluded from code coverage reports (`blaclist_files` option). +[4.2.1]: https://github.com/leanphp/phpspec-code-coverage/releases/tag/v4.2.1 [4.2.0]: https://github.com/leanphp/phpspec-code-coverage/releases/tag/v4.2.0 [4.1.2]: https://github.com/leanphp/phpspec-code-coverage/releases/tag/v4.1.2 [4.1.1]: https://github.com/leanphp/phpspec-code-coverage/releases/tag/v4.1.1 From 263f7a8c649734843497efed9dbe4d7f06020460 Mon Sep 17 00:00:00 2001 From: ek9 Date: Wed, 21 Mar 2018 15:46:51 +0000 Subject: [PATCH 54/57] Add Void return types (PHP 7.1) https://wiki.php.net/rfc/void_return_type --- CHANGELOG.md | 4 ++++ src/Listener/CodeCoverageListener.php | 30 +++++++++++++-------------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b777f9e..3ae2125 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## 4.x-dev + +- PHP 7.1 specific code improvements + ## [4.2.1] - 2018-03-21 - Integrate fixes from 4.1.2 (`--no-coverage` option bugfix) diff --git a/src/Listener/CodeCoverageListener.php b/src/Listener/CodeCoverageListener.php index 88dd7b1..29a8a32 100644 --- a/src/Listener/CodeCoverageListener.php +++ b/src/Listener/CodeCoverageListener.php @@ -42,14 +42,14 @@ public function __construct(ConsoleIO $io, CodeCoverage $coverage, array $report $this->io = $io; $this->coverage = $coverage; $this->reports = $reports; - $this->options = array( - 'whitelist' => array('src', 'lib'), - 'blacklist' => array('test', 'vendor', 'spec'), - 'whitelist_files' => array(), - 'blacklist_files' => array(), - 'output' => array('html' => 'coverage'), - 'format' => array('html'), - ); + $this->options = [ + 'whitelist' => ['src', 'lib'], + 'blacklist' => ['test', 'vendor', 'spec'], + 'whitelist_files' => [], + 'blacklist_files' => [], + 'output' => ['html' => 'coverage'], + 'format' => ['html'], + ]; $this->enabled = extension_loaded('xdebug') || (PHP_SAPI === 'phpdbg'); $this->skipCoverage = $skipCoverage; @@ -61,7 +61,7 @@ public function __construct(ConsoleIO $io, CodeCoverage $coverage, array $report * * @param SuiteEvent $event */ - public function beforeSuite(SuiteEvent $event) + public function beforeSuite(SuiteEvent $event) : void { if (!$this->enabled || $this->skipCoverage) { return; @@ -90,7 +90,7 @@ public function beforeSuite(SuiteEvent $event) /** * @param ExampleEvent $event */ - public function beforeExample(ExampleEvent $event) + public function beforeExample(ExampleEvent $event): void { if (!$this->enabled || $this->skipCoverage) { return; @@ -98,10 +98,10 @@ public function beforeExample(ExampleEvent $event) $example = $event->getExample(); - $name = strtr('%spec%::%example%', array( + $name = strtr('%spec%::%example%', [ '%spec%' => $example->getSpecification()->getClassReflection()->getName(), '%example%' => $example->getFunctionReflection()->getName(), - )); + ]); $this->coverage->start($name); } @@ -109,7 +109,7 @@ public function beforeExample(ExampleEvent $event) /** * @param ExampleEvent $event */ - public function afterExample(ExampleEvent $event) + public function afterExample(ExampleEvent $event): void { if (!$this->enabled || $this->skipCoverage) { return; @@ -121,7 +121,7 @@ public function afterExample(ExampleEvent $event) /** * @param SuiteEvent $event */ - public function afterSuite(SuiteEvent $event) + public function afterSuite(SuiteEvent $event): void { if (!$this->enabled || $this->skipCoverage) { if ($this->io && $this->io->isVerbose()) { @@ -156,7 +156,7 @@ public function afterSuite(SuiteEvent $event) /** * @param array $options */ - public function setOptions(array $options) + public function setOptions(array $options): void { $this->options = $options + $this->options; } From f97204ba31086d4be1cb4122ad21296245facd0d Mon Sep 17 00:00:00 2001 From: ek9 Date: Wed, 21 Mar 2018 16:03:26 +0000 Subject: [PATCH 55/57] composer.json change php-code-coverage dependency to ^6.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 1875e5e..498558b 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ "require": { "php": "^7.1", "phpspec/phpspec": "^4.2", - "phpunit/php-code-coverage": "~6.0" + "phpunit/php-code-coverage": "^6.0" }, "require-dev": { "escapestudios/symfony2-coding-standard": "^3.1", From 9dc509ed354f64ea9f4be6748bd1efcb32d1630b Mon Sep 17 00:00:00 2001 From: ek9 Date: Thu, 22 Mar 2018 21:36:13 +0000 Subject: [PATCH 56/57] v4.2.2 - php-code-coverage '^5.0||^6.0' --- CHANGELOG.md | 4 +++- composer.json | 2 +- src/CodeCoverageExtension.php | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ae2125..a9c5821 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,8 +6,9 @@ documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## 4.x-dev +## [4.2.2] - 2018-03-22 +- Bugfix: loosen up `phpunit/php-code-coverage` from `^6.0` to `^5.0||^6.0` - PHP 7.1 specific code improvements ## [4.2.1] - 2018-03-21 @@ -102,6 +103,7 @@ as [leanphp/phpspec-code-coverage][0]. - Support configuring a blacklist of files to be excluded from code coverage reports (`blaclist_files` option). +[4.2.2]: https://github.com/leanphp/phpspec-code-coverage/releases/tag/v4.2.2 [4.2.1]: https://github.com/leanphp/phpspec-code-coverage/releases/tag/v4.2.1 [4.2.0]: https://github.com/leanphp/phpspec-code-coverage/releases/tag/v4.2.0 [4.1.2]: https://github.com/leanphp/phpspec-code-coverage/releases/tag/v4.1.2 diff --git a/composer.json b/composer.json index 498558b..a73b56e 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ "require": { "php": "^7.1", "phpspec/phpspec": "^4.2", - "phpunit/php-code-coverage": "^6.0" + "phpunit/php-code-coverage": "^5.0||^6.0" }, "require-dev": { "escapestudios/symfony2-coding-standard": "^3.1", diff --git a/src/CodeCoverageExtension.php b/src/CodeCoverageExtension.php index b5e8054..76c8e13 100644 --- a/src/CodeCoverageExtension.php +++ b/src/CodeCoverageExtension.php @@ -2,7 +2,7 @@ /** * This file is part of the leanphp/phpspec-code-coverage package * - * @author ek9 + * @author ek9 * * @license MIT * From aeabf39de86ea457a23a451793782be7d39a3aed Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 26 Jun 2018 16:56:52 +0200 Subject: [PATCH 57/57] Remove invalid link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 84dce15..09eba09 100644 --- a/README.md +++ b/README.md @@ -173,7 +173,7 @@ Licensed under [MIT License](LICENSE). [1]: https://github.com/henrikbjorn/PhpSpecCodeCoverageExtension [2]: http://www.phpspec.net/en/stable [3]: https://xdebug.org/ -[4]: http://phpdbg.com/ +[4]: https://github.com/krakjoe/phpdbg [travis-image]: https://travis-ci.org/leanphp/phpspec-code-coverage.svg [travis-url]: https://travis-ci.org/leanphp/phpspec-code-coverage