Skip to content

Commit deb3af0

Browse files
committed
Use GitHub Actions and support up to PHP 8.5
While composer.json is set for PHP versions 5.5 or higher, we only test from PHP 8.1 so we can use PHPUnit 10 and set up coveralls.
1 parent ecb7a04 commit deb3af0

6 files changed

Lines changed: 76 additions & 37 deletions

File tree

.github/workflows/tests.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: tests
2+
3+
on: [ push, pull_request ]
4+
5+
jobs:
6+
tests:
7+
name: Tests PHP ${{ matrix.php }}
8+
runs-on: ubuntu-latest
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
php: [ 8.1, 8.2, 8.3, 8.4, 8.5 ]
13+
include:
14+
- php: 8.4
15+
analysis: true
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
21+
- name: Set up PHP ${{ matrix.php }}
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: ${{ matrix.php }}
25+
coverage: xdebug
26+
27+
- name: Install dependencies
28+
run: composer install --prefer-dist --no-progress --no-suggest
29+
30+
- name: Tests
31+
run: composer test:coverage
32+
33+
- name: Upload coverage results to Coveralls
34+
if: matrix.analysis
35+
env:
36+
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37+
run: |
38+
composer require php-coveralls/php-coveralls -n -W
39+
vendor/bin/php-coveralls --coverage_clover=build/coverage/clover.xml -o build/coverage/coveralls.json -v

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
vendor
1+
.DS_Store
2+
.phpunit.cache
3+
/build
4+
/vendor
5+
clover.xml
26
composer.lock

.travis.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

composer.json

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"php": ">=5.5.0"
1717
},
1818
"require-dev": {
19-
"phpunit/phpunit": "^4.0"
19+
"phpunit/phpunit": "^10.0"
2020
},
2121
"autoload": {
2222
"psr-4": {
@@ -27,5 +27,15 @@
2727
"psr-4": {
2828
"Slim\\Flash\\Tests\\": "tests"
2929
}
30+
},
31+
"scripts": {
32+
"check": [
33+
"@test:coverage"
34+
],
35+
"test": "phpunit --do-not-cache-result --colors=always",
36+
"test:coverage": [
37+
"@putenv XDEBUG_MODE=coverage",
38+
"phpunit --do-not-cache-result --colors=always --coverage-clover build/coverage/clover.xml --coverage-html build/coverage --coverage-text"
39+
]
3040
}
3141
}

phpunit.xml.dist

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
3-
<phpunit backupGlobals="false"
4-
backupStaticAttributes="false"
5-
colors="true"
6-
convertErrorsToExceptions="true"
7-
convertNoticesToExceptions="true"
8-
convertWarningsToExceptions="true"
9-
processIsolation="false"
10-
stopOnFailure="false"
11-
syntaxCheck="false"
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
4+
beStrictAboutChangesToGlobalState="true"
5+
beStrictAboutOutputDuringTests="true" colors="true"
126
bootstrap="tests/bootstrap.php"
7+
cacheDirectory=".phpunit.cache"
138
>
149
<testsuites>
15-
<testsuite name="Slim Test Suite">
16-
<directory>tests/</directory>
10+
<testsuite name="Slim-Flash Test Suite">
11+
<directory>tests</directory>
1712
</testsuite>
1813
</testsuites>
1914

20-
<filter>
21-
<whitelist>
22-
<directory>src/</directory>
23-
</whitelist>
24-
</filter>
15+
<coverage>
16+
<report>
17+
<html outputDirectory="coverage" lowUpperBound="20" highLowerBound="50"/>
18+
</report>
19+
</coverage>
20+
21+
<source>
22+
<include>
23+
<directory>src</directory>
24+
</include>
25+
</source>
2526
</phpunit>

tests/MessagesTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<?php
22
namespace Slim\Flash\Tests;
33

4+
use PHPUnit\Framework\TestCase;
45
use Psr\Http\Message\RequestInterface;
56
use Psr\Http\Message\ResponseInterface;
67
use Slim\Flash\Messages;
78

8-
class MessagesTest extends \PHPUnit_Framework_TestCase
9+
class MessagesTest extends TestCase
910
{
1011
// Test get messages from previous request
1112
public function testGetMessagesFromPrevRequest()
@@ -169,7 +170,7 @@ public function testSetMessagesForCurrentRequest()
169170
$this->assertEquals(['An info'], $messages['info']);
170171

171172
$this->assertArrayHasKey('slimFlash', $storage);
172-
$this->assertEmpty([], $storage['slimFlash']);
173+
$this->assertEmpty($storage['slimFlash']);
173174
}
174175

175176
// Test set messages for next request

0 commit comments

Comments
 (0)