Skip to content

Commit

Permalink
Merge pull request #32 from clue-labs/coverage
Browse files Browse the repository at this point in the history
Update CI setup to ensure 100% code coverage
  • Loading branch information
SimonFrings authored Dec 2, 2022
2 parents c37981a + 94d28e2 commit ea8fd45
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,16 @@ jobs:
php-version: ${{ matrix.php }}
coverage: xdebug
- run: composer install
- run: vendor/bin/phpunit --coverage-text
- run: vendor/bin/phpunit --coverage-text --coverage-clover=clover.xml
if: ${{ matrix.php >= 7.3 }}
- run: vendor/bin/phpunit --coverage-text -c phpunit.xml.legacy
- run: vendor/bin/phpunit --coverage-text --coverage-clover=clover.xml -c phpunit.xml.legacy
if: ${{ matrix.php < 7.3 }}
- name: Check 100% code coverage
shell: php {0}
run: |
<?php
$metrics = simplexml_load_file('clover.xml')->project->metrics;
exit((int) $metrics['statements'] === (int) $metrics['coveredstatements'] ? 0 : 1);
PHPUnit-hhvm:
name: PHPUnit (HHVM)
Expand Down
3 changes: 3 additions & 0 deletions src/Decoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,14 @@ public function handleData($data)
$this->buffer = (string)\substr($this->buffer, $newline + 1);

// decode data with options given in ctor
// @codeCoverageIgnoreStart
if ($this->options === 0) {
$data = \json_decode($data, $this->assoc, $this->depth);
} else {
assert(\PHP_VERSION_ID >= 50400);
$data = \json_decode($data, $this->assoc, $this->depth, $this->options);
}
// @codeCoverageIgnoreEnd

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

0 comments on commit ea8fd45

Please sign in to comment.