PageRenderTime 51ms CodeModel.GetById 30ms app.highlight 2ms RepoModel.GetById 18ms app.codeStats 0ms

/tests/TestHelper.php

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