blob: 53d88d55befd18ba8baf854868debe99c72b090b [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
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'));
Andrey Andreevf243ce12012-06-09 23:34:21 +030018
Taufan Adityaca16c4f2012-03-28 15:15:30 +070019 $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());
Andrey Andreevf243ce12012-06-09 23:34:21 +030023
Taufan Adityaca16c4f2012-03-28 15:15:30 +070024 $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 }
Andrey Andreevf243ce12012-06-09 23:34:21 +030030
Taufan Adityaca16c4f2012-03-28 15:15:30 +070031}