CodeIgniter Forums
Feature Tests and Session - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=31)
+--- Thread: Feature Tests and Session (/showthread.php?tid=76673)



Feature Tests and Session - MGatner - 06-08-2020

Currently, running a Feature Test will start with a fresh Session when you make the call(). While this helps ensure that each test is “fresh” it means you cannot prep anything in the Session l, such as logging a user in. FeatureTest has withSession to help with this but not any means of handling at the test case level. This means, for example, if you were testing a controller that required authentication you would need to pass the same Auth session data in on every test. 

Has anyone used Feature Tests? If so how would you like to see session data handled?

Note, here is the line in question on FeatureTestTrait, mostly for my reference:
$_SESSION = $this->session ?? [];