diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8b912ba..06c449c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,13 @@ jobs: php-version: ${{ matrix.php }} coverage: xdebug - run: composer install - - run: vendor/bin/phpunit --coverage-text ${{ matrix.php < 7.3 && '-c phpunit.xml.legacy' || '' }} + - run: vendor/bin/phpunit --coverage-text --coverage-clover clover.xml ${{ matrix.php < 7.3 && '-c phpunit.xml.legacy' || '' }} + - name: Check 100% code coverage + shell: php {0} + run: | + project->metrics; + exit((int) $metrics['statements'] === (int) $metrics['coveredstatements'] ? 0 : 1); PHPUnit-hhvm: name: PHPUnit (HHVM) diff --git a/README.md b/README.md index ad9126b..0b4db17 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # clue/reactphp-http-proxy [![CI status](https://github.com/clue/reactphp-http-proxy/actions/workflows/ci.yml/badge.svg)](https://github.com/clue/reactphp-http-proxy/actions) +[![code coverage](https://img.shields.io/badge/code%20coverage-100%25-success)](#tests) [![installs on Packagist](https://img.shields.io/packagist/dt/clue/http-proxy-react?color=blue&label=installs%20on%20Packagist)](https://packagist.org/packages/clue/http-proxy-react) Async HTTP proxy connector, tunnel any TCP/IP-based protocol through an HTTP @@ -483,6 +484,14 @@ alternatively you can also run it like this: vendor/bin/phpunit --exclude-group internet ``` +The test suite is set up to always ensure 100% code coverage across all +supported environments. If you have the Xdebug extension installed, you can also +generate a code coverage report locally like this: + +```bash +XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text +``` + ## License This project is released under the permissive [MIT license](LICENSE). diff --git a/src/ProxyConnector.php b/src/ProxyConnector.php index 3cb6b22..2e3575b 100644 --- a/src/ProxyConnector.php +++ b/src/ProxyConnector.php @@ -71,7 +71,7 @@ public function __construct( // connector uses Unix transport scheme and explicit path given $connector = new FixedUriConnector( 'unix://' . $match[2], - $connector ?: new UnixConnector() + $connector ?: new UnixConnector() // @codeCoverageIgnore ); } @@ -262,7 +262,7 @@ public function connect($uri) // what a lovely piece of code! $r = new \ReflectionProperty('Exception', 'trace'); if (PHP_VERSION_ID < 80100) { - $r->setAccessible(true); + $r->setAccessible(true); // @codeCoverageIgnore } $trace = $r->getValue($e);