Skip to content

Commit b1d32e0

Browse files
committed
FIx units tests
1 parent 9d674db commit b1d32e0

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

tests/MoreOptionsTestCase.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,39 @@ protected function getCurrentConfig(): Config
131131
}
132132
return $config;
133133
}
134+
135+
/**
136+
* Get and clear session messages after redirect
137+
* @return array<int, array<int, string>>
138+
*/
139+
protected function getSessionMessages(): array
140+
{
141+
$messages = $_SESSION['MESSAGE_AFTER_REDIRECT'] ?? [];
142+
$_SESSION['MESSAGE_AFTER_REDIRECT'] = [];
143+
return $messages;
144+
}
145+
146+
/**
147+
* Assert that a specific error message was added to session
148+
*/
149+
protected function assertHasSessionMessage(string $expectedMessage, int $type = ERROR): void
150+
{
151+
$messages = $_SESSION['MESSAGE_AFTER_REDIRECT'][$type] ?? [];
152+
$found = false;
153+
foreach ($messages as $message) {
154+
if (str_contains($message, $expectedMessage)) {
155+
$found = true;
156+
break;
157+
}
158+
}
159+
$this->assertTrue($found, "Expected message not found: {$expectedMessage}");
160+
}
161+
162+
/**
163+
* Clear all session messages
164+
*/
165+
protected function clearSessionMessages(): void
166+
{
167+
$_SESSION['MESSAGE_AFTER_REDIRECT'] = [];
168+
}
134169
}

0 commit comments

Comments
 (0)