TestHelper.php 2.3 KB

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