diff options
author | Andrey Andreev <narf@devilix.net> | 2017-06-21 13:44:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-21 13:44:44 +0200 |
commit | db29eb3b290a67e92e67372bd1d772df431c607b (patch) | |
tree | ce212ef3f762e420def85c5f00751695e22f6b73 /tests/codeigniter | |
parent | 8186b6b398c26c0c1e0052eaddf4fc122e4929a5 (diff) | |
parent | c8a0d0bc784a778694e7f42243a1584b51cf207d (diff) |
Merge pull request #5159 from tianhe1986/develop_model_load
Always check a model be a subclass of CI_Model when loaded
Diffstat (limited to 'tests/codeigniter')
-rw-r--r-- | tests/codeigniter/core/Loader_test.php | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index 241c415b3..3b6a7e16c 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -269,6 +269,25 @@ class Loader_test extends CI_TestCase { // -------------------------------------------------------------------- + public function test_invalid_model() + { + $this->ci_set_core_class('model', 'CI_Model'); + + // Create model in VFS + $model = 'Unit_test_invalid_model'; + $content = '<?php class '.$model.' {} '; + $this->ci_vfs_create($model, $content, $this->ci_app_root, 'models'); + + // Test no extending + $this->setExpectedException( + 'RuntimeException', + 'Class '.$model.' doesn\'t extend CI_Model' + ); + $this->load->model($model); + } + + // -------------------------------------------------------------------- + // public function testDatabase() // { // $this->assertInstanceOf('CI_Loader', $this->load->database()); @@ -544,7 +563,7 @@ class Loader_test extends CI_TestCase { $dir = 'testdir'; $path = APPPATH.$dir.'/'; $model = 'Automod'; - $this->ci_vfs_create($model, '<?php class '.$model.' { }', $this->ci_app_root, array($dir, 'models')); + $this->ci_vfs_create($model, '<?php class '.$model.' extends CI_Model { }', $this->ci_app_root, array($dir, 'models')); // Create autoloader config $cfg = array( |