|
From: Taras D. <Tar...@pr...> - 2008-10-27 15:32:32
|
Hi everyone,
I have a configuration file, which is required_once, and sets a global variable called 'root_path'.
However, when simpletest runs the third test in a test suite, root_path is unitialised. I am certain that root_path does, in fact, get set to something prior to this point, as I have set up a break point at the line which sets root_path (which gets hit).
config.php
-------------
$root_path = 'blah';
and then SimpleTest will load FooUnitTest as part of the 'All' Test Suite
FooUnitTest
---------------
require_once('config.php'); // doesn't get included... config.php is included as part of the Test Prolog
require_once($root_path.'Bar.php'); // fails because the $root_path global variable is unitialised at this stage
I was wondering if SimpleTest changes global variables between unit tests. This is the only explanation of the $root_path variable being unitialised that I can think of, as my code does not explicitly unset it.
If, in fact, SimpleTest *does* unset all of the global variables between unit tests, shouldn't it also reset the state of whether files have been included or not.
After the following line in the 'load' function in test_case.php gets run:
$existing_globals = get_defined_vars();
include_once($test_file);
$existing_globals does not contain the $root_path variable..
?
Taras Diakiw
Software Developer
Practical Law Company
T: +44 (0) 20 7202 1200 ext 5629
F: +44 (0) 20 7202 1211
W: http://www.practicallaw.com
This e-mail from Practical Law Company (http://www.practicallaw.com) is subject to our terms of use (http://www.practicallaw.com/9-103-0884). Information about our companies: Practical Law Company Limited. Registered in England and Wales. Registered Number: 02889191. Registered Office: 19 Hatfields, London SE1 8DJ. Telephone: +44(0)20 7202 1200. Practical Law Company, Inc. Incorporated in Delaware, USA. Corporate Office: 747 Third Avenue, 36th Floor, New York, NY 10017. Telephone: +1(646) 562-3400.
|