I'm trying to get familiar with PHPUnit testing within Kohana. At the moment, I seem to be having problems with Request::current()->redirect calls in my code.
For example, I am trying to test the login functionality. Once our user is successfully logged in, we redirect it to its home page using the above Request redirect line. The problem is that when that line is there, the test seems to stop there and never return the results.
Here is how my tests is written at the moment:
class SampleTest extends Kohana_UnitTest_TestCase
{
protected $session;
public function setUp() {
parent::setUp();
$this->session = Session::instance();
}
public function testLogin()
{
$request = new Request('/login');
$request->method(HTTP_Request::POST)
->post(array('username' => 'username', 'password' => 'password'));
$request->execute();
$this->assertEquals($this->session->get('username'), 'password');
}
}
If I comment out the following line in my login controller, everything works great:
Request::current()->redirect(); //redirect to home
What am I doing wrong?