diff options
author | Taufan Aditya <toopay@taufanaditya.com> | 2012-05-27 08:51:27 +0200 |
---|---|---|
committer | Taufan Aditya <toopay@taufanaditya.com> | 2012-05-27 08:51:27 +0200 |
commit | 6c7526c95b3fbd502dc8105a67fd38da793caa4e (patch) | |
tree | 5e3ec6bbccd6105cb993601f0c4356374e3cb2dd /tests | |
parent | 650f2a2bc15dd575f50446dcc1315c131652ca49 (diff) |
Continuation for Security and Table code-coverage, add coverage report to travis
Diffstat (limited to 'tests')
-rw-r--r-- | tests/codeigniter/core/Security_test.php | 32 | ||||
-rw-r--r-- | tests/codeigniter/libraries/Table_test.php | 24 | ||||
-rw-r--r-- | tests/mocks/autoloader.php | 4 | ||||
-rw-r--r-- | tests/travis/mysql.phpunit.xml | 11 | ||||
-rw-r--r-- | tests/travis/pdo/mysql.phpunit.xml | 11 | ||||
-rw-r--r-- | tests/travis/pdo/pgsql.phpunit.xml | 11 | ||||
-rw-r--r-- | tests/travis/pdo/sqlite.phpunit.xml | 11 | ||||
-rw-r--r-- | tests/travis/pgsql.phpunit.xml | 11 | ||||
-rw-r--r-- | tests/travis/sqlite.phpunit.xml | 11 |
9 files changed, 86 insertions, 40 deletions
diff --git a/tests/codeigniter/core/Security_test.php b/tests/codeigniter/core/Security_test.php index 1796ba74d..b2f8c69d2 100644 --- a/tests/codeigniter/core/Security_test.php +++ b/tests/codeigniter/core/Security_test.php @@ -70,4 +70,36 @@ class Security_test extends CI_TestCase { $this->assertEquals("Hello, i try to [removed]alert('Hack');[removed] your site", $harmless_string); } + + // -------------------------------------------------------------------- + + public function test_xss_hash() + { + $this->assertEmpty($this->security->xss_hash); + + // Perform hash + $this->security->xss_hash(); + + $this->assertTrue(preg_match('#^[0-9a-f]{32}$#iS', $this->security->xss_hash) === 1); + } + + // -------------------------------------------------------------------- + + public function test_entity_decode() + { + $encoded = '<div>Hello <b>Booya</b></div>'; + $decoded = $this->security->entity_decode($encoded); + + $this->assertEquals('<div>Hello <b>Booya</b></div>', $decoded); + } + + // -------------------------------------------------------------------- + + public function test_sanitize_filename() + { + $filename = './<!--foo-->'; + $safe_filename = $this->security->sanitize_filename($filename); + + $this->assertEquals('foo', $safe_filename); + } }
\ No newline at end of file diff --git a/tests/codeigniter/libraries/Table_test.php b/tests/codeigniter/libraries/Table_test.php index 13f338c6b..f5133de1e 100644 --- a/tests/codeigniter/libraries/Table_test.php +++ b/tests/codeigniter/libraries/Table_test.php @@ -291,6 +291,26 @@ class Table_test extends CI_TestCase { ); } - // Test main generate method - // -------------------------------------------------------------------- + function test_generate() + { + // Prepare the data + $data = array( + array('Name', 'Color', 'Size'), + array('Fred', 'Blue', 'Small'), + array('Mary', 'Red', 'Large'), + array('John', 'Green', 'Medium') + ); + + $table = $this->table->generate($data); + + // Test the table header + $this->assertTrue(strpos($table, '<th>Name</th>') !== FALSE); + $this->assertTrue(strpos($table, '<th>Color</th>') !== FALSE); + $this->assertTrue(strpos($table, '<th>Size</th>') !== FALSE); + + // Test the first entry + $this->assertTrue(strpos($table, '<td>Fred</td>') !== FALSE); + $this->assertTrue(strpos($table, '<td>Blue</td>') !== FALSE); + $this->assertTrue(strpos($table, '<td>Small</td>') !== FALSE); + } }
\ No newline at end of file diff --git a/tests/mocks/autoloader.php b/tests/mocks/autoloader.php index 92c9bea59..441c88944 100644 --- a/tests/mocks/autoloader.php +++ b/tests/mocks/autoloader.php @@ -22,7 +22,7 @@ function autoload($class) ); $ci_libraries = array( - 'Calendar', 'Cart', 'Driver', + 'Calendar', 'Cart', 'Driver_Library', 'Email', 'Encrypt', 'Form_validation', 'Ftp', 'Image_lib', 'Javascript', 'Log', 'Migration', 'Pagination', @@ -50,7 +50,7 @@ function autoload($class) elseif (in_array($subclass, $ci_libraries)) { $dir = BASEPATH.'libraries'.DIRECTORY_SEPARATOR; - $class = $subclass; + $class = ($subclass == 'Driver_Library') ? 'Driver' : $subclass; } elseif (preg_match('/^CI_DB_(.+)_(driver|forge|result|utility)$/', $class, $m) && count($m) == 3) { diff --git a/tests/travis/mysql.phpunit.xml b/tests/travis/mysql.phpunit.xml index 1792ae38d..38c8eba48 100644 --- a/tests/travis/mysql.phpunit.xml +++ b/tests/travis/mysql.phpunit.xml @@ -17,10 +17,9 @@ <directory suffix="test.php">../codeigniter</directory> </testsuite> </testsuites> - <filters> - <blacklist> - <directory suffix=".php">PEAR_INSTALL_DIR</directory> - <directory suffix=".php">PHP_LIBDIR</directory> - </blacklist> - </filters> + <filter> + <whitelist addUncoveredFilesFromWhitelist="true"> + <directory suffix=".php">../../system</directory> + </whitelist> + </filter> </phpunit>
\ No newline at end of file diff --git a/tests/travis/pdo/mysql.phpunit.xml b/tests/travis/pdo/mysql.phpunit.xml index 602030d4e..c3113a66f 100644 --- a/tests/travis/pdo/mysql.phpunit.xml +++ b/tests/travis/pdo/mysql.phpunit.xml @@ -17,10 +17,9 @@ <directory suffix="test.php">../../codeigniter</directory> </testsuite> </testsuites> - <filters> - <blacklist> - <directory suffix=".php">PEAR_INSTALL_DIR</directory> - <directory suffix=".php">PHP_LIBDIR</directory> - </blacklist> - </filters> + <filter> + <whitelist addUncoveredFilesFromWhitelist="true"> + <directory suffix=".php">../../../system</directory> + </whitelist> + </filter> </phpunit>
\ No newline at end of file diff --git a/tests/travis/pdo/pgsql.phpunit.xml b/tests/travis/pdo/pgsql.phpunit.xml index 77e1493c6..232025523 100644 --- a/tests/travis/pdo/pgsql.phpunit.xml +++ b/tests/travis/pdo/pgsql.phpunit.xml @@ -17,10 +17,9 @@ <directory suffix="test.php">../../codeigniter</directory> </testsuite> </testsuites> - <filters> - <blacklist> - <directory suffix=".php">PEAR_INSTALL_DIR</directory> - <directory suffix=".php">PHP_LIBDIR</directory> - </blacklist> - </filters> + <filter> + <whitelist addUncoveredFilesFromWhitelist="true"> + <directory suffix=".php">../../../system</directory> + </whitelist> + </filter> </phpunit>
\ No newline at end of file diff --git a/tests/travis/pdo/sqlite.phpunit.xml b/tests/travis/pdo/sqlite.phpunit.xml index cdccef017..3d1256721 100644 --- a/tests/travis/pdo/sqlite.phpunit.xml +++ b/tests/travis/pdo/sqlite.phpunit.xml @@ -17,10 +17,9 @@ <directory suffix="test.php">../../codeigniter</directory> </testsuite> </testsuites> - <filters> - <blacklist> - <directory suffix=".php">PEAR_INSTALL_DIR</directory> - <directory suffix=".php">PHP_LIBDIR</directory> - </blacklist> - </filters> + <filter> + <whitelist addUncoveredFilesFromWhitelist="true"> + <directory suffix=".php">../../../system</directory> + </whitelist> + </filter> </phpunit>
\ No newline at end of file diff --git a/tests/travis/pgsql.phpunit.xml b/tests/travis/pgsql.phpunit.xml index dfc1bff1c..51e433d76 100644 --- a/tests/travis/pgsql.phpunit.xml +++ b/tests/travis/pgsql.phpunit.xml @@ -17,10 +17,9 @@ <directory suffix="test.php">../codeigniter</directory> </testsuite> </testsuites> - <filters> - <blacklist> - <directory suffix=".php">PEAR_INSTALL_DIR</directory> - <directory suffix=".php">PHP_LIBDIR</directory> - </blacklist> - </filters> + <filter> + <whitelist addUncoveredFilesFromWhitelist="true"> + <directory suffix=".php">../../system</directory> + </whitelist> + </filter> </phpunit>
\ No newline at end of file diff --git a/tests/travis/sqlite.phpunit.xml b/tests/travis/sqlite.phpunit.xml index 3223da5e7..701165734 100644 --- a/tests/travis/sqlite.phpunit.xml +++ b/tests/travis/sqlite.phpunit.xml @@ -17,10 +17,9 @@ <directory suffix="test.php">../codeigniter</directory> </testsuite> </testsuites> - <filters> - <blacklist> - <directory suffix=".php">PEAR_INSTALL_DIR</directory> - <directory suffix=".php">PHP_LIBDIR</directory> - </blacklist> - </filters> + <filter> + <whitelist addUncoveredFilesFromWhitelist="true"> + <directory suffix=".php">../../system</directory> + </whitelist> + </filter> </phpunit>
\ No newline at end of file |