PageRenderTime 55ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 1ms

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

https://bitbucket.org/hosseinzolfi/db-lab-spring-2011/
PHP | 68 lines | 45 code | 12 blank | 11 comment | 2 complexity | 1c84d412d015668ab7cb8dbe02d97e4f 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. $_test_dir = realpath(dirname(__FILE__).'/..');
  15. require_once($_test_dir.'/../lib/vendor/lime/lime.php');
  16. require_once($_test_dir.'/../lib/config/sfConfig.class.php');
  17. sfConfig::set('sf_symfony_lib_dir', realpath($_test_dir.'/../lib'));
  18. require_once(dirname(__FILE__).'/../../lib/autoload/sfCoreAutoload.class.php');
  19. sfCoreAutoload::register();
  20. require_once(dirname(__FILE__).'/../../lib/util/sfToolkit.class.php');
  21. sfConfig::set('sf_test_cache_dir', sys_get_temp_dir().'/sf_test_project');
  22. // remove all test cache
  23. sf_unit_test_shutdown();
  24. // create test cache dir
  25. $sf_root_dir = sys_get_temp_dir().'/sf_test_project';
  26. @mkdir($sf_root_dir, 0777, true);
  27. register_shutdown_function('sf_unit_test_shutdown');
  28. function sf_unit_test_shutdown()
  29. {
  30. $sf_root_dir = sys_get_temp_dir().'/sf_test_project';
  31. if(is_dir($sf_root_dir))
  32. {
  33. sfToolkit::clearDirectory($sf_root_dir);
  34. @rmdir($sf_root_dir);
  35. }
  36. $sessions = glob(sys_get_temp_dir().'/sessions*');
  37. $tmp_files = glob(sys_get_temp_dir().'/sf*');
  38. $files = array_merge((empty($sessions) ? array() : $sessions), (empty($tmp_files) ? array() : $tmp_files));
  39. foreach ($files as $file)
  40. {
  41. if(is_dir($file))
  42. {
  43. sfToolkit::clearDirectory($file);
  44. @rmdir($file);
  45. }
  46. else
  47. {
  48. @unlink($file);
  49. }
  50. }
  51. }
  52. // Helper for cross platform testcases that validate output
  53. function fix_linebreaks($content)
  54. {
  55. return str_replace(array("\r\n", "\n", "\r"), "\n", $content);
  56. }