We are going to deploy the new yiiframework.com website on March 23, 2018 from 8:00 to 12:00 UTC.
Website and Yii documentation will not be available in this time frame. Check the news for more details.

Yii 1.1: Functional tests independing from your urlManager settings


If you are testing your app and use urlManager in your config, sometimes you will find a problem: you want to test your site independing from urlManager settings. in that way you need to extend your WebTestCase class by this method:

public function createUrl($route,$params=array()) {
$url = explode('phpunit',Yii::app()->createUrl($route,$params));
return $url[1];

and in your tests you can use next 'open' constructions:


Total 1 comment

#2866 report it
Stamm at 2011/02/18 07:04am
Another way

Or you may set in bootsrap: $_SERVER['SERVER_NAME'] = 'site.com'; $_SERVER['PHP_SELF'] = '/index-test.php'; $_SERVER['SCRIPT_NAME'] = '/index-test.php'; $_SERVER['DOCUMENT_ROOT'] = dirname(FILE).'/../../'; $_SERVER['SCRIPT_FILENAME'] = $_SERVER['DOCUMENT_ROOT'] . '/index-test.php';

Leave a comment

Please to leave your comment.

Write new article