Skip to content

Commit

Permalink
Update tests + add PHP 8 support
Browse files Browse the repository at this point in the history
  • Loading branch information
t0mmy742 committed Dec 7, 2020
1 parent 787232a commit 1adc293
Show file tree
Hide file tree
Showing 12 changed files with 281 additions and 126 deletions.
4 changes: 2 additions & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
* text=lf

/.github export-ignore
/tests export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/CHANGELOG.md export-ignore
/phpcs.xml.dist export-ignore
/phpstan.neon.dist export-ignore
/phpunit.xml.dist export-ignore
/README.md export-ignore
/tests export-ignore
51 changes: 51 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Tests

on: [push, pull_request]

jobs:
tests:
name: Tests PHP ${{ matrix.php }}
runs-on: ubuntu-latest
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
php: [8.0]
experimental: [false]
include:
- php: 8.0
analysis: true
- php: nightly
experimental: true

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up PHP ${{ matrix.php }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: xdebug

- name: Install dependencies with Composer
uses: ramsey/composer-install@v1

- name: Coding standards
if: matrix.analysis
run: vendor/bin/phpcs

- name: Static analysis
if: matrix.analysis
run: vendor/bin/phpstan analyse

- name: Tests
run: vendor/bin/phpunit --coverage-clover build/logs/clover.xml

- name: Upload coverage results to Coveralls
if: matrix.analysis
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
composer require --dev php-coveralls/php-coveralls
vendor/bin/php-coveralls -v
16 changes: 9 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
.idea
.phpunit.result.cache
composer.lock
phpcs.xml
phpstan.neon
phpunit.xml
vendor
/.idea/
/.phpunit.cache/
/build/
/vendor/
/.phpunit.result.cache
/composer.lock
/phpcs.xml
/phpstan.neon
/phpunit.xml
24 changes: 0 additions & 24 deletions .travis.yml

This file was deleted.

15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.1.0] - 2020-12-07
### Added
- PHP 8 support

### Changed
- GitHub Actions replaced Travis CI

### Removed
- Drop PHP 7 support
- Remove Prophecy `phpspec/prophecy` usage for testing
- Remove PSR-7 implementation (`slim/psr7`) for testing (test only with Mock)

## [1.0.5] - 2020-04-25
### Changed
- Tests now use Slim PSR-7 implementation
Expand Down Expand Up @@ -46,7 +58,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- First version

[Unreleased]: https://github.com/t0mmy742/trailing-slash-middleware/compare/1.0.5...HEAD
[Unreleased]: https://github.com/t0mmy742/trailing-slash-middleware/compare/1.0.6...HEAD
[1.0.6]: https://github.com/t0mmy742/trailing-slash-middleware/compare/1.0.5...1.0.6
[1.0.5]: https://github.com/t0mmy742/trailing-slash-middleware/compare/1.0.4...1.0.5
[1.0.4]: https://github.com/t0mmy742/trailing-slash-middleware/compare/1.0.3...1.0.4
[1.0.3]: https://github.com/t0mmy742/trailing-slash-middleware/compare/1.0.2...1.0.3
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Trailing Slash Middleware (PSR-15)

[![Build Status](https://travis-ci.org/t0mmy742/trailing-slash-middleware.svg?branch=master)](https://travis-ci.org/t0mmy742/trailing-slash-middleware)
[![Tests](https://github.com/t0mmy742/trailing-slash-middleware/workflows/Tests/badge.svg?branch=master)](https://github.com/t0mmy742/trailing-slash-middleware/actions?query=branch:master)
[![Coverage Status](https://coveralls.io/repos/github/t0mmy742/trailing-slash-middleware/badge.svg?branch=master)](https://coveralls.io/github/t0mmy742/trailing-slash-middleware?branch=master)

This middleware remove trailing slash from URI.
Expand Down
31 changes: 16 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,25 @@
"authors": [
{
"name": "Thomas LE BERRE",
"email": "t0mmy742@users.noreply.github.com"
"email": "29512640+t0mmy742@users.noreply.github.com"
}
],
"require": {
"php": "^7.3",
"php": "^8.0",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.0",
"psr/http-server-handler": "^1.0",
"psr/http-server-middleware": "^1.0"
},
"require-dev": {
"phpspec/prophecy": "^1.10",
"phpspec/prophecy-phpunit": "^2.0",
"phpstan/phpstan": "^0.12.19",
"phpunit/phpunit": "^9.1",
"slim/psr7": "^1.0",
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^0.12.59",
"phpstan/phpstan-deprecation-rules": "^0.12.5",
"phpstan/phpstan-phpunit": "^0.12.16",
"phpstan/phpstan-strict-rules": "^0.12.5",
"phpunit/phpunit": "^9.5",
"squizlabs/php_codesniffer": "^3.5",
"t0mmy742/middleware-dispatcher": "^1.0"
"thecodingmachine/phpstan-strict-rules": "^0.12.1"
},
"config": {
"sort-packages": true
Expand All @@ -45,13 +46,13 @@
}
},
"scripts": {
"test": [
"@phpunit",
"@phpcs",
"@phpstan"
],
"phpunit": "phpunit",
"phpcs": "phpcs",
"phpstan": "phpstan analyse src --memory-limit=-1"
"phpstan": "phpstan analyse",
"phpunit": "phpunit --coverage-html build/coverage/coverage-html",
"tests": [
"@phpcs",
"@phpstan",
"@phpunit"
]
}
}
7 changes: 4 additions & 3 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
name="Coding standard">
<description>Coding Standard</description>

<file>src</file>
<file>tests</file>

<arg name="colors"/>
<arg value="sp"/>

<rule ref="PSR12"/>
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>

<file>src</file>
<file>tests</file>
<rule ref="Generic.PHP.RequireStrictTypes"/>
</ruleset>
6 changes: 5 additions & 1 deletion phpstan.neon.dist
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
parameters:
level: max
inferPrivatePropertyTypeFromConstructor: true
paths:
- src
- tests
ignoreErrors:
- '#^Dynamic call to static method PHPUnit\\Framework\\.*#'
17 changes: 12 additions & 5 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="tests/bootstrap.php"
cacheResultFile=".phpunit.cache/test-results"
colors="true"
bootstrap="tests/bootstrap.php">
beStrictAboutOutputDuringTests="true"
failOnRisky="true"
failOnWarning="true"
verbose="true">
<testsuites>
<testsuite name="Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>

<coverage cacheDirectory=".phpunit.cache/code-coverage"
processUncoveredFiles="true">
<include>
<directory>src</directory>
</whitelist>
</filter>
</include>
</coverage>
</phpunit>
2 changes: 1 addition & 1 deletion src/TrailingSlashMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

class TrailingSlashMiddleware implements MiddlewareInterface
{
private $responseFactory;
private ResponseFactoryInterface $responseFactory;

public function __construct(ResponseFactoryInterface $responseFactory)
{
Expand Down

0 comments on commit 1adc293

Please sign in to comment.