Skip to content

Commit 1d55dce

Browse files
committed
poll: update the backend name in tests
1 parent ece92c7 commit 1d55dce

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

ext/standard/tests/poll/poll.inc

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,22 @@
33

44
function pt_new_stream_poll(): Io\Poll\Context {
55
$backend = getenv('POLL_TEST_BACKEND');
6-
return new Io\Poll\Context($backend === false ? Io\Poll\Backend::Auto : Io\Poll\Backend::from($backend));
6+
if ($backend === false) {
7+
return new Io\Poll\Context(Io\Poll\Backend::Auto);
8+
}
9+
10+
// Map string to enum case using match
11+
$backend_enum = match(strtolower($backend)) {
12+
'auto' => Io\Poll\Backend::Auto,
13+
'poll' => Io\Poll\Backend::Poll,
14+
'epoll' => Io\Poll\Backend::Epoll,
15+
'kqueue' => Io\Poll\Backend::Kqueue,
16+
'eventports' => Io\Poll\Backend::EventPorts,
17+
'wsapoll' => Io\Poll\Backend::WSAPoll,
18+
default => throw new ValueError("Unknown backend: $backend"),
19+
};
20+
21+
return new Io\Poll\Context($backend_enum);
722
}
823

924
function pt_stream_poll_add($poll_ctx, $stream, $events, $data = null): Io\Poll\Watcher {
@@ -157,7 +172,7 @@ function pt_expect_events($watchers, $expected, ?Io\Poll\Context $poll_ctx = nul
157172

158173
// Check if events field is a backend-specific map (associative array with string keys)
159174
if (isset($exp_event['events']) && is_array($exp_event['events'])) {
160-
// Check if it's a backend map (has string keys like 'default', 'kqueue', etc.)
175+
// Check if it's a backend map (has string keys like 'default', 'Kqueue', etc.)
161176
$keys = array_keys($exp_event['events']);
162177
$is_backend_map = false;
163178
foreach ($keys as $key) {
@@ -246,7 +261,7 @@ function pt_resolve_backend_specific_value($backend_map, $current_backend) {
246261
return $backend_map[$current_backend];
247262
}
248263

249-
// Check for multi-backend keys (e.g., "poll|epoll")
264+
// Check for multi-backend keys (e.g., "Kqueue|EventPorts")
250265
foreach ($backend_map as $key => $value) {
251266
if (strpos($key, '|') !== false) {
252267
$backends = array_map('trim', explode('|', $key));

ext/standard/tests/poll/poll_stream_sock_rw_close.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pt_expect_events($poll_ctx->wait(100), [
1717
[
1818
'events' => [
1919
'default' => [Io\Poll\Event::Write, Io\Poll\Event::Error, Io\Poll\Event::HangUp],
20-
'kqueue|eventport' => [Io\Poll\Event::Write, Io\Poll\Event::HangUp],
20+
'Kqueue|EventPorts' => [Io\Poll\Event::Write, Io\Poll\Event::HangUp],
2121
],
2222
'data' => 'socket2_data'
2323
]

0 commit comments

Comments
 (0)