|
3 | 3 |
|
4 | 4 | function pt_new_stream_poll(): Io\Poll\Context { |
5 | 5 | $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); |
7 | 22 | } |
8 | 23 |
|
9 | 24 | 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 |
157 | 172 |
|
158 | 173 | // Check if events field is a backend-specific map (associative array with string keys) |
159 | 174 | 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.) |
161 | 176 | $keys = array_keys($exp_event['events']); |
162 | 177 | $is_backend_map = false; |
163 | 178 | foreach ($keys as $key) { |
@@ -246,7 +261,7 @@ function pt_resolve_backend_specific_value($backend_map, $current_backend) { |
246 | 261 | return $backend_map[$current_backend]; |
247 | 262 | } |
248 | 263 |
|
249 | | - // Check for multi-backend keys (e.g., "poll|epoll") |
| 264 | + // Check for multi-backend keys (e.g., "Kqueue|EventPorts") |
250 | 265 | foreach ($backend_map as $key => $value) { |
251 | 266 | if (strpos($key, '|') !== false) { |
252 | 267 | $backends = array_map('trim', explode('|', $key)); |
|
0 commit comments