blob: e28650dba72c29fb8e3fef658256d9a975587c39 [file] [log] [blame]
Taufan Adityaca16c4f2012-03-28 15:15:30 +07001<?php
2
Taufan Adityaca16c4f2012-03-28 15:15:30 +07003class Mock_Core_Loader extends CI_Loader {
Andrey Andreevf243ce12012-06-09 23:34:21 +03004
Taufan Adityaca16c4f2012-03-28 15:15:30 +07005 /**
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
dchill4260307192012-08-27 23:59:31 -04008 * 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 Adityaca16c4f2012-03-28 15:15:30 +070013 *
14 * @covers CI_Loader::__construct()
15 */
16 public function __construct()
17 {
dchill4260307192012-08-27 23:59:31 -040018 // 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 Andreevf243ce12012-06-09 23:34:21 +030022
dchill4260307192012-08-27 23:59:31 -040023 // Get VFS app and base path URLs
24 $this->app_path = vfsStream::url('application').'/';
25 $this->base_path = vfsStream::url('system').'/';
Andrey Andreevf243ce12012-06-09 23:34:21 +030026
dchill4260307192012-08-27 23:59:31 -040027 // Set loader paths with VFS URLs
Taufan Adityaca16c4f2012-03-28 15:15:30 +070028 $this->_ci_ob_level = ob_get_level();
dchill4260307192012-08-27 23:59:31 -040029 $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 Adityaca16c4f2012-03-28 15:15:30 +070033 }
Andrey Andreevf243ce12012-06-09 23:34:21 +030034
dchill4260307192012-08-27 23:59:31 -040035}