Skip to content

Commit 75f02c5

Browse files
otschdbu
andauthored
Fix phpunit tests (#10)
Add the `composer test` command as mentioned in the readme file. And as phpunit's prophesize method is deprecated from version 9 on and will be removed in phpunit 10, use the trait from phpspec/prophecy-phpunit instead as recommended. phpspec/prophecy-phpunit v2 which contains the needed trait isn't available for PHP 7.2, so bump the version requirement to 7.3. Also use composer test instead of phpunit directly in the ci config and remove running the tests on version 7.2. Finally also remove --diff-format to get cs running again. New php cs fixer config file name. Co-authored-by: David Buchmann <[email protected]>
1 parent 3b7f8f4 commit 75f02c5

File tree

8 files changed

+32
-17
lines changed

8 files changed

+32
-17
lines changed

.gitattributes

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
.editorconfig export-ignore
2-
.gitattributes export-ignore
3-
/.github/ export-ignore
4-
.gitignore export-ignore
5-
/.php_cs.dist export-ignore
6-
/phpunit.xml.dist export-ignore
7-
/tests/ export-ignore
1+
.editorconfig export-ignore
2+
.gitattributes export-ignore
3+
/.github/ export-ignore
4+
.gitignore export-ignore
5+
/.php-cs-fixer.dist.php export-ignore
6+
/phpunit.xml.dist export-ignore
7+
/tests/ export-ignore

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
strategy:
99
max-parallel: 10
1010
matrix:
11-
php: [ '7.2', '7.3', '7.4']
11+
php: [ '7.3', '7.4']
1212

1313
steps:
1414
- name: Set up PHP
@@ -28,7 +28,7 @@ jobs:
2828
run: ./vendor/bin/http_test_server > /dev/null 2>&1 &
2929

3030
- name: Run tests
31-
run: ./vendor/bin/phpunit
31+
run: composer test
3232

3333
lowest:
3434
name: Lowest deps

.github/workflows/static.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: PHP-CS-Fixer
2525
uses: docker://oskarstark/php-cs-fixer-ga
2626
with:
27-
args: --dry-run --diff-format udiff
27+
args: --dry-run
2828

2929
psalm:
3030
name: Psalm

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
/composer.lock
33
/phpunit.xml
44
/vendor/
5+
.phpunit.result.cache

.php_cs.dist renamed to .php-cs-fixer.dist.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
$finder = PhpCsFixer\Finder::create()
44
->exclude('vendor')
5-
->in(__DIR__)
6-
;
5+
->in(__DIR__);
6+
$config = new PhpCsFixer\Config();
77

8-
return PhpCsFixer\Config::create()
8+
return $config->setFinder($finder)
99
->setRules([
1010
'@Symfony' => true,
1111
'array_syntax' => ['syntax' => 'short'],
12-
])
13-
->setFinder($finder);
12+
]);

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased]
9+
### Changed
10+
- Drop support for PHP version 7.2
11+
12+
### Fixed
13+
- Add missing `composer test` command and use it in CI
14+
- Fix deprecated usage of prophesize in phpunit tests
15+
816
## [1.0.0] - 2021-03-09
917

1018
- Stable release - no changes since 0.1.1

composer.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@
1111
}
1212
],
1313
"require": {
14-
"php": "^7.2 | ^8.0",
14+
"php": "^7.3 | ^8.0",
1515
"php-http/httplug": "^2.0",
1616
"psr/http-client": "^1.0",
1717
"guzzlehttp/guzzle": "^7.0"
1818
},
1919
"require-dev": {
2020
"phpunit/phpunit": "^8.0|^9.3",
21-
"php-http/client-integration-tests": "^3.0"
21+
"php-http/client-integration-tests": "^3.0",
22+
"phpspec/prophecy-phpunit": "^2.0"
2223
},
2324
"provide": {
2425
"php-http/client-implementation": "1.0",
@@ -39,5 +40,8 @@
3940
"branch-alias": {
4041
"dev-master": "1.x-dev"
4142
}
43+
},
44+
"scripts": {
45+
"test": "@php vendor/bin/phpunit"
4246
}
4347
}

tests/PromiseTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@
88
use GuzzleHttp\Promise\RejectedPromise;
99
use Http\Adapter\Guzzle7\Promise;
1010
use PHPUnit\Framework\TestCase;
11+
use Prophecy\PhpUnit\ProphecyTrait;
1112
use Psr\Http\Message\RequestInterface;
1213

1314
/**
1415
* @author Márk Sági-Kazár <[email protected]>
1516
*/
1617
class PromiseTest extends TestCase
1718
{
19+
use ProphecyTrait;
20+
1821
public function testNonDomainExceptionIsHandled(): void
1922
{
2023
$this->expectException(Exception::class);

0 commit comments

Comments
 (0)