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