Selenium tests are using the dev db instead of the test db

hi all,

I’m doing some selenium test cases using the yii webdriver extension and I have a problem with the databases. I have the DEV database and the TEST database which I configured in the main.php and in the test.php. The fixtures, the unit test cases and the setup of the selenium’s tests works perfectly in the TEST database, but when the browser is being used by selenium, it uses the DEV database.

Here are the codes:

phpunit.xml


<phpunit bootstrap="bootstrap.php"

		colors="false"

		convertErrorsToExceptions="true"

		convertNoticesToExceptions="true"

		convertWarningsToExceptions="true"

		stopOnFailure="false">


	<selenium>

		<browser name="Internet Explorer" browser="*iexplore" />

		<browser name="Firefox" browser="*firefox" />

	</selenium>


</phpunit>

bootstrap.php


<?php


// change the following paths if necessary

$yiit=dirname(__FILE__).'/../../../Yii_framework/framework/yiit.php';

$config=dirname(__FILE__).'/../config/test.php';


require_once($yiit);


//require_once(dirname(__FILE__).'/WebTestCase.php'); - since I'm using the webdriver extension, this is not necessary


Yii::createWebApplication($config);



Anyone has any idea why the override is not working?

appreciate it

Did you set TEST_BASE_URL correctly (it would be in WebTestCase class normally, not using the exstension) to index-test.php?

Hi, here it is


<?php


/**

 * Change the following URL based on your server configuration

 * Make sure the URL ends with a slash so that we can use relative URLs in test cases

 */

define('TEST_BASE_URL','http://localhost/Rafao_server/Yii_KombatoOnline/index-test.php/');


/**

 * The base class for functional test cases.

 * In this class, we set the base URL for the test application.

 * We also provide some common methods to be used by concrete test classes.

 */

class WebTestCase extends CWebTestCase

{

	/**

	 * Sets up before each test method runs.

	 * This mainly sets the base URL for the test application.

	 */

	protected function setUp()

	{

		parent::setUp();

		$this->setBrowserUrl(TEST_BASE_URL);

	}

}



here is the index-test.php


<?php

/**

 * This is the bootstrap file for test application.

 * This file should be removed when the application is deployed for production.

 */


// change the following paths if necessary

$yii=dirname(__FILE__).'/../Yii_framework/framework/yii.php';

$config=dirname(__FILE__).'/protected/config/test.php';


// remove the following line when in production mode

defined('YII_DEBUG') or define('YII_DEBUG',true);


require_once($yii);

Yii::createWebApplication($config)->run();



thank you for the help

Hm, looks normal.

If you enter http://localhost/Rafao_server/Yii_KombatoOnline/index-test.php/ directly to browser - do you get your test environment?

In you .htaccess file maybe you need to have redirects to index-test.php instead of index.php (if you get rid of index file in your urls)?

Sorry, but these are all ideas I have at the moment :).

You were RIGHT. It was the htaccess that was redirecting to the index.php. thank you.

Now I have to figure out how to have two htaccess, if that is possible.

thank you once more

Welcome and nice to hear you’ve found the problem :)