Skip to content

Commit f107915

Browse files
authored
Merge pull request #179 from Chris53897/feature/phpunit
tests: migrate tests to phpunit, allow PHP 8.6
2 parents c08db3b + 54e6b47 commit f107915

25 files changed

Lines changed: 518 additions & 390 deletions

‎.gitattributes‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66
/.scrutinizer.yml export-ignore
77
/.styleci.yml export-ignore
88
/.travis.yml export-ignore
9-
/phpspec.ci.yml export-ignore
10-
/phpspec.yml.dist export-ignore
119
/phpstan-baseline.neon export-ignore
1210
/phpstan.neon.dist export-ignore
1311
/phpunit.xml.dist export-ignore
14-
/spec/ export-ignore
1512
/tests/ export-ignore

‎.github/workflows/ci.yml‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ubuntu-latest
1313
strategy:
1414
matrix:
15-
php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
15+
php: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5', '8.6']
1616

1717
steps:
1818
- name: Checkout code
@@ -27,6 +27,9 @@ jobs:
2727

2828
- name: Install dependencies
2929
run: composer update --prefer-dist --no-interaction --no-progress
30+
env:
31+
# PHPUnit 7.5 is the last version supporting PHP 7.1, it has a security advisory that blocks installation
32+
COMPOSER_NO_BLOCKING: ${{ matrix.php == '7.1' && '1' || '' }}
3033

3134
- name: Execute tests
3235
run: composer test
@@ -36,7 +39,7 @@ jobs:
3639
runs-on: ubuntu-latest
3740
strategy:
3841
matrix:
39-
php: ['7.1', '7.4', '8.0', '8.5']
42+
php: ['7.1', '7.4', '8.0', '8.5', '8.6']
4043

4144
steps:
4245
- name: Checkout code
@@ -50,9 +53,10 @@ jobs:
5053
coverage: none
5154

5255
- name: Install dependencies
53-
run: |
54-
composer require "sebastian/comparator:^3.0.2" --no-interaction --no-update
55-
composer update --prefer-dist --prefer-stable --prefer-lowest --no-interaction --no-progress
56+
run: composer update --prefer-dist --prefer-stable --prefer-lowest --no-interaction --no-progress
57+
env:
58+
# PHPUnit 7.5 is the last version supporting PHP 7.1, it has a security advisory that blocks installation
59+
COMPOSER_NO_BLOCKING: ${{ matrix.php == '7.1' && '1' || '' }}
5660

5761
- name: Execute tests
5862
run: composer test
@@ -68,14 +72,12 @@ jobs:
6872
- name: Setup PHP
6973
uses: shivammathur/setup-php@v2
7074
with:
71-
php-version: '7.4'
75+
php-version: '8.5'
7276
tools: composer:v2
7377
coverage: xdebug
7478

7579
- name: Install dependencies
76-
run: |
77-
composer require "friends-of-phpspec/phpspec-code-coverage:^4.3.2" --no-interaction --no-update
78-
composer update --prefer-dist --no-interaction --no-progress
80+
run: composer update --prefer-dist --no-interaction --no-progress
7981

8082
- name: Execute tests
8183
run: composer test-ci

‎.github/workflows/static.yml‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ jobs:
1515
- name: Checkout code
1616
uses: actions/checkout@v7
1717

18-
- name: Remove phpspec
19-
run: composer remove --dev friends-of-phpspec/phpspec-code-coverage phpspec/phpspec
20-
2118
- name: PHPStan
2219
uses: docker://oskarstark/phpstan-ga
2320
with:

‎.gitignore‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
.php-cs-fixer.cache
33
/build/
44
/composer.lock
5-
/phpspec.yml
65
/phpunit.xml
6+
/.phpunit.cache/
7+
/.phpunit.result.cache
78
/vendor/

‎.php-cs-fixer.dist.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
$finder = PhpCsFixer\Finder::create()
4-
->in(__DIR__.'/src')
4+
->in([__DIR__.'/src', __DIR__.'/tests'])
55
->name('*.php')
66
;
77

‎composer.json‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,20 @@
2525
"psr/http-message": "^1.0 || ^2.0"
2626
},
2727
"require-dev": {
28-
"friends-of-phpspec/phpspec-code-coverage": "^4.1 || ^5.0 || ^6.0 || ^7.0",
29-
"phpspec/phpspec": "^5.1 || ^6.0 || ^7.0 || ^8.3"
28+
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.6 || ^10.5 || ^11.5 || ^12.5"
3029
},
3130
"autoload": {
3231
"psr-4": {
3332
"Http\\Client\\": "src/"
3433
}
3534
},
35+
"autoload-dev": {
36+
"psr-4": {
37+
"Http\\Client\\Tests\\": "tests/"
38+
}
39+
},
3640
"scripts": {
37-
"test": "vendor/bin/phpspec run",
38-
"test-ci": "vendor/bin/phpspec run -c phpspec.ci.yml"
41+
"test": "vendor/bin/phpunit",
42+
"test-ci": "vendor/bin/phpunit --coverage-filter src --coverage-clover build/coverage.xml"
3943
}
4044
}

‎phpspec.ci.yml‎

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

‎phpspec.yml.dist‎

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

‎phpstan-baseline.neon‎

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,2 @@
11
parameters:
2-
ignoreErrors:
3-
-
4-
message: "#^Method Http\\\\Client\\\\Exception\\\\HttpException\\:\\:create\\(\\) has no return type specified\\.$#"
5-
count: 1
6-
path: src/Exception/HttpException.php
7-
8-
-
9-
message: "#^Unsafe usage of new static\\(\\)\\.$#"
10-
count: 1
11-
path: src/Exception/HttpException.php
12-
13-
-
14-
message: "#^Method Http\\\\Client\\\\Exception\\\\NetworkException\\:\\:setRequest\\(\\) has no return type specified\\.$#"
15-
count: 1
16-
path: src/Exception/NetworkException.php
17-
18-
-
19-
message: "#^Method Http\\\\Client\\\\Exception\\\\RequestException\\:\\:setRequest\\(\\) has no return type specified\\.$#"
20-
count: 1
21-
path: src/Exception/RequestException.php
2+
ignoreErrors: []

‎phpunit.xml.dist‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
colors="true"
6+
>
7+
<testsuites>
8+
<testsuite name="HTTPlug Test Suite">
9+
<directory>tests/</directory>
10+
</testsuite>
11+
</testsuites>
12+
</phpunit>

0 commit comments

Comments
 (0)