File tree Expand file tree Collapse file tree 1 file changed +51
-0
lines changed
src/Codeception/Module/Laravel Expand file tree Collapse file tree 1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change 66
77trait InteractsWithSession
88{
9+ /**
10+ * Assert that a session attribute does not exist, or is not equal to the passed value.
11+ *
12+ * ```php
13+ * <?php
14+ * $I->dontSeeInSession('attribute');
15+ * $I->dontSeeInSession('attribute', 'value');
16+ * ```
17+ *
18+ * @param string|array $key
19+ * @param mixed|null $value
20+ */
21+ public function dontSeeInSession ($ key , $ value = null ): void
22+ {
23+ if (is_array ($ key )) {
24+ $ this ->dontSeeSessionHasValues ($ key );
25+ return ;
26+ }
27+
28+ $ session = $ this ->getSession ();
29+
30+ if (null === $ value ) {
31+ if ($ session ->has ($ key )) {
32+ $ this ->fail ("Session variable with key ' {$ key }' does exist " );
33+ }
34+ }
35+ else {
36+ $ this ->assertNotSame ($ value , $ session ->get ($ key ));
37+ }
38+ }
39+
40+ /**
41+ * Assert that the session does not have a particular list of values.
42+ *
43+ * ```php
44+ * <?php
45+ * $I->dontSeeSessionHasValues(['key1', 'key2']);
46+ * $I->dontSeeSessionHasValues(['key1' => 'value1', 'key2' => 'value2']);
47+ * ```
48+ */
49+ public function dontSeeSessionHasValues (array $ bindings ): void
50+ {
51+ foreach ($ bindings as $ key => $ value ) {
52+ if (is_int ($ key )) {
53+ $ this ->dontSeeInSession ($ value );
54+ } else {
55+ $ this ->dontSeeInSession ($ key , $ value );
56+ }
57+ }
58+ }
59+
960 /**
1061 * Flush all of the current session data.
1162 */
You can’t perform that action at this time.
0 commit comments