File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments