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

+5-40
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

+2-3
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

+2-1
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

+20-21
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

+1-1
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

+1-1
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

+1
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

+1
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

+1-1
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

+5-4
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

test/Rx/Functional/MarbleTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -222,28 +222,28 @@ public function testSubscriptionsGroup()
222222
}
223223

224224
/**
225-
* @expectedException \Rx\MarbleDiagramException
226225
*/
227226
public function testSubscriptionsInvalidMarkers()
228227
{
228+
$this->expectException(\Rx\MarbleDiagramException::class);
229229
$marbles = '--^--a--!-';
230230
$this->convertMarblesToSubscriptions($marbles);
231231
}
232232

233233
/**
234-
* @expectedException \Rx\MarbleDiagramException
235234
*/
236235
public function testSubscriptionsMultipleSubscribeMarkers()
237236
{
237+
$this->expectException(\Rx\MarbleDiagramException::class);
238238
$marbles = '--^-^---!-';
239239
$this->convertMarblesToSubscriptions($marbles);
240240
}
241241

242242
/**
243-
* @expectedException \Rx\MarbleDiagramException
244243
*/
245244
public function testSubscriptionsMultipleUnsubscribeMarkers()
246245
{
246+
$this->expectException(\Rx\MarbleDiagramException::class);
247247
$marbles = '--^---!-!-';
248248
$this->convertMarblesToSubscriptions($marbles);
249249
}

test/Rx/Functional/Observable/IntervalObservableTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ public function interval_relative_time_disposed()
9797

9898
/**
9999
* @test
100-
* @expectedException \Exception
101100
*/
102101
public function interval_relative_time_observer_throws()
103102
{
103+
$this->expectException(\Exception::class);
104104
$xs = new IntervalObservable(1, $this->scheduler);
105105

106106
$xs->subscribe(new CallbackObserver(function () {

test/Rx/Functional/Observable/TimerObservableTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ public function timer_one_shot_relative_time_zero()
4949

5050
/**
5151
* @test
52-
* @expectedException \TypeError
5352
*/
5453
public function timer_one_shot_relative_time_zero_non_int()
5554
{
55+
$this->expectException(\TypeError::class);
5656
$this->scheduler->startWithCreate(function () {
5757
return Observable::timer('z', $this->scheduler);
5858
});

test/Rx/Functional/Operator/AsObservableTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class AsObservableTest extends FunctionalTestCase
1717
public function testAsObservableHides()
1818
{
1919
$someObservable = new EmptyObservable($this->scheduler);
20+
self::assertNotSame($someObservable->asObservable(), $someObservable);
2021
return ($someObservable->asObservable() !== $someObservable);
2122
}
2223

test/Rx/Functional/Operator/BufferWithCountTest.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,10 @@ public function bufferWithCountdisposed()
228228

229229
/**
230230
* @test
231-
*
232-
* @expectedException \InvalidArgumentException
233231
*/
234232
public function bufferWithCount_invalid_skip()
235233
{
234+
$this->expectException(\InvalidArgumentException::class);
236235
$xs = $this->createHotObservable([
237236
onNext(100, 1),
238237
onNext(210, 2),
@@ -247,10 +246,10 @@ public function bufferWithCount_invalid_skip()
247246
/**
248247
* @test
249248
*
250-
* @expectedException \InvalidArgumentException
251249
*/
252250
public function bufferWithCount_invalid_count()
253251
{
252+
$this->expectException(\InvalidArgumentException::class);
254253
$xs = $this->createHotObservable([
255254
onNext(100, 1),
256255
onNext(210, 2),

test/Rx/Functional/Operator/CreateTest.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,10 @@ public function create_error()
9797

9898
/**
9999
* @test
100-
* @expectedException \Exception
101-
*
102100
*/
103101
public function create_throws_errors()
104102
{
103+
$this->expectException(\Exception::class);
105104
Observable::create(function ($o) {
106105
throw new \Exception;
107106
})->subscribe(new CallbackObserver());

test/Rx/Functional/Operator/DeferTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,11 @@ public function defer_factory_returns_invalid_string()
148148

149149
/**
150150
* @test
151-
* @expectedException \Exception
152-
* @expectedExceptionMessage I take exception
153151
*/
154152
public function defer_error_while_subscribe_with_immediate_scheduler()
155153
{
154+
$this->expectException(\Exception::class);
155+
$this->expectExceptionMessage('I take exception');
156156
Observable::defer(function () {
157157
return Observable::create(function (ObserverInterface $observer) {
158158
$observer->onError(new \Exception('I take exception'));

test/Rx/Functional/Operator/DoOnEachOperatorTest.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -744,15 +744,17 @@ function ($e) use (&$sawError, $ex) {
744744
);
745745
});
746746

747+
$this->assertTrue($sawError);
748+
747749
}
748750

749751
/**
750752
* @test
751753
*
752-
* @expectedException \InvalidArgumentException
753754
*/
754755
public function do_throws_when_args_invalid()
755756
{
757+
$this->expectException(\InvalidArgumentException::class);
756758
$xs = $this->createHotObservable([
757759
onNext(150, 1),
758760
onNext(210, 2),

0 commit comments

Comments
 (0)