forked from icon-pcs/cakephp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_bootstrap.php
49 lines (40 loc) · 1.55 KB
/
test_bootstrap.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
<?php
exec(__DIR__ . "/fixturize_tmp_dir");
ini_set("memory_limit", "512M");
/**
* Cake doesn't have a way of configuring the path to the temp directory,
* so we have to set this constant before it can. We need to change the
* temp directory to be a folder which is not shared with the host OS,
* or the permissions-related tests will not pass.
*/
define("TMP", "/home/vagrant/caketmp/");
// other constants that need to be in place during a test run
// which were previously set by the shell bootstrap process
define("CONFIG", __DIR__ . "/app/Config/");
define('CORE_TEST_CASES', __DIR__ . '/lib/Cake/Test/Case');
// bootstrap the framework
require(__DIR__ . "/lib/Cake/Console/ShellDispatcher.php");
$shellDispatcher = new ShellDispatcher([
__DIR__ . "/Console/cake.php",
"-working",
__DIR__,
]);
// tell Cake's autoloader where to find various classes
// we need to do this before PHPUnit autoloads all the test files
App::uses("CakeTestCase", "TestSuite");
App::uses("CakeTestModel", "TestSuite/Fixture");
App::uses("CakeFixtureManager", "TestSuite/Fixture");
App::uses("CakeTestFixture", "TestSuite/Fixture");
App::uses("ClassRegistry", "Utility");
App::uses("AppHelper", "View/Helper");
// initialize the test DB(s)
$_SERVER["DB"] = $_SERVER["DB"] ?? "sqlite";
ClassRegistry::config(['ds' => 'test', 'testing' => true]);
CakeFixtureManager::initialize();
// ensures that PHPUnit's error handler is used during tests
restore_error_handler();
restore_error_handler();
restore_exception_handler();
restore_exception_handler();
// freeze the time
CakeTestCase::time();