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 { |
| 4 | |
| 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 |
| 8 | * in the application directory. this will give finer grained control over |
| 9 | * these tests. So yeah, while this looks odd, I need to overwrite protected |
| 10 | * class vars in the loader. So here we go... |
| 11 | * |
| 12 | * @covers CI_Loader::__construct() |
| 13 | */ |
| 14 | public function __construct() |
| 15 | { |
| 16 | vfsStreamWrapper::register(); |
| 17 | vfsStreamWrapper::setRoot(new vfsStreamDirectory('application')); |
| 18 | |
| 19 | $this->models_dir = vfsStream::newDirectory('models')->at(vfsStreamWrapper::getRoot()); |
| 20 | $this->libs_dir = vfsStream::newDirectory('libraries')->at(vfsStreamWrapper::getRoot()); |
| 21 | $this->helpers_dir = vfsStream::newDirectory('helpers')->at(vfsStreamWrapper::getRoot()); |
| 22 | $this->views_dir = vfsStream::newDirectory('views')->at(vfsStreamWrapper::getRoot()); |
| 23 | |
| 24 | $this->_ci_ob_level = ob_get_level(); |
| 25 | $this->_ci_library_paths = array(vfsStream::url('application').'/', BASEPATH); |
| 26 | $this->_ci_helper_paths = array(vfsStream::url('application').'/', BASEPATH); |
| 27 | $this->_ci_model_paths = array(vfsStream::url('application').'/'); |
| 28 | $this->_ci_view_paths = array(vfsStream::url('application').'/views/' => TRUE); |
| 29 | } |
| 30 | } |