File tree Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -1101,6 +1101,21 @@ $I->seeInFormFields('//form[@id=my-form]', $form);
11011101 * ` param ` $params
11021102
11031103
1104+ ### seeInSession
1105+
1106+ Assert that a session attribute exists.
1107+
1108+ ``` php
1109+ <?php
1110+ $I->seeInSession('attrib');
1111+ $I->seeInSession('attrib', 'value');
1112+ ```
1113+
1114+ * ` param string ` $attrib
1115+ * ` param mixed|null ` $value
1116+ * ` return ` void
1117+
1118+
11041119### seeInSource
11051120
11061121Checks that the current page contains the given string in its
Original file line number Diff line number Diff line change @@ -845,6 +845,38 @@ public function logout()
845845 }
846846 }
847847 $ cookieJar ->flushExpiredCookies ();
848+ }
849+
850+ /**
851+ * Assert that a session attribute exists.
852+ *
853+ * ```php
854+ * <?php
855+ * $I->seeInSession('attrib');
856+ * $I->seeInSession('attrib', 'value');
857+ * ```
858+ *
859+ * @param string $attrib
860+ * @param mixed|null $value
861+ * @return void
862+ */
863+ public function seeInSession ($ attrib , $ value = null )
864+ {
865+ $ container = $ this ->_getContainer ();
848866
867+ if (!$ container ->has ('session ' )) {
868+ $ this ->fail ("Symfony container doesn't have 'session' service " );
869+ return ;
870+ }
871+
872+ $ session = $ this ->grabService ('session ' );
873+
874+ if (! $ session ->has ($ attrib )) {
875+ $ this ->fail ("No session attribute with name ' $ attrib' " );
876+ }
877+
878+ if (null !== $ value ) {
879+ $ this ->assertEquals ($ value , $ session ->get ($ attrib ));
880+ }
849881 }
850882}
You can’t perform that action at this time.
0 commit comments