TestHelper.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /*
  23. * Include PHPUnit dependencies
  24. */
  25. if (!@fopen('PHPUnit/Autoload.php', 'r', true)) {
  26. require_once 'PHPUnit/Framework.php'; // < PHPUnit 3.5.5
  27. } else {
  28. require_once 'PHPUnit/Autoload.php'; // >= of PHPUnit 3.5.5
  29. }
  30. /*
  31. * Set error reporting to the level to which Zend Framework code must comply.
  32. */
  33. error_reporting( E_ALL | E_STRICT );
  34. /*
  35. * Determine the root, library, and tests directories of the framework
  36. * distribution.
  37. */
  38. $zfRoot = realpath(dirname(dirname(__FILE__)));
  39. $zfCoreLibrary = "$zfRoot/library";
  40. $zfCoreTests = "$zfRoot/tests";
  41. /*
  42. * Prepend the Zend Framework library/ and tests/ directories to the
  43. * include_path. This allows the tests to run out of the box and helps prevent
  44. * loading other copies of the framework code and tests that would supersede
  45. * this copy.
  46. */
  47. $path = array(
  48. $zfCoreLibrary,
  49. $zfCoreTests,
  50. get_include_path()
  51. );
  52. set_include_path(implode(PATH_SEPARATOR, $path));
  53. /*
  54. * Load the user-defined test configuration file, if it exists; otherwise, load
  55. * the default configuration.
  56. */
  57. if (is_readable($zfCoreTests . DIRECTORY_SEPARATOR . 'TestConfiguration.php')) {
  58. require_once $zfCoreTests . DIRECTORY_SEPARATOR . 'TestConfiguration.php';
  59. } else {
  60. require_once $zfCoreTests . DIRECTORY_SEPARATOR . 'TestConfiguration.php.dist';
  61. }
  62. /**
  63. * Start output buffering, if enabled
  64. */
  65. if (defined('TESTS_ZEND_OB_ENABLED') && constant('TESTS_ZEND_OB_ENABLED')) {
  66. ob_start();
  67. }
  68. /*
  69. * Unset global variables that are no longer needed.
  70. */
  71. unset($zfRoot, $zfCoreLibrary, $zfCoreTests, $path);