Skip to content

Commit ea8fd45

Browse files
authored
Merge pull request #32 from clue-labs/coverage
Update CI setup to ensure 100% code coverage
2 parents c37981a + 94d28e2 commit ea8fd45

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,16 @@ jobs:
3030
php-version: ${{ matrix.php }}
3131
coverage: xdebug
3232
- run: composer install
33-
- run: vendor/bin/phpunit --coverage-text
33+
- run: vendor/bin/phpunit --coverage-text --coverage-clover=clover.xml
3434
if: ${{ matrix.php >= 7.3 }}
35-
- run: vendor/bin/phpunit --coverage-text -c phpunit.xml.legacy
35+
- run: vendor/bin/phpunit --coverage-text --coverage-clover=clover.xml -c phpunit.xml.legacy
3636
if: ${{ matrix.php < 7.3 }}
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)

src/Decoder.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,14 @@ public function handleData($data)
113113
$this->buffer = (string)\substr($this->buffer, $newline + 1);
114114

115115
// decode data with options given in ctor
116+
// @codeCoverageIgnoreStart
116117
if ($this->options === 0) {
117118
$data = \json_decode($data, $this->assoc, $this->depth);
118119
} else {
120+
assert(\PHP_VERSION_ID >= 50400);
119121
$data = \json_decode($data, $this->assoc, $this->depth, $this->options);
120122
}
123+
// @codeCoverageIgnoreEnd
121124

122125
// abort stream if decoding failed
123126
if ($data === null && \json_last_error() !== \JSON_ERROR_NONE) {

0 commit comments

Comments
 (0)