Skip to content

Commit d2c2a71

Browse files
committed
Update test suite to ensure 100% code coverage
1 parent 934d598 commit d2c2a71

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,13 @@ jobs:
3131
php-version: ${{ matrix.php }}
3232
coverage: xdebug
3333
- run: composer install
34-
- run: vendor/bin/phpunit --coverage-text
34+
- run: vendor/bin/phpunit --coverage-text --coverage-clover=clover.xml
3535
if: ${{ matrix.php >= 7.3 }}
36-
- run: vendor/bin/phpunit --coverage-text -c phpunit.xml.legacy
36+
- run: vendor/bin/phpunit --coverage-text --coverage-clover=clover.xml -c phpunit.xml.legacy
3737
if: ${{ matrix.php < 7.3 }}
38+
- name: Check 100% code coverage
39+
shell: php {0}
40+
run: |
41+
<?php
42+
$metrics = simplexml_load_file('clover.xml')->project->metrics;
43+
exit((int) $metrics['statements'] === (int) $metrics['coveredstatements'] ? 0 : 1);

README.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# clue/redis-protocol
22

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

67
A streaming Redis protocol (RESP) parser and serializer written in pure PHP.
@@ -26,6 +27,7 @@ implementations.
2627
* [Model](#model)
2728
* [Serializer](#serializer)
2829
* [Install](#install)
30+
* [Tests](#tests)
2931
* [License](#license)
3032

3133
## Support us
@@ -139,11 +141,34 @@ The recommended way to install this library is [through Composer](https://getcom
139141
This will install the latest supported version:
140142

141143
```bash
142-
$ composer require clue/redis-protocol:^0.3.1
144+
composer require clue/redis-protocol:^0.3.1
143145
```
144146

145147
More details and upgrade guides can be found in the [CHANGELOG](CHANGELOG.md).
146148

149+
## Tests
150+
151+
To run the test suite, you first need to clone this repo and then install all
152+
dependencies [through Composer](https://getcomposer.org/):
153+
154+
```bash
155+
composer install
156+
```
157+
158+
To run the test suite, go to the project root and run:
159+
160+
```bash
161+
vendor/bin/phpunit
162+
```
163+
164+
The test suite is set up to always ensure 100% code coverage across all
165+
supported environments. If you have the Xdebug extension installed, you can also
166+
generate a code coverage report locally like this:
167+
168+
```bash
169+
XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text
170+
```
171+
147172
## License
148173

149174
Its parser and serializer originally used to be based on

src/Clue/Redis/Protocol/Parser/ResponseParser.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,6 @@ private function readResponse()
143143
break;
144144
default:
145145
throw new ParserException('Invalid message can not be parsed: "' . $reply . '"');
146-
break;
147146
}
148147
/* Party on */
149148
return $response;

0 commit comments

Comments
 (0)