diff options
author | Andrew <browner12@gmail.com> | 2014-02-17 19:24:00 +0100 |
---|---|---|
committer | Andrew <browner12@gmail.com> | 2014-02-17 19:24:00 +0100 |
commit | 63cb46b94c4dda33e036643fbca3d94e0ba079f0 (patch) | |
tree | a8bc36fa23e3a7de491223c896d9aadaf4e8c408 /tests/codeigniter | |
parent | b6d8b962e44202a74c9b9321a4a53f61a753fccf (diff) | |
parent | ffe8aded4d2210759fce3427ed04893e6c655006 (diff) |
Merge branch 'develop' into patch-1
Diffstat (limited to 'tests/codeigniter')
-rw-r--r-- | tests/codeigniter/core/Config_test.php | 2 | ||||
-rw-r--r-- | tests/codeigniter/core/Loader_test.php | 8 | ||||
-rw-r--r-- | tests/codeigniter/core/Utf8_test.php | 4 | ||||
-rw-r--r-- | tests/codeigniter/core/compat/mbstring_test.php | 54 | ||||
-rw-r--r-- | tests/codeigniter/core/compat/password_test.php | 158 | ||||
-rw-r--r-- | tests/codeigniter/helpers/array_helper_test.php | 16 | ||||
-rw-r--r-- | tests/codeigniter/helpers/captcha_helper_test.php | 2 | ||||
-rw-r--r-- | tests/codeigniter/helpers/directory_helper_test.php | 2 | ||||
-rw-r--r-- | tests/codeigniter/helpers/email_helper_test.php | 5 | ||||
-rw-r--r-- | tests/codeigniter/helpers/file_helper_test.php | 74 | ||||
-rw-r--r-- | tests/codeigniter/helpers/inflector_helper_test.php | 44 | ||||
-rw-r--r-- | tests/codeigniter/libraries/Encryption_test.php | 11 | ||||
-rw-r--r-- | tests/codeigniter/libraries/Session_test.php | 2 | ||||
-rw-r--r-- | tests/codeigniter/libraries/Table_test.php | 51 |
14 files changed, 328 insertions, 105 deletions
diff --git a/tests/codeigniter/core/Config_test.php b/tests/codeigniter/core/Config_test.php index ba9a2c070..6a0a7a35f 100644 --- a/tests/codeigniter/core/Config_test.php +++ b/tests/codeigniter/core/Config_test.php @@ -180,7 +180,7 @@ class Config_test extends CI_TestCase { $cfg = array( 'one' => 'prime', 'two' => 2, - 'three' => true + 'three' => TRUE ); $this->ci_vfs_create($file.'.php', '<?php $config = '.var_export($cfg, TRUE).';', $this->ci_app_root, 'config'); $this->assertTrue($this->config->load($file, TRUE)); diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index 799bcd967..93ca5b223 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -324,12 +324,12 @@ class Loader_test extends CI_TestCase { // Create helper in VFS $helper = 'test'; $func = '_my_helper_test_func'; - $content = '<?php function '.$func.'() { return true; } '; + $content = '<?php function '.$func.'() { return TRUE; } '; $this->ci_vfs_create($helper.'_helper', $content, $this->ci_base_root, 'helpers'); // Create helper extension $exfunc = '_my_extension_func'; - $content = '<?php function '.$exfunc.'() { return true; } '; + $content = '<?php function '.$exfunc.'() { return TRUE; } '; $this->ci_vfs_create($this->prefix.$helper.'_helper', $content, $this->ci_app_root, 'helpers'); // Load helper @@ -373,7 +373,7 @@ class Loader_test extends CI_TestCase { $helpers[] = $helper; $func = '_my_helper_test_func'.$i; $funcs[] = $func; - $files[$helper.'_helper'] = '<?php function '.$func.'() { return true; } '; + $files[$helper.'_helper'] = '<?php function '.$func.'() { return TRUE; } '; } $this->ci_vfs_create($files, NULL, $this->ci_base_root, 'helpers'); @@ -457,7 +457,7 @@ class Loader_test extends CI_TestCase { // Create helper in VFS $helper = 'autohelp'; $hlp_func = '_autohelp_test_func'; - $content = '<?php function '.$hlp_func.'() { return true; }'; + $content = '<?php function '.$hlp_func.'() { return TRUE; }'; $this->ci_vfs_create($helper.'_helper', $content, $this->ci_app_root, 'helpers'); // Create library in VFS diff --git a/tests/codeigniter/core/Utf8_test.php b/tests/codeigniter/core/Utf8_test.php index 71299134e..2cf404841 100644 --- a/tests/codeigniter/core/Utf8_test.php +++ b/tests/codeigniter/core/Utf8_test.php @@ -18,8 +18,8 @@ class Utf8_test extends CI_TestCase { public function test_is_ascii() { - $this->assertTrue($this->utf8->is_ascii_test('foo bar')); - $this->assertFalse($this->utf8->is_ascii_test('тест')); + $this->assertTrue($this->utf8->is_ascii('foo bar')); + $this->assertFalse($this->utf8->is_ascii('тест')); } }
\ No newline at end of file diff --git a/tests/codeigniter/core/compat/mbstring_test.php b/tests/codeigniter/core/compat/mbstring_test.php new file mode 100644 index 000000000..415222446 --- /dev/null +++ b/tests/codeigniter/core/compat/mbstring_test.php @@ -0,0 +1,54 @@ +<?php + +class mbstring_test extends CI_TestCase { + + public function test_bootstrap() + { + if (MB_ENABLED) + { + return $this->markTestSkipped('ext/mbstring is loaded'); + } + + $this->assertTrue(function_exists('mb_strlen')); + $this->assertTrue(function_exists('mb_substr')); + } + + // ------------------------------------------------------------------------ + + /** + * @depends test_bootstrap + */ + public function test_mb_strlen() + { + $this->assertEquals(ICONV_ENABLED ? 4 : 8, mb_strlen('тест')); + $this->assertEquals(ICONV_ENABLED ? 4 : 8, mb_strlen('тест', 'UTF-8')); + } + + // ------------------------------------------------------------------------ + + /** + * @depends test_boostrap + */ + public function test_mb_strpos() + { + $this->assertEquals(ICONV_ENABLED ? 3 : 6, mb_strpos('тест', 'с')); + $this->assertFalse(mb_strpos('тест', 'с', 3)); + $this->assertEquals(ICONV_ENABLED ? 3 : 6, mb_strpos('тест', 'с', 1, 'UTF-8')); + } + + // ------------------------------------------------------------------------ + + /** + * @depends test_boostrap + */ + public function test_mb_substr() + { + $this->assertEquals(ICONV_ENABLED ? 'стинг' : 'естинг', mb_substr('тестинг', 2)); + $this->assertEquals(ICONV_ENABLED ? 'нг' : 'г', mb_substr('тестинг', -2)); + $this->assertEquals(ICONV_ENABLED ? 'ст' : 'е', mb_substr('тестинг', 2, 2)); + $this->assertEquals(ICONV_ENABLED ? 'стинг' : 'естинг', mb_substr('тестинг', 2, 'UTF-8')); + $this->assertEquals(ICONV_ENABLED ? 'нг' : 'г', mb_substr('тестинг', -2, 'UTF-8')); + $this->assertEquals(ICONV_ENABLED ? 'ст' : 'е', mb_substr('тестинг', 2, 2, 'UTF-8')); + } + +}
\ No newline at end of file diff --git a/tests/codeigniter/core/compat/password_test.php b/tests/codeigniter/core/compat/password_test.php new file mode 100644 index 000000000..4014e7415 --- /dev/null +++ b/tests/codeigniter/core/compat/password_test.php @@ -0,0 +1,158 @@ +<?php + +class password_test extends CI_TestCase { + + public function test_bootstrap() + { + if (is_php('5.5')) + { + return $this->markTestSkipped('ext/standard/password is available on PHP 5.5'); + } + elseif ( ! is_php('5.3.7')) + { + $this->assertFalse(defined('PASSWORD_BCRYPT')); + return $this->markTestSkipped("PHP versions prior to 5.3.7 don't have the '2y' Blowfish version"); + } + elseif ( ! defined('CRYPT_BLOWFISH') OR CRYPT_BLOWFISH !== 1) + { + $this->assertFalse(defined('PASSWORD_BCRYPT')); + return $this->markTestSkipped('CRYPT_BLOWFISH is not available'); + } + + $this->assertTrue(defined('PASSWORD_BCRYPT')); + $this->assertTrue(defined('PASSWORD_DEFAULT')); + $this->assertEquals(1, PASSWORD_BCRYPT); + $this->assertEquals(PASSWORD_BCRYPT, PASSWORD_DEFAULT); + $this->assertTrue(function_exists('password_get_info')); + $this->assertTrue(function_exists('password_hash')); + $this->assertTrue(function_exists('password_needs_rehash')); + $this->assertTrue(function_exists('password_verify')); + } + + // ------------------------------------------------------------------------ + + /** + * password_get_info() test + * + * Borrowed from PHP's own tests + * + * @depends test_bootstrap + */ + public function test_password_get_info() + { + $expected = array( + 'algo' => 1, + 'algoName' => 'bcrypt', + 'options' => array('cost' => 10) + ); + + // default + $this->assertEquals($expected, password_get_info('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y')); + + $expected['options']['cost'] = 11; + + // cost + $this->assertEquals($expected, password_get_info('$2y$11$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y')); + + $expected = array( + 'algo' => 0, + 'algoName' => 'unknown', + 'options' => array() + ); + + // invalid length + $this->assertEquals($expected, password_get_info('$2y$11$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100')); + + // non-bcrypt + $this->assertEquals($expected, password_get_info('$1$rasmusle$rISCgZzpwk3UhDidwXvin0')); + } + + // ------------------------------------------------------------------------ + + /** + * password_hash() test + * + * Borrowed from PHP's own tests + * + * @depends test_bootstrap + */ + public function test_password_hash() + { + // FALSE is returned if no CSPRNG source is available + if ( ! defined('MCRYPT_DEV_URANDOM') && ! function_exists('openssl_random_pseudo_bytes') + && (DIRECTORY_SEPARATOR !== '/' OR ! is_readable('/dev/arandom') OR ! is_readable('/dev/urandom')) + ) + { + $this->assertFalse(password_hash('foo', PASSWORD_BCRYPT)); + } + else + { + $this->assertEquals(60, strlen(password_hash('foo', PASSWORD_BCRYPT))); + $this->assertTrue(($hash = password_hash('foo', PASSWORD_BCRYPT)) === crypt('foo', $hash)); + } + + $this->assertEquals( + '$2y$07$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi', + password_hash('rasmuslerdorf', PASSWORD_BCRYPT, array('cost' => 7, 'salt' => 'usesomesillystringforsalt')) + ); + + $this->assertEquals( + '$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', + password_hash('test', PASSWORD_BCRYPT, array('salt' => '123456789012345678901'.chr(0))) + ); + } + + // ------------------------------------------------------------------------ + + /** + * password_needs_rehash() test + * + * Borrowed from PHP's own tests + * + * @depends test_password_get_info + */ + public function test_password_needs_rehash() + { + // invalid hash: always rehash + $this->assertTrue(password_needs_rehash('', PASSWORD_BCRYPT)); + + // valid, because it's an unknown algorithm + $this->assertFalse(password_needs_rehash('', 0)); + + // valid with same cost + $this->assertFalse(password_needs_rehash('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', PASSWORD_BCRYPT, array('cost' => 10))); + + // valid with same cost and additional parameters + $this->assertFalse(password_needs_rehash('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', PASSWORD_BCRYPT, array('cost' => 10, 'foo' => 3))); + + // invalid: different (lower) cost + $this->assertTrue(password_needs_rehash('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', PASSWORD_BCRYPT, array('cost' => 09))); + + // invalid: different (higher) cost + $this->assertTrue(password_needs_rehash('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', PASSWORD_BCRYPT, array('cost' => 11))); + + // valid with default cost + $this->assertFalse(password_needs_rehash('$2y$'.str_pad(10, 2, '0', STR_PAD_LEFT).'$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', PASSWORD_BCRYPT)); + + // invalid: 'foo' is cast to 0 + $this->assertTrue(password_needs_rehash('$2y$10$MTIzNDU2Nzg5MDEyMzQ1Nej0NmcAWSLR.oP7XOR9HD/vjUuOj100y', PASSWORD_BCRYPT, array('cost' => 'foo'))); + } + + // ------------------------------------------------------------------------ + + /** + * password_verify() test + * + * Borrowed from PHP's own tests + * + * @depends test_bootstrap + */ + public function test_password_verify() + { + $this->assertFalse(password_verify(123, 123)); + $this->assertFalse(password_verify('foo', '$2a$07$usesomesillystringforsalt$')); + $this->assertFalse(password_verify('rasmusler', '$2a$07$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi')); + $this->assertTrue(password_verify('rasmuslerdorf', '$2a$07$usesomesillystringfore2uDLvp1Ii2e./U9C8sBjqp8I90dH6hi')); + } + +}
\ No newline at end of file diff --git a/tests/codeigniter/helpers/array_helper_test.php b/tests/codeigniter/helpers/array_helper_test.php index ba46e86f9..5a9958971 100644 --- a/tests/codeigniter/helpers/array_helper_test.php +++ b/tests/codeigniter/helpers/array_helper_test.php @@ -2,16 +2,16 @@ class Array_helper_test extends CI_TestCase { + public $my_array = array( + 'foo' => 'bar', + 'sally' => 'jim', + 'maggie' => 'bessie', + 'herb' => 'cook' + ); + public function set_up() { $this->helper('array'); - - $this->my_array = array( - 'foo' => 'bar', - 'sally' => 'jim', - 'maggie' => 'bessie', - 'herb' => 'cook' - ); } // ------------------------------------------------------------------------ @@ -19,9 +19,7 @@ class Array_helper_test extends CI_TestCase { public function test_element_with_existing_item() { $this->assertEquals(FALSE, element('testing', $this->my_array)); - $this->assertEquals('not set', element('testing', $this->my_array, 'not set')); - $this->assertEquals('bar', element('foo', $this->my_array)); } diff --git a/tests/codeigniter/helpers/captcha_helper_test.php b/tests/codeigniter/helpers/captcha_helper_test.php index fc86305e3..bb8760a15 100644 --- a/tests/codeigniter/helpers/captcha_helper_test.php +++ b/tests/codeigniter/helpers/captcha_helper_test.php @@ -4,7 +4,7 @@ class Captcha_helper_test extends CI_TestCase { public function test_create_captcha() { - $this->markTestSkipped('Cant easily test'); + $this->markTestSkipped("Can't test"); } }
\ No newline at end of file diff --git a/tests/codeigniter/helpers/directory_helper_test.php b/tests/codeigniter/helpers/directory_helper_test.php index de72dee78..ac71dfaf8 100644 --- a/tests/codeigniter/helpers/directory_helper_test.php +++ b/tests/codeigniter/helpers/directory_helper_test.php @@ -31,7 +31,7 @@ class Directory_helper_test extends CI_TestCase { // is_dir(), opendir(), etc. seem to fail on Windows + vfsStream when there are trailing backslashes in directory names if ( ! is_dir(vfsStream::url('testDir').DIRECTORY_SEPARATOR)) { - $this->markTestSkipped(); + $this->markTestSkipped("Can't test this under Windows"); return; } diff --git a/tests/codeigniter/helpers/email_helper_test.php b/tests/codeigniter/helpers/email_helper_test.php index fea452f5f..53a206825 100644 --- a/tests/codeigniter/helpers/email_helper_test.php +++ b/tests/codeigniter/helpers/email_helper_test.php @@ -15,4 +15,9 @@ class Email_helper_test extends CI_TestCase { $this->assertEquals(TRUE, valid_email('my.test@test.com')); } + public function test_send_mail() + { + $this->markTestSkipped("Can't test"); + } + }
\ No newline at end of file diff --git a/tests/codeigniter/helpers/file_helper_test.php b/tests/codeigniter/helpers/file_helper_test.php index 3a6c73a5c..c31817595 100644 --- a/tests/codeigniter/helpers/file_helper_test.php +++ b/tests/codeigniter/helpers/file_helper_test.php @@ -31,9 +31,10 @@ class File_helper_Test extends CI_TestCase { { $content = 'Jack and Jill went up the mountain to fight a billy goat.'; - $file = vfsStream::newFile('my_file.txt', 0777)->withContent($content) - ->lastModified(time() - 86400) - ->at($this->_test_dir); + $file = vfsStream::newFile('my_file.txt', 0777) + ->withContent($content) + ->lastModified(time() - 86400) + ->at($this->_test_dir); $this->assertEquals('777', octal_permissions($file->getPermissions())); } @@ -47,9 +48,10 @@ class File_helper_Test extends CI_TestCase { { $content = 'Jack and Jill went up the mountain to fight a billy goat.'; - $file = vfsStream::newFile('my_file.txt', 0777)->withContent($content) - ->lastModified(time() - 86400) - ->at($this->_test_dir); + $file = vfsStream::newFile('my_file.txt', 0777) + ->withContent($content) + ->lastModified(time() - 86400) + ->at($this->_test_dir); $this->assertEquals('urwxrwxrwx', symbolic_permissions($file->getPermissions())); } @@ -60,9 +62,10 @@ class File_helper_Test extends CI_TestCase { { $content = 'Jack and Jill went up the mountain to fight a billy goat.'; - $file = vfsStream::newFile('my_file.txt', 0777)->withContent($content) - ->lastModified(time() - 86400) - ->at($this->_test_dir); + $file = vfsStream::newFile('my_file.txt', 0777) + ->withContent($content) + ->lastModified(time() - 86400) + ->at($this->_test_dir); $this->assertEquals('text/plain', get_mime_by_extension(vfsStream::url('my_file.txt'))); @@ -103,19 +106,20 @@ class File_helper_Test extends CI_TestCase { $content = 'Jack and Jill went up the mountain to fight a billy goat.'; $last_modified = time() - 86400; - $file = vfsStream::newFile('my_file.txt', 0777)->withContent($content) - ->lastModified($last_modified) - ->at($this->_test_dir); + $file = vfsStream::newFile('my_file.txt', 0777) + ->withContent($content) + ->lastModified($last_modified) + ->at($this->_test_dir); $ret_values = array( - 'name' => 'my_file.txt', - 'server_path' => 'vfs://my_file.txt', - 'size' => 57, - 'date' => $last_modified, - 'readable' => TRUE, - 'writable' => TRUE, - 'executable' => TRUE, - 'fileperms' => 33279 + 'name' => 'my_file.txt', + 'server_path' => 'vfs://my_file.txt', + 'size' => 57, + 'date' => $last_modified, + 'readable' => TRUE, + 'writable' => TRUE, + 'executable' => TRUE, + 'fileperms' => 33279 ); $info = get_file_info(vfsStream::url('my_file.txt'), $vals); @@ -128,24 +132,16 @@ class File_helper_Test extends CI_TestCase { // -------------------------------------------------------------------- - // Skipping for now, as it's not implemented in vfsStreamWrapper - // flock(): vfsStreamWrapper::stream_lock is not implemented! - - // public function test_write_file() - // { - // if ( ! defined('FOPEN_WRITE_CREATE_DESTRUCTIVE')) - // { - // define('FOPEN_WRITE_CREATE_DESTRUCTIVE', 'wb'); - // } - // - // $content = 'Jack and Jill went up the mountain to fight a billy goat.'; - // - // $file = vfsStream::newFile('write.txt', 0777)->withContent('') - // ->lastModified(time() - 86400) - // ->at($this->_test_dir); - // - // $this->assertTrue(write_file(vfsStream::url('write.txt'), $content)); - // - // } + public function test_write_file() + { + $content = 'Jack and Jill went up the mountain to fight a billy goat.'; + + $file = vfsStream::newFile('write.txt', 0777) + ->withContent('') + ->lastModified(time() - 86400) + ->at($this->_test_dir); + + $this->assertTrue(write_file(vfsStream::url('write.txt'), $content)); + } }
\ No newline at end of file diff --git a/tests/codeigniter/helpers/inflector_helper_test.php b/tests/codeigniter/helpers/inflector_helper_test.php index f3b0ebbe8..81ce5e394 100644 --- a/tests/codeigniter/helpers/inflector_helper_test.php +++ b/tests/codeigniter/helpers/inflector_helper_test.php @@ -10,11 +10,11 @@ class Inflector_helper_test extends CI_TestCase { public function test_singular() { $strs = array( - 'tellies' => 'telly', - 'smellies' => 'smelly', - 'abjectnesses' => 'abjectness', - 'smells' => 'smell', - 'equipment' => 'equipment' + 'tellies' => 'telly', + 'smellies' => 'smelly', + 'abjectnesses' => 'abjectness', + 'smells' => 'smell', + 'equipment' => 'equipment' ); foreach ($strs as $str => $expect) @@ -28,12 +28,12 @@ class Inflector_helper_test extends CI_TestCase { public function test_plural() { $strs = array( - 'telly' => 'tellies', - 'smelly' => 'smellies', - 'abjectness' => 'abjectnesses', // ref : http://en.wiktionary.org/wiki/abjectnesses - 'smell' => 'smells', - 'witch' => 'witches', - 'equipment' => 'equipment' + 'telly' => 'tellies', + 'smelly' => 'smellies', + 'abjectness' => 'abjectnesses', // ref : http://en.wiktionary.org/wiki/abjectnesses + 'smell' => 'smells', + 'witch' => 'witches', + 'equipment' => 'equipment' ); foreach ($strs as $str => $expect) @@ -48,9 +48,9 @@ class Inflector_helper_test extends CI_TestCase { { $strs = array( 'this is the string' => 'thisIsTheString', - 'this is another one' => 'thisIsAnotherOne', - 'i-am-playing-a-trick' => 'i-am-playing-a-trick', - 'what_do_you_think-yo?' => 'whatDoYouThink-yo?', + 'this is another one' => 'thisIsAnotherOne', + 'i-am-playing-a-trick' => 'i-am-playing-a-trick', + 'what_do_you_think-yo?' => 'whatDoYouThink-yo?', ); foreach ($strs as $str => $expect) @@ -64,10 +64,10 @@ class Inflector_helper_test extends CI_TestCase { public function test_underscore() { $strs = array( - 'this is the string' => 'this_is_the_string', - 'this is another one' => 'this_is_another_one', - 'i-am-playing-a-trick' => 'i-am-playing-a-trick', - 'what_do_you_think-yo?' => 'what_do_you_think-yo?', + 'this is the string' => 'this_is_the_string', + 'this is another one' => 'this_is_another_one', + 'i-am-playing-a-trick' => 'i-am-playing-a-trick', + 'what_do_you_think-yo?' => 'what_do_you_think-yo?', ); foreach ($strs as $str => $expect) @@ -81,10 +81,10 @@ class Inflector_helper_test extends CI_TestCase { public function test_humanize() { $strs = array( - 'this_is_the_string' => 'This Is The String', - 'this_is_another_one' => 'This Is Another One', - 'i-am-playing-a-trick' => 'I-am-playing-a-trick', - 'what_do_you_think-yo?' => 'What Do You Think-yo?', + 'this_is_the_string' => 'This Is The String', + 'this_is_another_one' => 'This Is Another One', + 'i-am-playing-a-trick' => 'I-am-playing-a-trick', + 'what_do_you_think-yo?' => 'What Do You Think-yo?', ); foreach ($strs as $str => $expect) diff --git a/tests/codeigniter/libraries/Encryption_test.php b/tests/codeigniter/libraries/Encryption_test.php index 54db2b42d..a8b5bc81e 100644 --- a/tests/codeigniter/libraries/Encryption_test.php +++ b/tests/codeigniter/libraries/Encryption_test.php @@ -179,6 +179,9 @@ class Encryption_test extends CI_TestCase { * Testing the three methods separately is not realistic as they are * designed to work together. A more thorough test for initialize() * though is the OpenSSL/MCrypt compatibility test. + * + * @depends test_hkdf + * @depends test__get_params */ public function test_initialize_encrypt_decrypt() { @@ -202,6 +205,8 @@ class Encryption_test extends CI_TestCase { /** * encrypt(), decrypt test with custom parameters + * + * @depends test___get_params */ public function test_encrypt_decrypt_custom() { @@ -239,7 +244,7 @@ class Encryption_test extends CI_TestCase { { if ($this->encryption->drivers['mcrypt'] === FALSE) { - return $this->markTestAsSkipped('Cannot test MCrypt because it is not available.'); + return $this->markTestSkipped('Cannot test MCrypt because it is not available.'); } $this->assertTrue(is_resource($this->encryption->__driver_get_handle('mcrypt', 'rijndael-128', 'cbc'))); @@ -254,7 +259,7 @@ class Encryption_test extends CI_TestCase { { if ($this->encryption->drivers['openssl'] === FALSE) { - return $this->markTestAsSkipped('Cannot test OpenSSL because it is not available.'); + return $this->markTestSkipped('Cannot test OpenSSL because it is not available.'); } $this->assertEquals('aes-128-cbc', $this->encryption->__driver_get_handle('openssl', 'aes-128', 'cbc')); @@ -272,7 +277,7 @@ class Encryption_test extends CI_TestCase { { if ( ! $this->encryption->drivers['mcrypt'] OR ! $this->encryption->drivers['openssl']) { - $this->markTestAsSkipped('Both MCrypt and OpenSSL support are required for portability tests.'); + $this->markTestSkipped('Both MCrypt and OpenSSL support are required for portability tests.'); return; } diff --git a/tests/codeigniter/libraries/Session_test.php b/tests/codeigniter/libraries/Session_test.php index 97e9444ee..6f1332384 100644 --- a/tests/codeigniter/libraries/Session_test.php +++ b/tests/codeigniter/libraries/Session_test.php @@ -91,7 +91,7 @@ class Session_test extends CI_TestCase { $cmsg1 = 'Some test data'; $cmsg2 = 42; $nmsg1 = 'Other test data'; - $nmsg2 = true; + $nmsg2 = TRUE; $this->session->cookie->set_userdata($key1, $cmsg1); $this->session->set_userdata($ckey2, $cmsg2); $this->session->native->set_userdata($key1, $nmsg1); diff --git a/tests/codeigniter/libraries/Table_test.php b/tests/codeigniter/libraries/Table_test.php index ce04b6a6d..8e7452474 100644 --- a/tests/codeigniter/libraries/Table_test.php +++ b/tests/codeigniter/libraries/Table_test.php @@ -34,7 +34,7 @@ class Table_test extends CI_TestCase { } /* - * @depends testPrepArgs + * @depends test_prep_args */ public function test_set_heading() { @@ -55,7 +55,7 @@ class Table_test extends CI_TestCase { } /* - * @depends testPrepArgs + * @depends test_prep_args */ public function test_add_row() { @@ -200,16 +200,14 @@ class Table_test extends CI_TestCase { public function test_set_from_array() { - $this->assertFalse($this->table->set_from_array('bogus')); - $this->assertFalse($this->table->set_from_array(NULL)); - $data = array( array('name', 'color', 'number'), array('Laura', 'Red', '22'), array('Katie', 'Blue') ); - $this->table->set_from_array($data, FALSE); + $this->table->auto_heading = FALSE; + $this->table->set_from_array($data); $this->assertEmpty($this->table->heading); $this->table->clear(); @@ -235,22 +233,14 @@ class Table_test extends CI_TestCase { public function test_set_from_object() { - // Make a stub of query instance - $query = new CI_TestCase(); - $query->list_fields = function(){ - return array('name', 'email'); - }; - $query->result_array = function(){ - return array( - array('name' => 'John Doe', 'email' => 'john@doe.com'), - array('name' => 'Foo Bar', 'email' => 'foo@bar.com'), - ); - }; - $query->num_rows = function(){ - return 2; - }; - - $this->table->set_from_object($query); + // This needs to be passed by reference to CI_DB_result::__construct() + $dummy = new stdClass(); + $dummy->conn_id = NULL; + $dummy->result_id = NULL; + + $db_result = new DB_result_dummy($dummy); + + $this->table->set_from_db_result($db_result); $expected = array( array('data' => 'name'), @@ -290,4 +280,21 @@ class Table_test extends CI_TestCase { $this->assertTrue(strpos($table, '<td>Small</td>') !== FALSE); } +} + +// We need this for the _set_from_db_result() test +class DB_result_dummy extends CI_DB_result +{ + public function list_fields() + { + return array('name', 'email'); + } + + public function result_array() + { + return array( + array('name' => 'John Doe', 'email' => 'john@doe.com'), + array('name' => 'Foo Bar', 'email' => 'foo@bar.com') + ); + } }
\ No newline at end of file |