Functional tests independing from your urlManager settings

0 0
4
Viewed: 14 282 times
Version: Unknown (update)
Category: Tips
Written by: RusAlex RusAlex
Updated by: RusAlex RusAlex
Created: Feb 18, 2011
Updated: 15 years ago

You are viewing revision #1 of this wiki article.
This is the latest version of this article.

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:

$this->open($this->createUrl('user/view',array('id'=>$user->id)));