| 1 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/*
|
|
|
4 |
* This file is part of the symfony package.
|
|
|
5 |
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
|
|
|
6 |
*
|
|
|
7 |
* For the full copyright and license information, please view the LICENSE
|
|
|
8 |
* file that was distributed with this source code.
|
|
|
9 |
*/
|
|
|
10 |
|
|
|
11 |
include(dirname(__FILE__).'/../../../../../test/bootstrap/unit.php');
|
|
|
12 |
|
|
|
13 |
if (!isset($root_dir))
|
|
|
14 |
{
|
|
|
15 |
$root_dir = realpath(dirname(__FILE__).sprintf('/../%s/fixtures', isset($type) ? $type : 'functional'));
|
|
|
16 |
}
|
|
|
17 |
|
|
|
18 |
include $root_dir.'/config/ProjectConfiguration.class.php';
|
|
|
19 |
$configuration = ProjectConfiguration::getApplicationConfiguration($app, 'test', isset($debug) ? $debug : true);
|
|
|
20 |
sfContext::createInstance($configuration);
|
|
|
21 |
|
|
|
22 |
// remove all cache
|
|
|
23 |
sf_functional_test_shutdown();
|
|
|
24 |
register_shutdown_function('sf_functional_test_shutdown');
|
|
|
25 |
|
|
|
26 |
$configuration->initializeDoctrine();
|
|
|
27 |
if (isset($fixtures))
|
|
|
28 |
{
|
|
|
29 |
$configuration->loadFixtures($fixtures);
|
|
|
30 |
}
|
|
|
31 |
|
|
|
32 |
function sf_functional_test_shutdown_cleanup()
|
|
|
33 |
{
|
|
|
34 |
sfToolkit::clearDirectory(sfConfig::get('sf_cache_dir'));
|
|
|
35 |
sfToolkit::clearDirectory(sfConfig::get('sf_log_dir'));
|
|
|
36 |
$databases = glob(sfConfig::get('sf_data_dir') . '/*.sqlite');
|
|
|
37 |
foreach ($databases as $database)
|
|
|
38 |
{
|
|
|
39 |
unlink($database);
|
|
|
40 |
}
|
|
|
41 |
}
|
|
|
42 |
|
|
|
43 |
function sf_functional_test_shutdown()
|
|
|
44 |
{
|
|
|
45 |
// try/catch needed due to http://bugs.php.net/bug.php?id=33598
|
|
|
46 |
try
|
|
|
47 |
{
|
|
|
48 |
sf_functional_test_shutdown_cleanup();
|
|
|
49 |
}
|
|
|
50 |
catch (Exception $e)
|
|
|
51 |
{
|
|
|
52 |
echo $e.PHP_EOL;
|
|
|
53 |
}
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
return true;
|