PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/extras/tests/TestHelper.php

https://bitbucket.org/ksekar/campus
PHP | 85 lines | 31 code | 8 blank | 46 comment | 9 complexity | acae991a9c2845b9152b91f56ad2bed4 MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.0, MIT
  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: TestHelper.php 23646 2011-01-21 17:35:37Z mikaelkael $
  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. if (version_compare($phpunitVersion, '3.6.0', '>=')) {
  29. echo 'This verison of PHPUnit is not supported in Zend Framework 1.x unit tests.';
  30. exit(1);
  31. }
  32. require_once 'PHPUnit/Autoload.php'; // >= PHPUnit 3.5.5
  33. } else {
  34. require_once 'PHPUnit/Framework.php'; // < PHPUnit 3.5.5
  35. }
  36. /*
  37. * Set error reporting to the level to which Zend Framework code must comply.
  38. */
  39. error_reporting(E_ALL | E_STRICT);
  40. /*
  41. * Determine the root, library, and tests directories of the framework
  42. * distribution.
  43. */
  44. $zfRoot = realpath(dirname(dirname(__FILE__)));
  45. $zfCoreLibrary = "$zfRoot/library";
  46. $zfCoreTests = "$zfRoot/tests";
  47. /*
  48. * Prepend the Zend Framework library/ and tests/ directories to the
  49. * include_path. This allows the tests to run out of the box and helps prevent
  50. * loading other copies of the framework code and tests that would supersede
  51. * this copy.
  52. */
  53. $path = array(
  54. $zfCoreLibrary,
  55. $zfCoreTests,
  56. get_include_path()
  57. );
  58. set_include_path(implode(PATH_SEPARATOR, $path));
  59. /*
  60. * Load the user-defined test configuration file, if it exists; otherwise, load
  61. * the default configuration.
  62. */
  63. if (is_readable($zfCoreTests . DIRECTORY_SEPARATOR . 'TestConfiguration.php')) {
  64. require_once $zfCoreTests . DIRECTORY_SEPARATOR . 'TestConfiguration.php';
  65. } else {
  66. require_once $zfCoreTests . DIRECTORY_SEPARATOR . 'TestConfiguration.php.dist';
  67. }
  68. /**
  69. * Start output buffering, if enabled
  70. */
  71. if (defined('TESTS_ZEND_OB_ENABLED') && constant('TESTS_ZEND_OB_ENABLED')) {
  72. ob_start();
  73. }
  74. /*
  75. * Unset global variables that are no longer needed.
  76. */
  77. unset($zfRoot, $zfCoreLibrary, $zfCoreTests, $path);