PageRenderTime 52ms CodeModel.GetById 28ms RepoModel.GetById 1ms app.codeStats 0ms

/Group-I/jobeet/lib/vendor/symfony/test/bootstrap/functional.php

https://bitbucket.org/hosseinzolfi/db-lab-spring-2011/
PHP | 73 lines | 52 code | 11 blank | 10 comment | 3 complexity | b47734c813c689dfd472412feeca5913 MD5 | raw file
Possible License(s): ISC, AGPL-3.0, LGPL-2.1, BSD-3-Clause, LGPL-3.0
  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. // setup expected test environment (per check_configuration.php)
  10. ini_set('magic_quotes_runtime', 'off');
  11. ini_set('session.auto_start', 'off');
  12. ini_set('arg_separator.output', '&amp;');
  13. ini_set('allow_url_fopen', 'on');
  14. if (!isset($root_dir))
  15. {
  16. $root_dir = realpath(dirname(__FILE__).sprintf('/../%s/fixtures', isset($type) ? $type : 'functional'));
  17. }
  18. require_once $root_dir.'/config/ProjectConfiguration.class.php';
  19. $configuration = ProjectConfiguration::getApplicationConfiguration($app, 'test', isset($debug) ? $debug : true);
  20. // remove all cache
  21. sf_functional_test_shutdown();
  22. register_shutdown_function('sf_functional_test_shutdown');
  23. sfContext::createInstance($configuration);
  24. function sf_functional_test_shutdown_cleanup()
  25. {
  26. sfToolkit::clearDirectory(sfConfig::get('sf_cache_dir'));
  27. sfToolkit::clearDirectory(sfConfig::get('sf_log_dir'));
  28. $sf_root_dir = sys_get_temp_dir().'/sf_test_project';
  29. if (is_dir($sf_root_dir))
  30. {
  31. sfToolkit::clearDirectory($sf_root_dir);
  32. @rmdir($sf_root_dir);
  33. }
  34. $sessions = glob(sys_get_temp_dir().'/sessions*');
  35. $tmp_files = glob(sys_get_temp_dir().'/sf*');
  36. $files = array_merge(empty($sessions) ? array() : $sessions, empty($tmp_files) ? array() : $tmp_files);
  37. foreach ($files as $file)
  38. {
  39. if (is_dir($file))
  40. {
  41. sfToolkit::clearDirectory($file);
  42. @rmdir($file);
  43. }
  44. else
  45. {
  46. @unlink($file);
  47. }
  48. }
  49. }
  50. function sf_functional_test_shutdown()
  51. {
  52. // try/catch needed due to http://bugs.php.net/bug.php?id=33598
  53. try
  54. {
  55. sf_functional_test_shutdown_cleanup();
  56. }
  57. catch (Exception $e)
  58. {
  59. echo $e.PHP_EOL;
  60. }
  61. }
  62. return true;