Skip to content

Commit

Permalink
Update test suite and remove legacy PHPUnit workarounds
Browse files Browse the repository at this point in the history
  • Loading branch information
WyriHaximus committed Feb 24, 2024
1 parent 7fa1b76 commit eee05cc
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 92 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"php": ">=7.1.0"
},
"require-dev": {
"phpunit/phpunit": "^9.6 || ^5.7"
"phpunit/phpunit": "^9.6 || ^7.5"
},
"suggest": {
"ext-pcntl": "For signal handling support when using the StreamSelectLoop"
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.legacy
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<!-- PHPUnit configuration file with old format for legacy PHPUnit -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/5.7/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/7.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true">
<testsuites>
Expand Down
10 changes: 4 additions & 6 deletions tests/AbstractLoopTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -464,11 +464,10 @@ public function stopShouldStopRunningLoop()

public function testStopShouldPreventRunFromBlocking()
{
$that = $this;
$this->loop->addTimer(
1,
function () use ($that) {
$that->fail('Timer was executed.');
function () {
$this->fail('Timer was executed.');
}
);

Expand Down Expand Up @@ -500,10 +499,9 @@ public function testIgnoreRemovedCallback()
});

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

Expand Down
25 changes: 0 additions & 25 deletions tests/ExtEventLoopTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,29 +70,4 @@ public function writeToStream($stream, $content)

fwrite($stream, $content);
}

/**
* @group epoll-readable-error
*/
public function testCanUseReadableStreamWithFeatureFds()
{
if (PHP_VERSION_ID > 70000) {
$this->markTestSkipped('Memory stream not supported');
}

$this->loop = $this->createLoop(true);

$input = fopen('php://temp/maxmemory:0', 'r+');

fwrite($input, 'x');
ftruncate($input, 0);

$this->loop->addReadStream($input, $this->expectCallableExactly(2));

fwrite($input, "foo\n");
$this->tickLoop($this->loop);

fwrite($input, "bar\n");
$this->tickLoop($this->loop);
}
}
90 changes: 44 additions & 46 deletions tests/ExtUvLoopTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,51 +45,49 @@ public function intervalProvider()
$tenMillionsIntMax = PHP_INT_MAX + 10000000;
$tenThousandsTimesIntMax = PHP_INT_MAX * 1000;

return array(
array(
$oversizeInterval,
"Interval overflow, value must be lower than '{$maxValue}', but '{$oversizeInterval}' passed."
),
array(
$oneMaxValue,
"Interval overflow, value must be lower than '{$maxValue}', but '{$oneMaxValue}' passed.",
),
array(
$tenMaxValue,
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenMaxValue}' passed.",
),
array(
$tenMillionsMaxValue,
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenMillionsMaxValue}' passed.",
),
array(
$intMax,
"Interval overflow, value must be lower than '{$maxValue}', but '{$intMax}' passed.",
),
array(
$oneIntMax,
"Interval overflow, value must be lower than '{$maxValue}', but '{$oneIntMax}' passed.",
),
array(
$tenIntMax,
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenIntMax}' passed.",
),
array(
$oneHundredIntMax,
"Interval overflow, value must be lower than '{$maxValue}', but '{$oneHundredIntMax}' passed.",
),
array(
$oneThousandIntMax,
"Interval overflow, value must be lower than '{$maxValue}', but '{$oneThousandIntMax}' passed.",
),
array(
$tenMillionsIntMax,
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenMillionsIntMax}' passed.",
),
array(
$tenThousandsTimesIntMax,
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenThousandsTimesIntMax}' passed.",
),
);
yield [
$oversizeInterval,
"Interval overflow, value must be lower than '{$maxValue}', but '{$oversizeInterval}' passed."
];
yield [
$oneMaxValue,
"Interval overflow, value must be lower than '{$maxValue}', but '{$oneMaxValue}' passed.",
];
yield [
$tenMaxValue,
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenMaxValue}' passed.",
];
yield [
$tenMillionsMaxValue,
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenMillionsMaxValue}' passed.",
];
yield [
$intMax,
"Interval overflow, value must be lower than '{$maxValue}', but '{$intMax}' passed.",
];
yield [
$oneIntMax,
"Interval overflow, value must be lower than '{$maxValue}', but '{$oneIntMax}' passed.",
];
yield [
$tenIntMax,
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenIntMax}' passed.",
];
yield [
$oneHundredIntMax,
"Interval overflow, value must be lower than '{$maxValue}', but '{$oneHundredIntMax}' passed.",
];
yield [
$oneThousandIntMax,
"Interval overflow, value must be lower than '{$maxValue}', but '{$oneThousandIntMax}' passed.",
];
yield [
$tenMillionsIntMax,
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenMillionsIntMax}' passed.",
];
yield [
$tenThousandsTimesIntMax,
"Interval overflow, value must be lower than '{$maxValue}', but '{$tenThousandsTimesIntMax}' passed.",
];
}
}
16 changes: 3 additions & 13 deletions tests/StreamSelectLoopTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ public function testStreamSelectTimeoutEmulation()

public function testStreamSelectReportsWarningForStreamWithFilter()
{
if (defined('HHVM_VERSION')) {
$this->markTestSkipped('Not supported on legacy HHVM');
}

$stream = tmpfile();
stream_filter_append($stream, 'string.rot13');

Expand Down Expand Up @@ -80,10 +76,6 @@ public function testStreamSelectReportsWarningForStreamWithFilter()

public function testStreamSelectThrowsWhenCustomErrorHandlerThrowsForStreamWithFilter()
{
if (defined('HHVM_VERSION')) {
$this->markTestSkipped('Not supported on legacy HHVM');
}

$stream = tmpfile();
stream_filter_append($stream, 'string.rot13');

Expand Down Expand Up @@ -121,11 +113,9 @@ public function testStreamSelectThrowsWhenCustomErrorHandlerThrowsForStreamWithF

public function signalProvider()
{
return array(
array('SIGUSR1'),
array('SIGHUP'),
array('SIGTERM'),
);
yield ['SIGUSR1'];
yield ['SIGHUP'];
yield ['SIGTERM'];
}

/**
Expand Down

0 comments on commit eee05cc

Please sign in to comment.