Skip to content

Commit f5c4caa

Browse files
use regex with full string match on SSE response keys (#949)
1 parent ddc6cf0 commit f5c4caa

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

tests/DemoCallExitTest.php

+9-3
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,19 @@ public function testDemoAssertSSEResponse(string $uri)
154154
$this->assertGreaterThan(0, count($output_rows), ' Response is empty on '.$uri);
155155
// check SSE Syntax
156156
foreach ($output_rows as $index => $sse_line) {
157-
if (empty($sse_line) || $sse_line === null) {
157+
if (empty($sse_line)) {
158158
continue;
159159
}
160160

161-
preg_match('/^[id|event|data].*$/', $sse_line, $matches);
161+
$matches = [];
162+
163+
preg_match_all('/^(id|event|data).*$/m', $sse_line, $matches);
164+
165+
$sse_string = str_ireplace(["\r", "\n"], '', $sse_line);
166+
$format_match_string = implode('', $matches[0] ?? ['error']);
167+
162168
$this->assertEquals(
163-
$sse_line, $matches[0] ?? 'error',
169+
$sse_string, $format_match_string,
164170
' Testing SSE response line '.$index.' with content '.$sse_line.' on '.$uri
165171
);
166172
}

0 commit comments

Comments
 (0)