Yii Framework Forum: Yii Test bootstrap.php does not load global parameters - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yii Test bootstrap.php does not load global parameters Rate Topic: -----

#1 User is offline   jordan_v86 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 17-October 11

Posted 10 August 2012 - 07:57 AM

I tried running a PHPUnit test from Yii today (and eventually succeeded). But I bumped into some issues.
The bootstrap.php file, used to load the environment for testing, loads the main.php file containing all application settings. In our case, the main.php file contains a bunch of global parameters which are configured in the params.php file:

ex:

array(
	'class'=>'CFileLogRoute',
	'levels'=>'error, warning, info',
	'logPath'=>LOG_PATH,
	'logFile'=>LOG_FILE,
),


The bootstrap.php file however does not load the params.php file. This causes the execution of the main.php file to fail because of undifined constant errors:
PHP Notice: Use of undefined constant LOG_FILE - assumed 'LOG_FILE' in my/path/protected/config/main.php on line 94

I fixed it by adding some code to the bootstrap script which loads the params.php file (I found the code in the index.php file)

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

include_once($config_params);
foreach($params as $key=>$value) {
	defined($key) or define($key, $value);
}


Now there are 2 possibilities:
1. The bootstrap.php file should indeed load the params.php file in order to make it work (when using params in main.php) but for some reason the code is not in the bootstrap.php file.
2. I'm missing something here and I shouldn't have had any problems with the parameters used in the mail.php file.

Is there anybody who can clear this up?

Thanks!
Jordan
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users