Skip to content

Commit 668346f

Browse files
committed
Update test suite to ensure 100% code coverage
1 parent 71f0ae6 commit 668346f

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
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-csv
22

33
[![CI status](https://github.com/clue/reactphp-csv/actions/workflows/ci.yml/badge.svg)](https://github.com/clue/reactphp-csv/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/reactphp-csv?color=blue&label=installs%20on%20Packagist)](https://packagist.org/packages/clue/reactphp-csv)
56

67
Streaming CSV (Comma-Separated Values or Character-Separated Values) parser and encoder for [ReactPHP](https://reactphp.org/).
@@ -411,6 +412,14 @@ To run the test suite, go to the project root and run:
411412
vendor/bin/phpunit
412413
```
413414

415+
The test suite is set up to always ensure 100% code coverage across all
416+
supported environments. If you have the Xdebug extension installed, you can also
417+
generate a code coverage report locally like this:
418+
419+
```bash
420+
XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text
421+
```
422+
414423
## License
415424

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

src/Encoder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function write($data)
8282

8383
// manually replace custom EOL on PHP < 8.1
8484
if (\PHP_VERSION_ID < 80100 && $this->eol !== "\n") {
85-
$data = \substr($data, 0, -1) . $this->eol;
85+
$data = \substr($data, 0, -1) . $this->eol; // @codeCoverageIgnore
8686
}
8787

8888
return $this->output->write($data);

0 commit comments

Comments
 (0)