TestHelper.php 2.5 KB

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