File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
src/Codeception/Module/Laravel Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change 66
77trait InteractsWithSession
88{
9+ /**
10+ * Set the session to the given array.
11+ */
12+ public function haveInSession (array $ data ): void
13+ {
14+ $ this ->startSession ();
15+
16+ foreach ($ data as $ key => $ value ) {
17+ $ this ->getSession ()->put ($ key , $ value );
18+ }
19+ }
20+
921 /**
1022 * Assert that a session variable exists.
1123 *
@@ -55,4 +67,23 @@ public function seeSessionHasValues(array $bindings): void
5567 }
5668 }
5769 }
70+
71+ /**
72+ * Flush all of the current session data.
73+ */
74+ public function flushSession (): void
75+ {
76+ $ this ->startSession ();
77+ $ this ->getSession ()->flush ();
78+ }
79+
80+ /**
81+ * Start the session for the application.
82+ */
83+ protected function startSession (): void
84+ {
85+ if (! $ this ->getSession ()->isStarted ()) {
86+ $ this ->getSession ()->start ();
87+ }
88+ }
5889}
You can’t perform that action at this time.
0 commit comments