Skip to content

Commit f196569

Browse files
authored
Allow PHP 8 and Update PHPUnit (#208)
* Update travis.yml - drop 7.0 and 7.1, test 7.4 * Allow php >7, Update tests for phpunit >8 compatibility * Drop 7.1 on travis, remove optional argument before required on VirtualTimeScheduler * Get rid of assertion in doc delinter, remove accidentally added operator WIP * Add new line at end of travis file back
1 parent 3c760ba commit f196569

35 files changed

+137
-138
lines changed

.travis.yml

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,10 @@
11
language: php
22

3-
matrix:
4-
include:
5-
- php: 7.0
6-
env:
7-
- qaExtended=true
8-
- php: 7.1
9-
- php: 7.2
10-
env:
11-
- dropPlatform=false
12-
- php: nightly
13-
env:
14-
- dropPlatform=false
15-
- php: 7.0
16-
env:
17-
- dependencies=lowest
18-
- php: 7.1
19-
env:
20-
- dependencies=lowest
21-
- php: 7.2
22-
env:
23-
- dependencies=lowest
24-
- dropPlatform=false
25-
- php: nightly
26-
env:
27-
- dependencies=lowest
28-
- dropPlatform=false
29-
- php: 7.0
30-
env:
31-
- dependencies=highest
32-
- php: 7.1
33-
env:
34-
- dependencies=highest
35-
- php: 7.2
36-
env:
37-
- dependencies=highest
38-
- dropPlatform=false
39-
- php: nightly
40-
env:
41-
- dependencies=highest
42-
- dropPlatform=false
3+
php:
4+
- 7.2
5+
- 7.3
6+
- 7.4
7+
- 8.0
438

449
before_script: composer install
4510

composer.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,12 @@
2020
}
2121
],
2222
"require": {
23-
"php": "~7.0",
23+
"php": ">=7.0.0",
2424
"react/promise": "~2.2"
2525
},
2626
"require-dev": {
2727
"satooshi/php-coveralls": "~1.0",
28-
"phpunit/phpcov": "^3.1",
29-
"phpunit/phpunit": "^5.7",
28+
"phpunit/phpunit": "^8.5 || ^9",
3029
"react/event-loop": "^1.0 || ^0.5 || ^0.4.2"
3130
},
3231
"suggest": {

docs/doc-loader.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ public static function fromPath($path) {
7777
$outputPath = __DIR__ . '/../demo/' . $path . '.expect';
7878

7979
assert(file_exists($codePath), "code does not exist $codePath");
80-
assert(file_exists($outputPath), "output does not exist $outputPath");
80+
// allow demos without expect files - we will just get a warning later
81+
// assert(file_exists($outputPath), "output does not exist $outputPath");
8182

8283
return new Demo(
8384
$path,

phpunit.xml.dist

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,30 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
3-
<phpunit backupGlobals="false"
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
backupGlobals="false"
44
backupStaticAttributes="false"
55
colors="true"
66
convertErrorsToExceptions="true"
77
convertNoticesToExceptions="true"
88
convertWarningsToExceptions="true"
99
processIsolation="false"
1010
stopOnFailure="false"
11-
syntaxCheck="false"
1211
bootstrap="test/bootstrap.php"
13-
>
14-
<testsuites>
15-
<testsuite name="RxPHP Test Suite">
16-
<directory>./test/Rx/</directory>
17-
</testsuite>
18-
</testsuites>
19-
20-
<filter>
21-
<whitelist>
22-
<directory suffix=".php">./src/</directory>
23-
<exclude>
24-
<directory suffix="Interface.php">./src/</directory>
25-
</exclude>
26-
</whitelist>
27-
</filter>
28-
<logging>
29-
<log type="coverage-clover" target="build/logs/clover.xml"/>
30-
</logging>
12+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
13+
<coverage>
14+
<include>
15+
<directory suffix=".php">./src/</directory>
16+
</include>
17+
<exclude>
18+
<directory suffix="Interface.php">./src/</directory>
19+
</exclude>
20+
<report>
21+
<clover outputFile="build/logs/clover.xml"/>
22+
</report>
23+
</coverage>
24+
<testsuites>
25+
<testsuite name="RxPHP Test Suite">
26+
<directory>./test/Rx/</directory>
27+
</testsuite>
28+
</testsuites>
29+
<logging/>
3130
</phpunit>

src/Scheduler/VirtualTimeScheduler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class VirtualTimeScheduler implements AsyncSchedulerInterface
2121
* @param integer $initialClock Initial value for the clock.
2222
* @param callable $comparer Comparer to determine causality of events based on absolute time.
2323
*/
24-
public function __construct(int $initialClock = 0, callable $comparer)
24+
public function __construct(int $initialClock, callable $comparer)
2525
{
2626
$this->clock = $initialClock;
2727
$this->comparer = $comparer;

src/Testing/Recorded.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public function __construct(int $time, $value, callable $comparer = null)
1111
$this->time = $time;
1212
$this->value = $value;
1313
$this->comparer = $comparer ?: function ($a, $b) {
14-
if (method_exists($a, 'equals')) {
14+
if (is_object($a) && method_exists($a, 'equals')) {
1515
return $a->equals($b);
1616
}
1717

test/Rx/Disposable/CompositeDisposableTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ public function clear_disposes_all_contained_disposables_but_not_the_composite_d
200200

201201
/**
202202
* @test
203+
* @doesNotPerformAssertions
203204
*/
204205
public function it_can_be_disposed_multiple_times()
205206
{

test/Rx/Disposable/EmptyDisposableTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class EmptyDisposableTest extends TestCase
1010
{
1111
/**
1212
* @test
13+
* @doesNotPerformAssertions
1314
*/
1415
public function it_can_be_disposed()
1516
{

test/Rx/Disposable/SingleAssignmentDisposableTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ public function it_disposes_newly_set_disposable_if_already_disposed()
4848

4949
/**
5050
* @test
51-
* @expectedException RuntimeException
5251
*/
5352
public function it_cannot_be_assignmed_multiple_times()
5453
{
54+
$this->expectException(\RuntimeException::class);
5555
$d1 = new CallbackDisposable(function(){});
5656
$d2 = new CallbackDisposable(function(){});
5757
$disposable = new SingleAssignmentDisposable();

test/Rx/Functional/FunctionalTestCase.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ abstract class FunctionalTestCase extends TestCase
2121

2222
const TIME_FACTOR = 10;
2323

24-
public function setup()
24+
public function setup() : void
2525
{
2626
$this->scheduler = $this->createTestScheduler();
2727
}
@@ -105,14 +105,15 @@ public function assertSubscriptions(array $expected, array $recorded)
105105
/**
106106
* @param callable $callback
107107
*/
108-
protected function assertException(callable $callback)
108+
protected static function assertException(callable $callback)
109109
{
110+
$exception = null;
110111
try {
111112
$callback();
112113
} catch (\Exception $e) {
113-
return;
114+
$exception = $e;
114115
}
115-
$this->fail('Expected the callback to throw an exception.');
116+
static::assertThat($e instanceof \Exception, static::isTrue(), 'Expected the callback to throw an exception.');
116117
}
117118

118119

0 commit comments

Comments
 (0)