From dd8d3d366bef1bc3fcb4476e88e8e6af44b89973 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 3 Nov 2012 02:09:05 +0200 Subject: Fix the bloody tests --- tests/codeigniter/core/Loader_test.php | 72 +++++++++++++++++----------------- tests/mocks/ci_testcase.php | 2 + 2 files changed, 39 insertions(+), 35 deletions(-) (limited to 'tests') diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index 02629908f..be223f97d 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -6,41 +6,6 @@ class Loader_test extends CI_TestCase { public function set_up() { - // Create helper in VFS - $helper = 'autohelp'; - $hlp_func = '_autohelp_test_func'; - $content = 'ci_vfs_create($helper.'_helper', $content, $this->ci_app_root, 'helpers'); - - // Create library in VFS - $lib = 'autolib'; - $lib_class = 'CI_'.ucfirst($lib); - $this->ci_vfs_create($lib, 'ci_base_root, 'libraries'); - - // Create driver in VFS - $drv = 'autodrv'; - $subdir = ucfirst($drv); - $drv_class = 'CI_'.$subdir; - $this->ci_vfs_create($drv, 'ci_base_root, array('libraries', $subdir)); - - // Create model in VFS package path - $dir = 'testdir'; - $path = APPPATH.$dir.'/'; - $model = 'automod'; - $mod_class = ucfirst($model); - $this->ci_vfs_create($model, 'ci_app_root, array($dir, 'models')); - - // Create autoloader config - $cfg = array( - 'packages' => array($path), - 'helper' => array($helper), - 'libraries' => array($lib), - 'drivers' => array($drv), - 'model' => array($model), - 'config' => array('config1', 'config2') - ); - $this->ci_vfs_create('autoload', 'ci_app_root, 'config'); - // Instantiate a new loader $loader = $this->ci_core_class('loader'); $this->load = new $loader(); @@ -493,6 +458,43 @@ class Loader_test extends CI_TestCase { public function test_initialize() { + // Create helper in VFS + $helper = 'autohelp'; + $hlp_func = '_autohelp_test_func'; + $content = 'ci_vfs_create($helper.'_helper', $content, $this->ci_app_root, 'helpers'); + + // Create library in VFS + $lib = 'autolib'; + $lib_class = 'CI_'.ucfirst($lib); + $this->ci_vfs_create($lib, 'ci_base_root, 'libraries'); + + // Create driver in VFS + $drv = 'autodrv'; + $subdir = ucfirst($drv); + $drv_class = 'CI_'.$subdir; + $this->ci_vfs_create($drv, 'ci_base_root, array('libraries', $subdir)); + + // Create model in VFS package path + $dir = 'testdir'; + $path = APPPATH.$dir.'/'; + $model = 'automod'; + $mod_class = ucfirst($model); + $this->ci_vfs_create($model, 'ci_app_root, array($dir, 'models')); + + // Create autoloader config + $cfg = array( + 'packages' => array($path), + 'helper' => array($helper), + 'libraries' => array($lib), + 'drivers' => array($drv), + 'model' => array($model), + 'config' => array('config1', 'config2') + ); + $this->ci_vfs_create('autoload', 'ci_app_root, 'config'); + + $this->load->__construct(); + // Verify path $this->assertContains($path, $this->load->get_package_paths()); diff --git a/tests/mocks/ci_testcase.php b/tests/mocks/ci_testcase.php index f16492945..2d0a26830 100644 --- a/tests/mocks/ci_testcase.php +++ b/tests/mocks/ci_testcase.php @@ -39,6 +39,8 @@ class CI_TestCase extends PHPUnit_Framework_TestCase { $this->ci_app_root = vfsStream::newDirectory('application')->at($this->ci_vfs_root); $this->ci_base_root = vfsStream::newDirectory('system')->at($this->ci_vfs_root); $this->ci_view_root = vfsStream::newDirectory('views')->at($this->ci_app_root); + vfsStream::newDirectory('config')->at($this->ci_app_root); + $this->ci_vfs_clone('application/config/autoload.php'); if (method_exists($this, 'set_up')) { -- cgit v1.2.3-24-g4f1b