Skip to content

Commit b6d17a7

Browse files
committed
Update test suite to ensure 100% code coverage
1 parent 28b107d commit b6d17a7

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,13 @@ jobs:
3333
php-version: ${{ matrix.php }}
3434
coverage: xdebug
3535
- run: composer install
36-
- run: vendor/bin/phpunit --coverage-text ${{ matrix.php < 7.3 && '-c phpunit.xml.legacy' || '' }}
36+
- run: vendor/bin/phpunit --coverage-text --coverage-clover clover.xml ${{ matrix.php < 7.3 && '-c phpunit.xml.legacy' || '' }}
37+
- name: Check 100% code coverage
38+
shell: php {0}
39+
run: |
40+
<?php
41+
$metrics = simplexml_load_file('clover.xml')->project->metrics;
42+
exit((int) $metrics['statements'] === (int) $metrics['coveredstatements'] ? 0 : 1);
3743
3844
PHPUnit-hhvm:
3945
name: PHPUnit (HHVM)

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# clue/reactphp-http-proxy
22

33
[![CI status](https://github.com/clue/reactphp-http-proxy/actions/workflows/ci.yml/badge.svg)](https://github.com/clue/reactphp-http-proxy/actions)
4+
[![code coverage](https://img.shields.io/badge/code%20coverage-100%25-success)](#tests)
45
[![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)
56

67
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:
483484
vendor/bin/phpunit --exclude-group internet
484485
```
485486

487+
The test suite is set up to always ensure 100% code coverage across all
488+
supported environments. If you have the Xdebug extension installed, you can also
489+
generate a code coverage report locally like this:
490+
491+
```bash
492+
XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text
493+
```
494+
486495
## License
487496

488497
This project is released under the permissive [MIT license](LICENSE).

src/ProxyConnector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function __construct(
7171
// connector uses Unix transport scheme and explicit path given
7272
$connector = new FixedUriConnector(
7373
'unix://' . $match[2],
74-
$connector ?: new UnixConnector()
74+
$connector ?: new UnixConnector() // @codeCoverageIgnore
7575
);
7676
}
7777

@@ -262,7 +262,7 @@ public function connect($uri)
262262
// what a lovely piece of code!
263263
$r = new \ReflectionProperty('Exception', 'trace');
264264
if (PHP_VERSION_ID < 80100) {
265-
$r->setAccessible(true);
265+
$r->setAccessible(true); // @codeCoverageIgnore
266266
}
267267
$trace = $r->getValue($e);
268268

0 commit comments

Comments
 (0)