TestHelper.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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-2015 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 (version_compare(PHPUnit_Runner_Version::id(), '4.0.0', '<')) {
  26. require_once 'PHPUnit/Runner/Version.php';
  27. $phpunitVersion = PHPUnit_Runner_Version::id();
  28. if ($phpunitVersion == '@package_version@' || version_compare($phpunitVersion, '3.5.5', '>=')) {
  29. require_once 'PHPUnit/Autoload.php'; // >= PHPUnit 3.5.5
  30. } else {
  31. require_once 'PHPUnit/Framework.php'; // < PHPUnit 3.5.5
  32. }
  33. }
  34. /*
  35. * Set error reporting to the level to which Zend Framework code must comply.
  36. */
  37. error_reporting(E_ALL | E_STRICT);
  38. /*
  39. * Determine the root, library, and tests directories of the framework
  40. * distribution.
  41. */
  42. $zfRoot = realpath(dirname(dirname(__FILE__)));
  43. $zfCoreLibrary = "$zfRoot/library";
  44. $zfCoreTests = "$zfRoot/tests";
  45. /*
  46. * Prepend the Zend Framework library/ and tests/ directories to the
  47. * include_path. This allows the tests to run out of the box and helps prevent
  48. * loading other copies of the framework code and tests that would supersede
  49. * this copy.
  50. */
  51. $path = array(
  52. $zfCoreLibrary,
  53. $zfCoreTests,
  54. get_include_path()
  55. );
  56. set_include_path(implode(PATH_SEPARATOR, $path));
  57. /*
  58. * Load the user-defined test configuration file, if it exists; otherwise, load
  59. * the default configuration.
  60. */
  61. if (is_readable($zfCoreTests . DIRECTORY_SEPARATOR . 'TestConfiguration.php')) {
  62. require_once $zfCoreTests . DIRECTORY_SEPARATOR . 'TestConfiguration.php';
  63. } else {
  64. require_once $zfCoreTests . DIRECTORY_SEPARATOR . 'TestConfiguration.php.dist';
  65. }
  66. /**
  67. * Start output buffering, if enabled
  68. */
  69. if (defined('TESTS_ZEND_OB_ENABLED') && constant('TESTS_ZEND_OB_ENABLED')) {
  70. ob_start();
  71. }
  72. /*
  73. * Unset global variables that are no longer needed.
  74. */
  75. unset($zfRoot, $zfCoreLibrary, $zfCoreTests, $path);
  76. // Suppress DateTime warnings
  77. date_default_timezone_set(@date_default_timezone_get());