Skip to content

Commit aae0269

Browse files
committed
Added PHP 8 support.
Dropped PHP <7.2 support.
1 parent 1ade9bf commit aae0269

File tree

4 files changed

+33
-30
lines changed

4 files changed

+33
-30
lines changed

.travis.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
notifications:
22
email: false
33

4-
sudo: false
5-
64
language: php
75

86
php:
9-
- 7.0
10-
- 7.1
117
- 7.2
8+
- 7.3
9+
- 7.4
10+
- 8.0
1211

1312
env:
1413
matrix:
@@ -23,12 +22,11 @@ cache:
2322
- vendor
2423

2524
install:
26-
- alias composer=composer\ -n && composer selfupdate
2725
- composer validate
2826
- composer update --no-progress --no-suggest $DEPENDENCIES
2927

3028
script:
31-
- composer test -- --coverage-clover=build/logs/clover.xml
29+
- XDEBUG_MODE=coverage composer test -- --coverage-clover=build/logs/clover.xml
3230

3331
after_success:
3432
- composer require php-coveralls/php-coveralls:^2

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
}
1414
],
1515
"require": {
16-
"php": "^7"
16+
"php": "^7.2|^8"
1717
},
1818
"require-dev": {
19-
"phpunit/phpunit": "^4.8",
19+
"phpunit/phpunit": "^8.5|^9",
2020
"amphp/amp": "^2.1"
2121
},
2222
"autoload": {

test/RetryAsyncTest.php

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
use Amp\Delayed;
55
use Amp\Promise;
66
use Amp\Success;
7+
use PHPUnit\Framework\TestCase;
78
use ScriptFUSION\Retry\FailingTooHardException;
9+
use function Amp\Promise\wait;
10+
use function ScriptFUSION\Retry\retryAsync;
811

9-
final class RetryAsyncTest extends \PHPUnit_Framework_TestCase
12+
final class RetryAsyncTest extends TestCase
1013
{
1114
/**
1215
* Tests that a successful promise is returned without retrying.
@@ -15,8 +18,8 @@ public function testWithoutFailingAsync()
1518
{
1619
$invocations = 0;
1720

18-
$value = \Amp\Promise\wait(
19-
\ScriptFUSION\Retry\retryAsync($tries = 1, static function () use (&$invocations) {
21+
$value = wait(
22+
retryAsync($tries = 1, static function () use (&$invocations) {
2023
++$invocations;
2124

2225
return new Delayed(0, 'foo');
@@ -35,8 +38,8 @@ public function testFailingOnceAsync()
3538
$invocations = 0;
3639
$failed = false;
3740

38-
$value = \Amp\Promise\wait(
39-
\ScriptFUSION\Retry\retryAsync($tries = 2, static function () use (&$invocations, &$failed) {
41+
$value = wait(
42+
retryAsync($tries = 2, static function () use (&$invocations, &$failed) {
4043
++$invocations;
4144

4245
if (!$failed) {
@@ -61,8 +64,8 @@ public function testZeroTriesAsync()
6164
{
6265
$invocations = 0;
6366

64-
$value = \Amp\Promise\wait(
65-
\ScriptFUSION\Retry\retryAsync($tries = 0, static function () use (&$invocations) {
67+
$value = wait(
68+
retryAsync($tries = 0, static function () use (&$invocations) {
6669
++$invocations;
6770

6871
return new Delayed(0, 'foo');
@@ -82,7 +85,7 @@ public function testFailingTooHardAsync()
8285
$outerException = $innerException = null;
8386

8487
try {
85-
\ScriptFUSION\Retry\retryAsync($tries = 3, static function () use (&$invocations, &$innerException) {
88+
retryAsync($tries = 3, static function () use (&$invocations, &$innerException) {
8689
++$invocations;
8790

8891
throw $innerException = new \RuntimeException;
@@ -104,7 +107,7 @@ public function testErrorCallbackAsync()
104107
$outerException = $innerException = null;
105108

106109
try {
107-
\ScriptFUSION\Retry\retryAsync($tries = 2, static function () use (&$invocations, &$innerException) {
110+
retryAsync($tries = 2, static function () use (&$invocations, &$innerException) {
108111
++$invocations;
109112

110113
throw $innerException = new \RuntimeException;
@@ -132,8 +135,8 @@ public function testPromiseErrorCallback()
132135
$start = microtime(true);
133136

134137
try {
135-
\Amp\Promise\wait(
136-
\ScriptFUSION\Retry\retryAsync($tries = 3, static function () {
138+
wait(
139+
retryAsync($tries = 3, static function () {
137140
throw new \DomainException;
138141
}, static function () use ($delay): Promise {
139142
return new Delayed($delay);
@@ -154,7 +157,7 @@ public function testErrorCallbackHaltAsync()
154157
{
155158
$invocations = 0;
156159

157-
\ScriptFUSION\Retry\retryAsync(2, static function () use (&$invocations) {
160+
retryAsync(2, static function () use (&$invocations) {
158161
++$invocations;
159162

160163
throw new \RuntimeException;
@@ -172,7 +175,7 @@ public function testPromiseErrorCallbackHaltAsync()
172175
{
173176
$invocations = 0;
174177

175-
\ScriptFUSION\Retry\retryAsync(2, static function () use (&$invocations) {
178+
retryAsync(2, static function () use (&$invocations) {
176179
++$invocations;
177180

178181
throw new \RuntimeException;
@@ -188,9 +191,9 @@ public function testPromiseErrorCallbackHaltAsync()
188191
*/
189192
public function testErrorCallbackCanThrow()
190193
{
191-
$this->setExpectedException(\LogicException::class);
194+
$this->expectException(\LogicException::class);
192195

193-
\ScriptFUSION\Retry\retryAsync(2, static function () {
196+
retryAsync(2, static function () {
194197
throw new \RuntimeException;
195198
}, static function () {
196199
throw new \LogicException;

test/RetryTest.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
<?php
22
namespace ScriptFUSIONTest\Retry;
33

4+
use PHPUnit\Framework\TestCase;
45
use ScriptFUSION\Retry\FailingTooHardException;
6+
use function ScriptFUSION\Retry\retry;
57

6-
final class RetryTest extends \PHPUnit_Framework_TestCase
8+
final class RetryTest extends TestCase
79
{
810
public function testWithoutFailing()
911
{
1012
$invocations = 0;
1113

12-
$value = \ScriptFUSION\Retry\retry($tries = 1, static function () use (&$invocations) {
14+
$value = retry($tries = 1, static function () use (&$invocations) {
1315
++$invocations;
1416

1517
return 5;
@@ -24,7 +26,7 @@ public function testFailingOnce()
2426
$invocations = 0;
2527
$failed = false;
2628

27-
$value = \ScriptFUSION\Retry\retry($tries = 2, static function () use (&$invocations, &$failed) {
29+
$value = retry($tries = 2, static function () use (&$invocations, &$failed) {
2830
++$invocations;
2931

3032
if (!$failed) {
@@ -45,7 +47,7 @@ public function testZeroTries()
4547
{
4648
$invocations = 0;
4749

48-
$value = \ScriptFUSION\Retry\retry($tries = 0, static function () use (&$invocations) {
50+
$value = retry($tries = 0, static function () use (&$invocations) {
4951
++$invocations;
5052

5153
return 5;
@@ -61,7 +63,7 @@ public function testFailingTooHard()
6163
$outerException = $innerException = null;
6264

6365
try {
64-
\ScriptFUSION\Retry\retry($tries = 2, static function () use (&$invocations, &$innerException) {
66+
retry($tries = 2, static function () use (&$invocations, &$innerException) {
6567
++$invocations;
6668

6769
throw $innerException = new \RuntimeException;
@@ -84,7 +86,7 @@ public function testErrorCallback()
8486
$outerException = $innerException = null;
8587

8688
try {
87-
\ScriptFUSION\Retry\retry($tries = 2, static function () use (&$invocations, &$innerException) {
89+
retry($tries = 2, static function () use (&$invocations, &$innerException) {
8890
++$invocations;
8991

9092
throw $innerException = new \RuntimeException;
@@ -110,7 +112,7 @@ public function testErrorCallbackHalt()
110112
{
111113
$invocations = 0;
112114

113-
\ScriptFUSION\Retry\retry($tries = 2, static function () use (&$invocations) {
115+
retry($tries = 2, static function () use (&$invocations) {
114116
++$invocations;
115117

116118
throw new \RuntimeException;

0 commit comments

Comments
 (0)