Skip to content

Commit d047054

Browse files
committed
Update test suite to ensure 100% code coverage
1 parent e450527 commit d047054

5 files changed

Lines changed: 35 additions & 18 deletions

File tree

.github/workflows/ci.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,16 @@ jobs:
2929
coverage: xdebug
3030
ini-file: development
3131
- run: composer install
32-
- run: vendor/bin/phpunit --coverage-text --stderr
32+
- run: vendor/bin/phpunit --coverage-text --coverage-clover=clover.xml
3333
if: ${{ matrix.php >= 7.3 }}
34-
- run: vendor/bin/phpunit --coverage-text --stderr -c phpunit.xml.legacy
34+
- run: vendor/bin/phpunit --coverage-text --coverage-clover=clover.xml -c phpunit.xml.legacy
3535
if: ${{ matrix.php < 7.3 }}
36+
- name: Check 100% code coverage
37+
shell: php {0}
38+
run: |
39+
<?php
40+
$metrics = simplexml_load_file('clover.xml')->project->metrics;
41+
exit((int) $metrics['statements'] === (int) $metrics['coveredstatements'] ? 0 : 1);
3642
3743
PHPStan:
3844
name: PHPStan (PHP ${{ matrix.php }})

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Framework X
22

33
[![CI status](https://github.com/clue-access/framework-x/workflows/CI/badge.svg)](https://github.com/clue-access/framework-x/actions)
4+
[![code coverage](https://img.shields.io/badge/code%20coverage-100%25-success)](#tests)
45

56
Framework X – the simple and fast micro framework for building reactive web applications that run anywhere.
67

@@ -115,7 +116,15 @@ $ composer install
115116
To run the test suite, go to the project root and run:
116117

117118
```bash
118-
$ vendor/bin/phpunit --stderr
119+
$ vendor/bin/phpunit
120+
```
121+
122+
The test suite is set up to always ensure 100% code coverage across all
123+
supported environments. If you have the Xdebug extension installed, you can also
124+
generate a code coverage report locally like this:
125+
126+
```bash
127+
$ XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text
119128
```
120129

121130
Additionally, you can run some simple acceptance tests to verify the framework

phpunit.xml.dist

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
bootstrap="vendor/autoload.php"
77
cacheResult="false"
88
colors="true"
9-
convertDeprecationsToExceptions="true">
9+
convertDeprecationsToExceptions="true"
10+
stderr="true">
1011
<testsuites>
1112
<testsuite name="Framework X test suite">
1213
<directory>./tests/</directory>

phpunit.xml.legacy

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
55
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.5/phpunit.xsd"
66
bootstrap="vendor/autoload.php"
7-
colors="true">
7+
colors="true"
8+
stderr="true">
89
<testsuites>
910
<testsuite name="Framework X test suite">
1011
<directory>./tests/</directory>

tests/Io/SapiHandlerTest.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function testRequestFromGlobalsWithConnectProxy(): void
141141
public function testSendResponseSendsEmptyResponseWithNoHeadersAndEmptyBodyAndAssignsNoContentTypeAndEmptyContentLength(): void
142142
{
143143
if (headers_sent() || !function_exists('xdebug_get_headers')) {
144-
$this->markTestSkipped('Test requires running phpunit with --stderr and Xdebug enabled');
144+
$this->markTestSkipped('Test requires running PHPUnit with Xdebug enabled');
145145
}
146146

147147
header_remove();
@@ -158,7 +158,7 @@ public function testSendResponseSendsEmptyResponseWithNoHeadersAndEmptyBodyAndAs
158158
public function testSendResponseSendsJsonResponseWithGivenHeadersAndBodyAndAssignsMatchingContentLength(): void
159159
{
160160
if (headers_sent() || !function_exists('xdebug_get_headers')) {
161-
$this->markTestSkipped('Test requires running phpunit with --stderr and Xdebug enabled');
161+
$this->markTestSkipped('Test requires running PHPUnit with Xdebug enabled');
162162
}
163163

164164
header_remove();
@@ -178,7 +178,7 @@ public function testSendResponseSendsJsonResponseWithGivenHeadersAndBodyAndAssig
178178
public function testSendResponseSendsJsonResponseWithGivenHeadersAndMatchingContentLengthButEmptyBodyForHeadRequest(): void
179179
{
180180
if (headers_sent() || !function_exists('xdebug_get_headers')) {
181-
$this->markTestSkipped('Test requires running phpunit with --stderr and Xdebug enabled');
181+
$this->markTestSkipped('Test requires running PHPUnit with Xdebug enabled');
182182
}
183183

184184
header_remove();
@@ -196,7 +196,7 @@ public function testSendResponseSendsJsonResponseWithGivenHeadersAndMatchingCont
196196
public function testSendResponseSendsEmptyBodyWithGivenHeadersAndAssignsNoContentLengthForNoContentResponse(): void
197197
{
198198
if (headers_sent() || !function_exists('xdebug_get_headers')) {
199-
$this->markTestSkipped('Test requires running phpunit with --stderr and Xdebug enabled');
199+
$this->markTestSkipped('Test requires running PHPUnit with Xdebug enabled');
200200
}
201201

202202
header_remove();
@@ -213,7 +213,7 @@ public function testSendResponseSendsEmptyBodyWithGivenHeadersAndAssignsNoConten
213213
public function testSendResponseSendsEmptyBodyWithGivenHeadersButWithoutExplicitContentLengthForNoContentResponse(): void
214214
{
215215
if (headers_sent() || !function_exists('xdebug_get_headers')) {
216-
$this->markTestSkipped('Test requires running phpunit with --stderr and Xdebug enabled');
216+
$this->markTestSkipped('Test requires running PHPUnit with Xdebug enabled');
217217
}
218218

219219
header_remove();
@@ -230,7 +230,7 @@ public function testSendResponseSendsEmptyBodyWithGivenHeadersButWithoutExplicit
230230
public function testSendResponseSendsEmptyBodyWithGivenHeadersAndAssignsContentLengthForNotModifiedResponse(): void
231231
{
232232
if (headers_sent() || !function_exists('xdebug_get_headers')) {
233-
$this->markTestSkipped('Test requires running phpunit with --stderr and Xdebug enabled');
233+
$this->markTestSkipped('Test requires running PHPUnit with Xdebug enabled');
234234
}
235235

236236
header_remove();
@@ -247,7 +247,7 @@ public function testSendResponseSendsEmptyBodyWithGivenHeadersAndAssignsContentL
247247
public function testSendResponseSendsEmptyBodyWithGivenHeadersAndExplicitContentLengthForNotModifiedResponse(): void
248248
{
249249
if (headers_sent() || !function_exists('xdebug_get_headers')) {
250-
$this->markTestSkipped('Test requires running phpunit with --stderr and Xdebug enabled');
250+
$this->markTestSkipped('Test requires running PHPUnit with Xdebug enabled');
251251
}
252252

253253
header_remove();
@@ -264,7 +264,7 @@ public function testSendResponseSendsEmptyBodyWithGivenHeadersAndExplicitContent
264264
public function testSendResponseSendsStreamingResponseWithNoHeadersAndBodyFromStreamData(): void
265265
{
266266
if (headers_sent() || !function_exists('xdebug_get_headers')) {
267-
$this->markTestSkipped('Test requires running phpunit with --stderr and Xdebug enabled');
267+
$this->markTestSkipped('Test requires running PHPUnit with Xdebug enabled');
268268
}
269269

270270
header_remove();
@@ -287,7 +287,7 @@ public function testSendResponseSendsStreamingResponseWithNoHeadersAndBodyFromSt
287287
public function testSendResponseClosesStreamingResponseAndSendsResponseWithNoHeadersAndBodyForHeadRequest(): void
288288
{
289289
if (headers_sent() || !function_exists('xdebug_get_headers')) {
290-
$this->markTestSkipped('Test requires running phpunit with --stderr and Xdebug enabled');
290+
$this->markTestSkipped('Test requires running PHPUnit with Xdebug enabled');
291291
}
292292

293293
header_remove();
@@ -307,7 +307,7 @@ public function testSendResponseClosesStreamingResponseAndSendsResponseWithNoHea
307307
public function testSendResponseClosesStreamingResponseAndSendsResponseWithNoHeadersAndBodyForNotModifiedResponse(): void
308308
{
309309
if (headers_sent() || !function_exists('xdebug_get_headers')) {
310-
$this->markTestSkipped('Test requires running phpunit with --stderr and Xdebug enabled');
310+
$this->markTestSkipped('Test requires running PHPUnit with Xdebug enabled');
311311
}
312312

313313
header_remove();
@@ -326,7 +326,7 @@ public function testSendResponseClosesStreamingResponseAndSendsResponseWithNoHea
326326
public function testSendResponseClosesStreamingResponseAndSendsResponseWithNoHeadersAndBodyForNoContentResponse(): void
327327
{
328328
if (headers_sent() || !function_exists('xdebug_get_headers')) {
329-
$this->markTestSkipped('Test requires running phpunit with --stderr and Xdebug enabled');
329+
$this->markTestSkipped('Test requires running PHPUnit with Xdebug enabled');
330330
}
331331

332332
header_remove();
@@ -345,7 +345,7 @@ public function testSendResponseClosesStreamingResponseAndSendsResponseWithNoHea
345345
public function testSendResponseSendsStreamingResponseWithNoHeadersAndBodyFromStreamDataAndNoBufferHeaderForNginxServer(): void
346346
{
347347
if (headers_sent() || !function_exists('xdebug_get_headers')) {
348-
$this->markTestSkipped('Test requires running phpunit with --stderr and Xdebug enabled');
348+
$this->markTestSkipped('Test requires running PHPUnit with Xdebug enabled');
349349
}
350350

351351
header_remove();
@@ -366,7 +366,7 @@ public function testSendResponseSendsStreamingResponseWithNoHeadersAndBodyFromSt
366366
public function testSendResponseSetsMultipleCookieHeaders(): void
367367
{
368368
if (headers_sent() || !function_exists('xdebug_get_headers')) {
369-
$this->markTestSkipped('Test requires running phpunit with --stderr and Xdebug enabled');
369+
$this->markTestSkipped('Test requires running PHPUnit with Xdebug enabled');
370370
}
371371

372372
header_remove();

0 commit comments

Comments
 (0)