Skip to content

Commit eee05cc

Browse files
committed
Update test suite and remove legacy PHPUnit workarounds
1 parent 7fa1b76 commit eee05cc

6 files changed

+53
-92
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"php": ">=7.1.0"
3030
},
3131
"require-dev": {
32-
"phpunit/phpunit": "^9.6 || ^5.7"
32+
"phpunit/phpunit": "^9.6 || ^7.5"
3333
},
3434
"suggest": {
3535
"ext-pcntl": "For signal handling support when using the StreamSelectLoop"

phpunit.xml.legacy

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<!-- PHPUnit configuration file with old format for legacy PHPUnit -->
44
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/5.7/phpunit.xsd"
5+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.5/phpunit.xsd"
66
bootstrap="vendor/autoload.php"
77
colors="true">
88
<testsuites>

tests/AbstractLoopTest.php

+4-6
Original file line numberDiff line numberDiff line change
@@ -464,11 +464,10 @@ public function stopShouldStopRunningLoop()
464464

465465
public function testStopShouldPreventRunFromBlocking()
466466
{
467-
$that = $this;
468467
$this->loop->addTimer(
469468
1,
470-
function () use ($that) {
471-
$that->fail('Timer was executed.');
469+
function () {
470+
$this->fail('Timer was executed.');
472471
}
473472
);
474473

@@ -500,10 +499,9 @@ public function testIgnoreRemovedCallback()
500499
});
501500

502501
// this callback would have to be called as well, but the first stream already removed us
503-
$that = $this;
504-
$loop->addReadStream($input2, function () use (& $called, $that) {
502+
$loop->addReadStream($input2, function () use (& $called) {
505503
if ($called) {
506-
$that->fail('Callback 2 must not be called after callback 1 was called');
504+
$this->fail('Callback 2 must not be called after callback 1 was called');
507505
}
508506
});
509507

tests/ExtEventLoopTest.php

-25
Original file line numberDiff line numberDiff line change
@@ -70,29 +70,4 @@ public function writeToStream($stream, $content)
7070

7171
fwrite($stream, $content);
7272
}
73-
74-
/**
75-
* @group epoll-readable-error
76-
*/
77-
public function testCanUseReadableStreamWithFeatureFds()
78-
{
79-
if (PHP_VERSION_ID > 70000) {
80-
$this->markTestSkipped('Memory stream not supported');
81-
}
82-
83-
$this->loop = $this->createLoop(true);
84-
85-
$input = fopen('php://temp/maxmemory:0', 'r+');
86-
87-
fwrite($input, 'x');
88-
ftruncate($input, 0);
89-
90-
$this->loop->addReadStream($input, $this->expectCallableExactly(2));
91-
92-
fwrite($input, "foo\n");
93-
$this->tickLoop($this->loop);
94-
95-
fwrite($input, "bar\n");
96-
$this->tickLoop($this->loop);
97-
}
9873
}

tests/ExtUvLoopTest.php

+44-46
Original file line numberDiff line numberDiff line change
@@ -45,51 +45,49 @@ public function intervalProvider()
4545
$tenMillionsIntMax = PHP_INT_MAX + 10000000;
4646
$tenThousandsTimesIntMax = PHP_INT_MAX * 1000;
4747

48-
return array(
49-
array(
50-
$oversizeInterval,
51-
"Interval overflow, value must be lower than '{$maxValue}', but '{$oversizeInterval}' passed."
52-
),
53-
array(
54-
$oneMaxValue,
55-
"Interval overflow, value must be lower than '{$maxValue}', but '{$oneMaxValue}' passed.",
56-
),
57-
array(
58-
$tenMaxValue,
59-
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenMaxValue}' passed.",
60-
),
61-
array(
62-
$tenMillionsMaxValue,
63-
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenMillionsMaxValue}' passed.",
64-
),
65-
array(
66-
$intMax,
67-
"Interval overflow, value must be lower than '{$maxValue}', but '{$intMax}' passed.",
68-
),
69-
array(
70-
$oneIntMax,
71-
"Interval overflow, value must be lower than '{$maxValue}', but '{$oneIntMax}' passed.",
72-
),
73-
array(
74-
$tenIntMax,
75-
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenIntMax}' passed.",
76-
),
77-
array(
78-
$oneHundredIntMax,
79-
"Interval overflow, value must be lower than '{$maxValue}', but '{$oneHundredIntMax}' passed.",
80-
),
81-
array(
82-
$oneThousandIntMax,
83-
"Interval overflow, value must be lower than '{$maxValue}', but '{$oneThousandIntMax}' passed.",
84-
),
85-
array(
86-
$tenMillionsIntMax,
87-
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenMillionsIntMax}' passed.",
88-
),
89-
array(
90-
$tenThousandsTimesIntMax,
91-
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenThousandsTimesIntMax}' passed.",
92-
),
93-
);
48+
yield [
49+
$oversizeInterval,
50+
"Interval overflow, value must be lower than '{$maxValue}', but '{$oversizeInterval}' passed."
51+
];
52+
yield [
53+
$oneMaxValue,
54+
"Interval overflow, value must be lower than '{$maxValue}', but '{$oneMaxValue}' passed.",
55+
];
56+
yield [
57+
$tenMaxValue,
58+
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenMaxValue}' passed.",
59+
];
60+
yield [
61+
$tenMillionsMaxValue,
62+
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenMillionsMaxValue}' passed.",
63+
];
64+
yield [
65+
$intMax,
66+
"Interval overflow, value must be lower than '{$maxValue}', but '{$intMax}' passed.",
67+
];
68+
yield [
69+
$oneIntMax,
70+
"Interval overflow, value must be lower than '{$maxValue}', but '{$oneIntMax}' passed.",
71+
];
72+
yield [
73+
$tenIntMax,
74+
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenIntMax}' passed.",
75+
];
76+
yield [
77+
$oneHundredIntMax,
78+
"Interval overflow, value must be lower than '{$maxValue}', but '{$oneHundredIntMax}' passed.",
79+
];
80+
yield [
81+
$oneThousandIntMax,
82+
"Interval overflow, value must be lower than '{$maxValue}', but '{$oneThousandIntMax}' passed.",
83+
];
84+
yield [
85+
$tenMillionsIntMax,
86+
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenMillionsIntMax}' passed.",
87+
];
88+
yield [
89+
$tenThousandsTimesIntMax,
90+
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenThousandsTimesIntMax}' passed.",
91+
];
9492
}
9593
}

tests/StreamSelectLoopTest.php

+3-13
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ public function testStreamSelectTimeoutEmulation()
4242

4343
public function testStreamSelectReportsWarningForStreamWithFilter()
4444
{
45-
if (defined('HHVM_VERSION')) {
46-
$this->markTestSkipped('Not supported on legacy HHVM');
47-
}
48-
4945
$stream = tmpfile();
5046
stream_filter_append($stream, 'string.rot13');
5147

@@ -80,10 +76,6 @@ public function testStreamSelectReportsWarningForStreamWithFilter()
8076

8177
public function testStreamSelectThrowsWhenCustomErrorHandlerThrowsForStreamWithFilter()
8278
{
83-
if (defined('HHVM_VERSION')) {
84-
$this->markTestSkipped('Not supported on legacy HHVM');
85-
}
86-
8779
$stream = tmpfile();
8880
stream_filter_append($stream, 'string.rot13');
8981

@@ -121,11 +113,9 @@ public function testStreamSelectThrowsWhenCustomErrorHandlerThrowsForStreamWithF
121113

122114
public function signalProvider()
123115
{
124-
return array(
125-
array('SIGUSR1'),
126-
array('SIGHUP'),
127-
array('SIGTERM'),
128-
);
116+
yield ['SIGUSR1'];
117+
yield ['SIGHUP'];
118+
yield ['SIGTERM'];
129119
}
130120

131121
/**

0 commit comments

Comments
 (0)