diff options
author | Andrey Andreev <narf@devilix.net> | 2014-02-21 14:50:36 +0100 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2014-02-21 14:50:36 +0100 |
commit | 742826c26c64656acf5cfc7df4cc5e1c5c8a68cc (patch) | |
tree | 07acdcc452a528fb535c047b45ae8d5a6343eec5 /tests/codeigniter/libraries/Upload_test.php | |
parent | 2cf4c9bac558e978d376ef80c4f515d829706c4c (diff) |
Add test cases for CI_Upload::__construct(), CI_Upload::initialize()
Diffstat (limited to 'tests/codeigniter/libraries/Upload_test.php')
-rw-r--r-- | tests/codeigniter/libraries/Upload_test.php | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/tests/codeigniter/libraries/Upload_test.php b/tests/codeigniter/libraries/Upload_test.php index 03eb640b7..4fbc11ef0 100644 --- a/tests/codeigniter/libraries/Upload_test.php +++ b/tests/codeigniter/libraries/Upload_test.php @@ -2,7 +2,7 @@ class Upload_test extends CI_TestCase { - function set_up() + public function set_up() { $ci = $this->ci_instance(); $ci->upload = new CI_Upload(); @@ -12,11 +12,52 @@ class Upload_test extends CI_TestCase { $this->upload = $ci->upload; } - function test_do_upload() + // -------------------------------------------------------------------- + + public function test___construct_initialize() + { + // via __construct + + $upload = new CI_Upload( + array( + 'file_name' => 'foo', + 'file_ext_tolower' => TRUE + ) + ); + + // ReflectionProperty::setAccessible() is not available in PHP 5.2.x + if (is_php('5.3')) + { + $reflection = new ReflectionClass($upload); + $reflection = $reflection->getProperty('_file_name_override'); + $reflection->setAccessible(TRUE); + $this->assertEquals('foo', $reflection->getValue($upload)); + } + + $this->assertTrue($upload->file_ext_tolower); + + // reset (defaults to true) + + $upload->initialize(array('file_name' => 'bar')); + $this->assertEquals('bar', $upload->file_name); + $this->assertFalse($upload->file_ext_tolower); + + // no reset + + $upload->initialize(array('file_ext_tolower' => TRUE), FALSE); + $this->assertTrue($upload->file_ext_tolower); + $this->assertEquals('bar', $upload->file_name); + } + + // -------------------------------------------------------------------- + + public function test_do_upload() { - $this->markTestSkipped('We can\'t really test this at the moment because of the call to `is_uploaded_file` in do_upload which isn\'t supported by vfsStream'); + $this->markTestSkipped("We can't test this at the moment because of the call to is_uploaded_file() in do_upload() which isn't supported by vfsStream."); } + // -------------------------------------------------------------------- + function test_data() { $data = array( |