Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 1 | <?php |
Pascal Kriete | f5aee9d | 2011-04-21 01:20:40 -0400 | [diff] [blame] | 2 | // Errors on full! |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 3 | ini_set('display_errors', 1); |
| 4 | error_reporting(E_ALL | E_STRICT); |
| 5 | |
Pascal Kriete | f5aee9d | 2011-04-21 01:20:40 -0400 | [diff] [blame] | 6 | $dir = realpath(dirname(__FILE__)); |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 7 | |
Pascal Kriete | f5aee9d | 2011-04-21 01:20:40 -0400 | [diff] [blame] | 8 | // Path constants |
Taufan Aditya | 4912f8b | 2012-05-26 22:09:58 +0700 | [diff] [blame] | 9 | defined('PROJECT_BASE') OR define('PROJECT_BASE', realpath($dir.'/../').'/'); |
dchill42 | 7ecc5cd | 2012-10-12 16:25:51 -0400 | [diff] [blame] | 10 | defined('SYSTEM_PATH') OR define('SYSTEM_PATH', PROJECT_BASE.'system/'); |
Pascal Kriete | 69c97a7 | 2011-04-20 21:44:54 -0400 | [diff] [blame] | 11 | |
Taufan Aditya | e13511a | 2012-05-25 02:15:42 +0700 | [diff] [blame] | 12 | // Get vfsStream either via PEAR or composer |
Taufan Aditya | eeca6d2 | 2012-05-25 03:15:19 +0700 | [diff] [blame] | 13 | foreach (explode(PATH_SEPARATOR, get_include_path()) as $path) |
Taufan Aditya | 6bca9f8 | 2012-05-25 01:55:36 +0700 | [diff] [blame] | 14 | { |
Taufan Aditya | 2d57445 | 2012-05-25 04:03:56 +0700 | [diff] [blame] | 15 | if (file_exists($path.DIRECTORY_SEPARATOR.'vfsStream/vfsStream.php')) |
Taufan Aditya | eeca6d2 | 2012-05-25 03:15:19 +0700 | [diff] [blame] | 16 | { |
| 17 | require_once 'vfsStream/vfsStream.php'; |
| 18 | break; |
| 19 | } |
Taufan Aditya | 6bca9f8 | 2012-05-25 01:55:36 +0700 | [diff] [blame] | 20 | } |
Taufan Aditya | eeca6d2 | 2012-05-25 03:15:19 +0700 | [diff] [blame] | 21 | |
| 22 | if ( ! class_exists('vfsStream') && file_exists(PROJECT_BASE.'vendor/autoload.php')) |
Taufan Aditya | 6bca9f8 | 2012-05-25 01:55:36 +0700 | [diff] [blame] | 23 | { |
Taufan Aditya | e13511a | 2012-05-25 02:15:42 +0700 | [diff] [blame] | 24 | include_once PROJECT_BASE.'vendor/autoload.php'; |
| 25 | class_alias('org\bovigo\vfs\vfsStream', 'vfsStream'); |
| 26 | class_alias('org\bovigo\vfs\vfsStreamDirectory', 'vfsStreamDirectory'); |
| 27 | class_alias('org\bovigo\vfs\vfsStreamWrapper', 'vfsStreamWrapper'); |
Taufan Aditya | 6bca9f8 | 2012-05-25 01:55:36 +0700 | [diff] [blame] | 28 | } |
| 29 | |
dchill42 | 7ecc5cd | 2012-10-12 16:25:51 -0400 | [diff] [blame] | 30 | // Define CI path constants to VFS (filesystem setup in CI_TestCase::setUp) |
| 31 | defined('BASEPATH') OR define('BASEPATH', vfsStream::url('system/')); |
| 32 | defined('APPPATH') OR define('APPPATH', vfsStream::url('application/')); |
| 33 | defined('VIEWPATH') OR define('VIEWPATH', APPPATH.'views/'); |
Andrey Andreev | 7638479 | 2013-01-28 11:22:05 +0200 | [diff] [blame] | 34 | defined('ENVIRONMENT') OR define('ENVIRONMENT', 'development'); |
dchill42 | 7ecc5cd | 2012-10-12 16:25:51 -0400 | [diff] [blame] | 35 | |
| 36 | // Set localhost "remote" IP |
| 37 | isset($_SERVER['REMOTE_ADDR']) OR $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; |
| 38 | |
Pascal Kriete | f5aee9d | 2011-04-21 01:20:40 -0400 | [diff] [blame] | 39 | // Prep our test environment |
Taufan Aditya | ca16c4f | 2012-03-28 15:15:30 +0700 | [diff] [blame] | 40 | include_once $dir.'/mocks/core/common.php'; |
dchill42 | e9435dc | 2012-10-14 15:44:39 -0400 | [diff] [blame] | 41 | include_once SYSTEM_PATH.'core/Common.php'; |
Andrey Andreev | eb555ed | 2014-02-12 19:25:01 +0200 | [diff] [blame] | 42 | |
Andrey Andreev | 263e8fe | 2014-05-09 12:19:15 +0300 | [diff] [blame] | 43 | ini_set('default_charset', 'UTF-8'); |
Andrey Andreev | eb555ed | 2014-02-12 19:25:01 +0200 | [diff] [blame] | 44 | |
| 45 | if (extension_loaded('mbstring')) |
| 46 | { |
| 47 | defined('MB_ENABLED') OR define('MB_ENABLED', TRUE); |
Andrey Andreev | 1ffa223 | 2014-05-09 12:30:59 +0300 | [diff] [blame] | 48 | @ini_set('mbstring.internal_encoding', 'UTF-8'); |
Andrey Andreev | eb555ed | 2014-02-12 19:25:01 +0200 | [diff] [blame] | 49 | mb_substitute_character('none'); |
| 50 | } |
| 51 | else |
| 52 | { |
| 53 | defined('MB_ENABLED') OR define('MB_ENABLED', FALSE); |
| 54 | } |
| 55 | |
| 56 | if (extension_loaded('iconv')) |
| 57 | { |
| 58 | defined('ICONV_ENABLED') OR define('ICONV_ENABLED', TRUE); |
Andrey Andreev | 263e8fe | 2014-05-09 12:19:15 +0300 | [diff] [blame] | 59 | @ini_set('iconv.internal_encoding', 'UTF-8'); |
Andrey Andreev | eb555ed | 2014-02-12 19:25:01 +0200 | [diff] [blame] | 60 | } |
| 61 | else |
| 62 | { |
| 63 | defined('ICONV_ENABLED') OR define('ICONV_ENABLED', FALSE); |
| 64 | } |
| 65 | |
Andrey Andreev | 263e8fe | 2014-05-09 12:19:15 +0300 | [diff] [blame] | 66 | is_php('5.6') && ini_set('php.internal_encoding', 'UTF-8'); |
| 67 | |
Andrey Andreev | 3fd1b38 | 2014-02-13 03:01:31 +0200 | [diff] [blame] | 68 | include_once SYSTEM_PATH.'core/compat/mbstring.php'; |
Andrey Andreev | 9a152a9 | 2014-02-18 16:29:53 +0200 | [diff] [blame] | 69 | include_once SYSTEM_PATH.'core/compat/hash.php'; |
Andrey Andreev | 3fd1b38 | 2014-02-13 03:01:31 +0200 | [diff] [blame] | 70 | include_once SYSTEM_PATH.'core/compat/password.php'; |
Andrey Andreev | 5b3fe7c | 2014-07-07 10:55:53 +0300 | [diff] [blame] | 71 | include_once SYSTEM_PATH.'core/compat/standard.php'; |
Andrey Andreev | 3fd1b38 | 2014-02-13 03:01:31 +0200 | [diff] [blame] | 72 | |
Taufan Aditya | ca16c4f | 2012-03-28 15:15:30 +0700 | [diff] [blame] | 73 | include_once $dir.'/mocks/autoloader.php'; |
| 74 | spl_autoload_register('autoload'); |
Pascal Kriete | f5aee9d | 2011-04-21 01:20:40 -0400 | [diff] [blame] | 75 | |
| 76 | unset($dir); |