blob: 8240d23401a5034ef6b0b204e8376164bdd4fb80 [file] [log] [blame]
Pascal Kriete69c97a72011-04-20 21:44:54 -04001<?php
Andrey Andreev4f0354f2015-01-12 14:40:24 +02002// For some reason, setting this fixes the 5.2 tests but breaks the 5.3 ones ...
3if (version_compare(PHP_VERSION, '5.3.0', '<'))
4{
5 ini_set('memory_limit', '128M');
6}
Pascal Kriete69c97a72011-04-20 21:44:54 -04007
Pascal Krietef5aee9d2011-04-21 01:20:40 -04008// Errors on full!
Pascal Kriete69c97a72011-04-20 21:44:54 -04009ini_set('display_errors', 1);
10error_reporting(E_ALL | E_STRICT);
11
Pascal Krietef5aee9d2011-04-21 01:20:40 -040012$dir = realpath(dirname(__FILE__));
Pascal Kriete69c97a72011-04-20 21:44:54 -040013
Pascal Krietef5aee9d2011-04-21 01:20:40 -040014// Path constants
Taufan Aditya4912f8b2012-05-26 22:09:58 +070015defined('PROJECT_BASE') OR define('PROJECT_BASE', realpath($dir.'/../').'/');
dchill427ecc5cd2012-10-12 16:25:51 -040016defined('SYSTEM_PATH') OR define('SYSTEM_PATH', PROJECT_BASE.'system/');
Pascal Kriete69c97a72011-04-20 21:44:54 -040017
Taufan Adityae13511a2012-05-25 02:15:42 +070018// Get vfsStream either via PEAR or composer
Taufan Adityaeeca6d22012-05-25 03:15:19 +070019foreach (explode(PATH_SEPARATOR, get_include_path()) as $path)
Taufan Aditya6bca9f82012-05-25 01:55:36 +070020{
Taufan Aditya2d574452012-05-25 04:03:56 +070021 if (file_exists($path.DIRECTORY_SEPARATOR.'vfsStream/vfsStream.php'))
Taufan Adityaeeca6d22012-05-25 03:15:19 +070022 {
23 require_once 'vfsStream/vfsStream.php';
24 break;
25 }
Taufan Aditya6bca9f82012-05-25 01:55:36 +070026}
Taufan Adityaeeca6d22012-05-25 03:15:19 +070027
28if ( ! class_exists('vfsStream') && file_exists(PROJECT_BASE.'vendor/autoload.php'))
Taufan Aditya6bca9f82012-05-25 01:55:36 +070029{
Taufan Adityae13511a2012-05-25 02:15:42 +070030 include_once PROJECT_BASE.'vendor/autoload.php';
31 class_alias('org\bovigo\vfs\vfsStream', 'vfsStream');
32 class_alias('org\bovigo\vfs\vfsStreamDirectory', 'vfsStreamDirectory');
33 class_alias('org\bovigo\vfs\vfsStreamWrapper', 'vfsStreamWrapper');
Taufan Aditya6bca9f82012-05-25 01:55:36 +070034}
35
dchill427ecc5cd2012-10-12 16:25:51 -040036// Define CI path constants to VFS (filesystem setup in CI_TestCase::setUp)
37defined('BASEPATH') OR define('BASEPATH', vfsStream::url('system/'));
38defined('APPPATH') OR define('APPPATH', vfsStream::url('application/'));
39defined('VIEWPATH') OR define('VIEWPATH', APPPATH.'views/');
Andrey Andreev76384792013-01-28 11:22:05 +020040defined('ENVIRONMENT') OR define('ENVIRONMENT', 'development');
dchill427ecc5cd2012-10-12 16:25:51 -040041
42// Set localhost "remote" IP
43isset($_SERVER['REMOTE_ADDR']) OR $_SERVER['REMOTE_ADDR'] = '127.0.0.1';
44
Pascal Krietef5aee9d2011-04-21 01:20:40 -040045// Prep our test environment
Taufan Adityaca16c4f2012-03-28 15:15:30 +070046include_once $dir.'/mocks/core/common.php';
dchill42e9435dc2012-10-14 15:44:39 -040047include_once SYSTEM_PATH.'core/Common.php';
Andrey Andreeveb555ed2014-02-12 19:25:01 +020048
Andrey Andreev263e8fe2014-05-09 12:19:15 +030049ini_set('default_charset', 'UTF-8');
Andrey Andreeveb555ed2014-02-12 19:25:01 +020050
51if (extension_loaded('mbstring'))
52{
53 defined('MB_ENABLED') OR define('MB_ENABLED', TRUE);
Andrey Andreev1ffa2232014-05-09 12:30:59 +030054 @ini_set('mbstring.internal_encoding', 'UTF-8');
Andrey Andreeveb555ed2014-02-12 19:25:01 +020055 mb_substitute_character('none');
56}
57else
58{
59 defined('MB_ENABLED') OR define('MB_ENABLED', FALSE);
60}
61
62if (extension_loaded('iconv'))
63{
64 defined('ICONV_ENABLED') OR define('ICONV_ENABLED', TRUE);
Andrey Andreev263e8fe2014-05-09 12:19:15 +030065 @ini_set('iconv.internal_encoding', 'UTF-8');
Andrey Andreeveb555ed2014-02-12 19:25:01 +020066}
67else
68{
69 defined('ICONV_ENABLED') OR define('ICONV_ENABLED', FALSE);
70}
71
Andrey Andreev263e8fe2014-05-09 12:19:15 +030072is_php('5.6') && ini_set('php.internal_encoding', 'UTF-8');
73
Andrey Andreev3fd1b382014-02-13 03:01:31 +020074include_once SYSTEM_PATH.'core/compat/mbstring.php';
Andrey Andreev9a152a92014-02-18 16:29:53 +020075include_once SYSTEM_PATH.'core/compat/hash.php';
Andrey Andreev3fd1b382014-02-13 03:01:31 +020076include_once SYSTEM_PATH.'core/compat/password.php';
Andrey Andreev5b3fe7c2014-07-07 10:55:53 +030077include_once SYSTEM_PATH.'core/compat/standard.php';
Andrey Andreev3fd1b382014-02-13 03:01:31 +020078
Taufan Adityaca16c4f2012-03-28 15:15:30 +070079include_once $dir.'/mocks/autoloader.php';
80spl_autoload_register('autoload');
Pascal Krietef5aee9d2011-04-21 01:20:40 -040081
82unset($dir);