Taufan Aditya | ca16c4f | 2012-03-28 15:15:30 +0700 | [diff] [blame] | 1 | <?php |
| 2 | |
Taufan Aditya | ca16c4f | 2012-03-28 15:15:30 +0700 | [diff] [blame] | 3 | class Mock_Core_Loader extends CI_Loader { |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 4 | |
Taufan Aditya | ca16c4f | 2012-03-28 15:15:30 +0700 | [diff] [blame] | 5 | /** |
| 6 | * Since we use paths to load up models, views, etc, we need the ability to |
| 7 | * mock up the file system so when core tests are run, we aren't mucking |
dchill42 | 6030719 | 2012-08-27 23:59:31 -0400 | [diff] [blame^] | 8 | * in the application directory. This will give finer grained control over |
| 9 | * these tests. Also, by mocking the system directory, we eliminate dependency |
| 10 | * on any other classes so errors in libraries, helpers, etc. don't give false |
| 11 | * negatives for the actual loading process. So yeah, while this looks odd, |
| 12 | * I need to overwrite protected class vars in the loader. So here we go... |
Taufan Aditya | ca16c4f | 2012-03-28 15:15:30 +0700 | [diff] [blame] | 13 | * |
| 14 | * @covers CI_Loader::__construct() |
| 15 | */ |
| 16 | public function __construct() |
| 17 | { |
dchill42 | 6030719 | 2012-08-27 23:59:31 -0400 | [diff] [blame^] | 18 | // Create VFS tree of loader locations |
| 19 | $this->root = vfsStream::setup(); |
| 20 | $this->app_root = vfsStream::newDirectory('application')->at($this->root); |
| 21 | $this->base_root = vfsStream::newDirectory('system')->at($this->root); |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 22 | |
dchill42 | 6030719 | 2012-08-27 23:59:31 -0400 | [diff] [blame^] | 23 | // Get VFS app and base path URLs |
| 24 | $this->app_path = vfsStream::url('application').'/'; |
| 25 | $this->base_path = vfsStream::url('system').'/'; |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 26 | |
dchill42 | 6030719 | 2012-08-27 23:59:31 -0400 | [diff] [blame^] | 27 | // Set loader paths with VFS URLs |
Taufan Aditya | ca16c4f | 2012-03-28 15:15:30 +0700 | [diff] [blame] | 28 | $this->_ci_ob_level = ob_get_level(); |
dchill42 | 6030719 | 2012-08-27 23:59:31 -0400 | [diff] [blame^] | 29 | $this->_ci_library_paths = array($this->app_path, $this->base_path); |
| 30 | $this->_ci_helper_paths = array($this->app_path, $this->base_path); |
| 31 | $this->_ci_model_paths = array($this->app_path); |
| 32 | $this->_ci_view_paths = array($this->app_path.'views/' => TRUE); |
Taufan Aditya | ca16c4f | 2012-03-28 15:15:30 +0700 | [diff] [blame] | 33 | } |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 34 | |
dchill42 | 6030719 | 2012-08-27 23:59:31 -0400 | [diff] [blame^] | 35 | } |