|
From: Marcus B. <ma...@wo...> - 2008-10-27 19:14:32
|
Hi... Taras Diakiw wrote: > 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. No. It tries to do the simplest thing, which is to allow test conflicts, but at least make them obvious. It's then up to the developer to resolve them, or to explicitely reset globals between tests. Here, of course, you want to do the opposite of normal behaviour. You actually want to maintain a global between tests (why?). This should be fine. Something odd is happening. > > 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. Unless each test is executed in it's own process, this is impossible. Right now that kills performance, although it will in future be added as an explicit option for particular test cases. > > 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.. This is to give the illusion that file scope variables will still be visible in the test methods )I think - can't remember). It imports these variables, but does not reset any other globals. Could you see if your variable is visible in get_declared_vars(). > Taras Diakiw yours, Marcus |