Hi Guys,
I’m adapting to TDD and therefor I’m new to the concept. So I have been reading/ the testing section mentioned in the Yii documentation.
At the moment I want to do a functional test for a module called ‘geo’ which handles Countries, states/ provinces, and cities.
To begin my functional testing, I have thought to test Country section first. For this I have created CountryTest.php file in protected/tests/functiona/geo/ path. Now from the browser the countries can be listed by visiting "http://localhost/somesite/index-test.php/locations/country"
In this page, there is a link to create a country. If the user is logged in and has access to create a country, the create page will be displayed. So I’ve added the following test to CountryTest.php.
public function testCreateCountry() {
$this->open('locations/country');
$this->assertElementPresent('link=Create');
$this->clickAndWait('link=Create');
$this->assertElementPresent('name=Country[name]');
}
However since I’m doing functional testing with Selenium, once the $this->clickAndWait(‘link=Create’); statement is executed, the browser is redirected to site/login page. Therefore my last assert statement in the test fails.
So my question is, how to login an user (e.g. admin) so that I can pass this test?
Also if you think I’m doing something in the wrong way, please guide me. Thanks a lot.