-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
TestHelper.php
69 lines (60 loc) · 1.77 KB
/
TestHelper.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/*
* Start output buffering
*/
ob_start();
/*
* Set error reporting to the level to which Zend Framework code must comply.
*/
error_reporting( E_ALL | E_STRICT );
/*
* Set default timezone
*/
date_default_timezone_set('GMT');
/*
* Determine the root, library, tests, and models directories
*/
$root = realpath(dirname(__FILE__) . '/../');
$library = $root . '/library';
$tests = $root . '/tests';
$models = $root . '/application/models';
$controllers = $root . '/application/controllers';
/*
* Prepend the library/, tests/, and models/ directories to the
* include_path. This allows the tests to run out of the box.
*/
$path = array(
$models,
$library,
$tests,
get_include_path()
);
set_include_path(implode(PATH_SEPARATOR, $path));
/**
* Register autoloader
*/
require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();
/*
* Add library/ and models/ directory to the PHPUnit code coverage
* whitelist. This has the effect that only production code source files appear
* in the code coverage report and that all production code source files, even
* those that are not covered by a test yet, are processed.
*/
if (defined('TESTS_GENERATE_REPORT') && TESTS_GENERATE_REPORT === true &&
version_compare(PHPUnit_Runner_Version::id(), '3.1.6', '>=')) {
PHPUnit_Util_Filter::addDirectoryToWhitelist($library);
PHPUnit_Util_Filter::addDirectoryToWhitelist($models);
PHPUnit_Util_Filter::addDirectoryToWhitelist($controllers);
}
/**
* Setup default DB adapter
*/
$db = Zend_Db::factory('pdo_sqlite', array(
'dbname' => $root . '/data/db/bugs.db',
));
Zend_Db_Table_Abstract::setDefaultAdapter($db);
/*
* Unset global variables that are no longer needed.
*/
unset($root, $library, $models, $controllers, $tests, $path);