CodeIgniter Forums
Functional testing of pages that require a login using SimpleTest - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Functional testing of pages that require a login using SimpleTest (/showthread.php?tid=19784)



Functional testing of pages that require a login using SimpleTest - El Forum - 06-18-2009

[eluser]topherdan1[/eluser]
Hello,

I have integrated the SimpleTest library with my CodeIgniter application. I am able to run basic unit and functional tests without a problem. When I try to run tests which require the user to login, though, the code always fails. Here is what I am trying:

Code:
//Set the user credentials
$email = 'tester';
$password = 'tester';

//Login the user
$this->post(base_url().'users/login', array('email'=>$email, 'password'=>$password);

//Verify that the login worked
$this->assertTitle(new PatternExpectation('/testers\'s Profile/'));

When I looked in the sessions table in the database, I can see that the code logged the user in and stored the user_data fields correctly. The issue is the that cookie that SimpleTest sends is not the cookie that CodeIgniter set. I have tried using $this->_browser->useCookies(), but I still am not able to login.

Does anyone have any suggestions on how to get this to work?

Thanks!