PageRenderTime 48ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 1ms

/tests/TestHelper.php

https://github.com/joedevon/Shanty-Mongo
PHP | 68 lines | 32 code | 10 blank | 26 comment | 5 complexity | ba83ad664e6ab7786e7adf991fbca00a MD5 | raw file
Possible License(s): BSD-3-Clause
  1. <?php
  2. /*
  3. * Set error reporting to the level
  4. */
  5. error_reporting(E_ALL | E_STRICT);
  6. /*
  7. * Determine the root, library, and tests directories of the framework
  8. * distribution.
  9. */
  10. $root = realpath(dirname(dirname(__FILE__)));
  11. $coreLibrary = "$root/library";
  12. $coreTests = "$root/tests";
  13. /*
  14. * Load the user-defined test configuration file, if it exists; otherwise, load
  15. * the default configuration.
  16. */
  17. if (is_readable($coreTests . DIRECTORY_SEPARATOR . 'TestConfiguration.php')) {
  18. require_once $coreTests . DIRECTORY_SEPARATOR . 'TestConfiguration.php';
  19. } else {
  20. require_once $coreTests . DIRECTORY_SEPARATOR . 'TestConfiguration.php.dist';
  21. }
  22. if (is_null(ZEND_FRAMEWORK_PATH)) {
  23. die("Please configure the path to your Zend Framework library by setting the constant 'ZEND_FRAMEWORK_PATH' in your TestConfigureation.php file.");
  24. }
  25. /*
  26. * Set include path
  27. */
  28. $path = array(
  29. $coreLibrary,
  30. $coreTests,
  31. ZEND_FRAMEWORK_PATH,
  32. get_include_path()
  33. );
  34. set_include_path(implode(PATH_SEPARATOR, $path));
  35. if (defined('TESTS_GENERATE_REPORT') && TESTS_GENERATE_REPORT === true &&
  36. version_compare(PHPUnit_Runner_Version::id(), '3.1.6', '>=')) {
  37. /*
  38. * Add library/ directory to the PHPUnit code coverage
  39. * whitelist. This has the effect that only production code source files
  40. * appear in the code coverage report and that all production code source
  41. * files, even those that are not covered by a test yet, are processed.
  42. */
  43. PHPUnit_Util_Filter::addDirectoryToWhitelist($coreLibrary);
  44. /*
  45. * Omit from code coverage reports the contents of the tests directory
  46. */
  47. foreach (array('.php', '.phtml', '.csv', '.inc') as $suffix) {
  48. PHPUnit_Util_Filter::addDirectoryToFilter($coreTests, $suffix);
  49. }
  50. PHPUnit_Util_Filter::addDirectoryToFilter(PEAR_INSTALL_DIR);
  51. PHPUnit_Util_Filter::addDirectoryToFilter(PHP_LIBDIR);
  52. PHPUnit_Util_Filter::addDirectoryToFilter(ZEND_FRAMEWORK_PATH);
  53. PHPUnit_Util_Filter::addDirectoryToFilter($coreTests);
  54. }
  55. /*
  56. * Unset global variables that are no longer needed.
  57. */
  58. unset($root, $coreLibrary, $coreTests, $path);