Hi team
I’m trying to do some neat things with unit testing in EE, and one of the biggest things getting in my way (believe it or not) is the PHP4-style variable reference assignments (=&) in system/codeigniter/system/core/CodeIgniter.php.
The reason for this is that if I require that file from within a function, the variables no longer have global scope. I would normally be able to work around this by declaring the globals manually (global $CFG etc), however PHP does not allow global variables defined inside a function to be assigned to by reference (source).
Ideally, you could replace all of these $CFG variables with the $GLOBALS[‘CFG’] syntax, so it is clear that they are always defined globally. However, if that is not possible, would you be able to simply remove the =& variable assignments (which have no effect in PHP5 anyway)?
Example:
$EXT =& load_class('Hooks', 'core');Desired:
$EXT = load_class('Hooks', 'core');Thanks!
Ok. Well as long as it’s going to be the release after that, it would be awesome if you could separate the EE initialization code (loading classes, db configuration) from the actual page rendering. And also remove as much global state (global variables, constants etc) as possible.
I’m really just hacking around the EE loading code so that I can run PHPUnit tests and have EE methods work correctly. To do this, I need to initialize EE without actually rendering anything. Previously I simply mocked out the entire EE global object in my tests, however it’s a much better test of the whole system if some EE classes are available (especially when API changes are introduced in new versions of EE).
Ok. Well as long as it’s going to be the release after that, it would be *awesome* if you could separate the EE initialization code (loading classes, db configuration) from the actual page rendering. And also remove as much global state (global variables, constants etc) as possible.
We’d certainly like to head that direction, but it’ll be far longer before that. We should be able to replace the reference assignments for the next maintenance release though.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.