summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/README.md2
-rw-r--r--tests/codeigniter/core/Config_test.php13
-rw-r--r--tests/codeigniter/core/Lang_test.php7
-rw-r--r--tests/codeigniter/core/Output_test.php33
-rw-r--r--tests/codeigniter/core/Security_test.php2
-rw-r--r--tests/codeigniter/core/URI_test.php25
-rw-r--r--tests/codeigniter/core/compat/standard_test.php6
-rw-r--r--tests/codeigniter/libraries/Encryption_test.php7
-rw-r--r--tests/mocks/ci_testcase.php13
-rw-r--r--tests/mocks/database/schema/skeleton.php34
10 files changed, 70 insertions, 72 deletions
diff --git a/tests/README.md b/tests/README.md
index 3e32edc0c..47b5241d1 100644
--- a/tests/README.md
+++ b/tests/README.md
@@ -1,6 +1,6 @@
# CodeIgniter Unit Tests #
-Status : [![Build Status](https://secure.travis-ci.org/EllisLab/CodeIgniter.png?branch=develop)](http://travis-ci.org/EllisLab/CodeIgniter)
+Status : [![Build Status](https://secure.travis-ci.org/bcit-ci/CodeIgniter.png?branch=develop)](http://travis-ci.org/bcit-ci/CodeIgniter)
### Introduction:
diff --git a/tests/codeigniter/core/Config_test.php b/tests/codeigniter/core/Config_test.php
index 8e312e361..f125fc6e9 100644
--- a/tests/codeigniter/core/Config_test.php
+++ b/tests/codeigniter/core/Config_test.php
@@ -205,13 +205,18 @@ class Config_test extends CI_TestCase {
'number' => 42,
'letter' => 'Z'
);
+
$pkg_dir = 'package';
- $this->ci_vfs_create($file.'.php', '<?php $config = '.var_export($cfg2, TRUE).';', $this->ci_app_root,
- array($pkg_dir, 'config'));
- $this->config->_config_paths[] = $this->ci_vfs_path($pkg_dir.'/', APPPATH);
+ $this->ci_vfs_create(
+ $file.'.php',
+ '<?php $config = '.var_export($cfg2, TRUE).';',
+ $this->ci_app_root,
+ array($pkg_dir, 'config')
+ );
+ array_unshift($this->config->_config_paths, $this->ci_vfs_path($pkg_dir.'/', APPPATH));
$this->assertTrue($this->config->load($file, TRUE));
$this->assertEquals(array_merge($cfg, $cfg2), $this->config->item($file));
- array_pop($this->config->_config_paths);
+ array_shift($this->config->_config_paths);
// Test graceful fail of invalid file
$file = 'badfile';
diff --git a/tests/codeigniter/core/Lang_test.php b/tests/codeigniter/core/Lang_test.php
index d3c7ee1e4..87a71c885 100644
--- a/tests/codeigniter/core/Lang_test.php
+++ b/tests/codeigniter/core/Lang_test.php
@@ -29,6 +29,11 @@ class Lang_test extends CI_TestCase {
$this->assertTrue($this->lang->load('date'));
$this->assertEquals('Year', $this->lang->language['date_year']);
+ // A language other than english
+ $this->ci_vfs_clone('system/language/english/email_lang.php', 'system/language/german/');
+ $this->assertTrue($this->lang->load('email', 'german'));
+ $this->assertEquals('german', $this->lang->is_loaded['email_lang.php'] );
+
// Non-alpha idiom (should act the same as unspecified language)
$this->ci_vfs_clone('system/language/english/number_lang.php');
$this->assertTrue($this->lang->load('number'));
@@ -56,4 +61,4 @@ class Lang_test extends CI_TestCase {
$this->assertFalse($this->lang->line(NULL));
}
-} \ No newline at end of file
+}
diff --git a/tests/codeigniter/core/Output_test.php b/tests/codeigniter/core/Output_test.php
index 0eeb93f7b..887c077d7 100644
--- a/tests/codeigniter/core/Output_test.php
+++ b/tests/codeigniter/core/Output_test.php
@@ -3,19 +3,20 @@
class Output_test extends CI_TestCase {
public $output;
- protected $_output_data = <<<HTML
-<html>
- <head>
- <title>Basic HTML</title>
- </head>
- <body>
- Test
- </body>
-</html>
-HTML;
+ protected $_output_data = '';
public function set_up()
{
+ $this->_output_data =<<<HTML
+ <html>
+ <head>
+ <title>Basic HTML</title>
+ </head>
+ <body>
+ Test
+ </body>
+ </html>
+HTML;
$this->ci_set_config('charset', 'UTF-8');
$output = $this->ci_core_class('output');
$this->output = new $output();
@@ -38,16 +39,6 @@ HTML;
// --------------------------------------------------------------------
- public function test_minify()
- {
- $this->assertEquals(
- str_replace(array("\t", "\n"), '', $this->_output_data),
- $this->output->minify($this->_output_data)
- );
- }
-
- // --------------------------------------------------------------------
-
public function test_get_content_type()
{
$this->assertEquals('text/html', $this->output->get_content_type());
@@ -69,4 +60,4 @@ HTML;
);
}
-} \ No newline at end of file
+}
diff --git a/tests/codeigniter/core/Security_test.php b/tests/codeigniter/core/Security_test.php
index c80c3d65a..402422ff8 100644
--- a/tests/codeigniter/core/Security_test.php
+++ b/tests/codeigniter/core/Security_test.php
@@ -98,7 +98,7 @@ class Security_test extends CI_TestCase {
$this->assertEquals('<div>Hello <b>Booya</b></div>', $decoded);
- // Issue #3057 (https://github.com/EllisLab/CodeIgniter/issues/3057)
+ // Issue #3057 (https://github.com/bcit-ci/CodeIgniter/issues/3057)
$this->assertEquals(
'&foo should not include a semicolon',
$this->security->entity_decode('&foo should not include a semicolon')
diff --git a/tests/codeigniter/core/URI_test.php b/tests/codeigniter/core/URI_test.php
index 6589c1f5a..50663d54a 100644
--- a/tests/codeigniter/core/URI_test.php
+++ b/tests/codeigniter/core/URI_test.php
@@ -11,7 +11,7 @@ class URI_test extends CI_TestCase {
/* As of the following commit, _set_uri_string() is a protected method:
- https://github.com/EllisLab/CodeIgniter/commit/d461934184d95b0cfb2feec93f27b621ef72a5c2
+ https://github.com/bcit-ci/CodeIgniter/commit/d461934184d95b0cfb2feec93f27b621ef72a5c2
public function test_set_uri_string()
{
@@ -119,26 +119,12 @@ class URI_test extends CI_TestCase {
*/
// --------------------------------------------------------------------
- public function test_filter_uri()
+ public function test_filter_uri_passing()
{
$this->uri->_set_permitted_uri_chars('a-z 0-9~%.:_\-');
- $str_in = 'abc01239~%.:_-';
- $str = $this->uri->filter_uri($str_in);
-
- $this->assertEquals($str, $str_in);
- }
-
- // --------------------------------------------------------------------
-
- public function test_filter_uri_escaping()
- {
- // ensure escaping even if dodgey characters are permitted
- $this->uri->_set_permitted_uri_chars('a-z 0-9~%.:_\-()$');
-
- $str = $this->uri->filter_uri('$destroy_app(foo)');
-
- $this->assertEquals($str, '&#36;destroy_app&#40;foo&#41;');
+ $str = 'abc01239~%.:_-';
+ $this->uri->filter_uri($str);
}
// --------------------------------------------------------------------
@@ -149,7 +135,8 @@ class URI_test extends CI_TestCase {
$this->uri->config->set_item('enable_query_strings', FALSE);
$this->uri->_set_permitted_uri_chars('a-z 0-9~%.:_\-');
- $this->uri->filter_uri('$this()');
+ $segment = '$this()'; // filter_uri() accepts by reference
+ $this->uri->filter_uri($segment);
}
// --------------------------------------------------------------------
diff --git a/tests/codeigniter/core/compat/standard_test.php b/tests/codeigniter/core/compat/standard_test.php
index a3a6d9552..4077a5c7c 100644
--- a/tests/codeigniter/core/compat/standard_test.php
+++ b/tests/codeigniter/core/compat/standard_test.php
@@ -449,7 +449,6 @@ class standard_test extends CI_TestCase {
return $this->markTestSkipped('quoted_printable_encode() is already available on PHP 5.3');
}
-
// These are actually imap_8bit() tests:
$this->assertEquals("String with CRLF at end=20\r\n", quoted_printable_encode("String with CRLF at end \r\n"));
// ext/imap/tests/imap_8bit_basic.phpt says for this line:
@@ -459,6 +458,11 @@ class standard_test extends CI_TestCase {
$this->assertEquals("String with tab at end =09", quoted_printable_encode("String with tab at end \t"));
$this->assertEquals("=00=01=02=03=04=FE=FF=0A=0D", quoted_printable_encode("\x00\x01\x02\x03\x04\xfe\xff\x0a\x0d"));
+ if (function_exists('imap_8bit'))
+ {
+ return $this->markTestIncomplete('imap_8bit() exists and is called as an alias for quoted_printable_encode()');
+ }
+
// And these are from ext/standard/tests/strings/quoted_printable_encode_002.phpt:
$this->assertEquals(
"=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=00=\r\n"
diff --git a/tests/codeigniter/libraries/Encryption_test.php b/tests/codeigniter/libraries/Encryption_test.php
index f457fe325..cbcae3133 100644
--- a/tests/codeigniter/libraries/Encryption_test.php
+++ b/tests/codeigniter/libraries/Encryption_test.php
@@ -155,15 +155,16 @@ class Encryption_test extends CI_TestCase {
);
$output = $this->encryption->__get_params($params);
- unset($output['handle'], $params['raw_data']);
+ unset($output['handle'], $output['cipher'], $params['raw_data'], $params['cipher']);
$params['base64'] = FALSE;
$this->assertEquals($params, $output);
// HMAC disabled
unset($params['hmac_key'], $params['hmac_digest']);
$params['hmac'] = $params['raw_data'] = FALSE;
+ $params['cipher'] = 'aes-128';
$output = $this->encryption->__get_params($params);
- unset($output['handle'], $params['hmac'], $params['raw_data']);
+ unset($output['handle'], $output['cipher'], $params['hmac'], $params['raw_data'], $params['cipher']);
$params['base64'] = TRUE;
$params['hmac_digest'] = $params['hmac_key'] = NULL;
$this->assertEquals($params, $output);
@@ -195,7 +196,7 @@ class Encryption_test extends CI_TestCase {
$this->assertEquals($message, $this->encryption->decrypt($this->encryption->encrypt($message)));
// Try DES in ECB mode, just for the sake of changing stuff
- $this->encryption->initialize(array('cipher' => 'des', 'mode' => 'ecb'));
+ $this->encryption->initialize(array('cipher' => 'des', 'mode' => 'ecb', 'key' => substr($key, 0, 8)));
$this->assertEquals($message, $this->encryption->decrypt($this->encryption->encrypt($message)));
}
diff --git a/tests/mocks/ci_testcase.php b/tests/mocks/ci_testcase.php
index ad4fe5ac3..a2c37b92e 100644
--- a/tests/mocks/ci_testcase.php
+++ b/tests/mocks/ci_testcase.php
@@ -274,14 +274,14 @@ class CI_TestCase extends PHPUnit_Framework_TestCase {
* @param string Path from base directory
* @return bool TRUE on success, otherwise FALSE
*/
- public function ci_vfs_clone($path)
+ public function ci_vfs_clone($path, $dest='')
{
// Check for array
if (is_array($path))
{
foreach ($path as $file)
{
- $this->ci_vfs_clone($file);
+ $this->ci_vfs_clone($file, $dest);
}
return;
}
@@ -294,7 +294,12 @@ class CI_TestCase extends PHPUnit_Framework_TestCase {
return FALSE;
}
- $this->ci_vfs_create(basename($path), $content, NULL, dirname($path));
+ if (empty($dest))
+ {
+ $dest = dirname($path);
+ }
+
+ $this->ci_vfs_create(basename($path), $content, NULL, $dest);
return TRUE;
}
@@ -378,4 +383,4 @@ class CI_TestCase extends PHPUnit_Framework_TestCase {
}
}
-} \ No newline at end of file
+}
diff --git a/tests/mocks/database/schema/skeleton.php b/tests/mocks/database/schema/skeleton.php
index e5c536090..b6d4b7893 100644
--- a/tests/mocks/database/schema/skeleton.php
+++ b/tests/mocks/database/schema/skeleton.php
@@ -22,7 +22,7 @@ class Mock_Database_Schema_Skeleton {
*/
public static function init($driver)
{
- if (empty(static::$db) && empty(static::$forge))
+ if (empty(self::$db) && empty(self::$forge))
{
$config = Mock_Database_DB::config($driver);
$connection = new Mock_Database_DB($config);
@@ -34,12 +34,12 @@ class Mock_Database_Schema_Skeleton {
$loader->dbforge();
$forge = CI_TestCase::instance()->ci_instance_var('dbforge');
- static::$db = $db;
- static::$forge = $forge;
- static::$driver = $driver;
+ self::$db = $db;
+ self::$forge = $forge;
+ self::$driver = $driver;
}
- return static::$db;
+ return self::$db;
}
/**
@@ -50,7 +50,7 @@ class Mock_Database_Schema_Skeleton {
public static function create_tables()
{
// User Table
- static::$forge->add_field(array(
+ self::$forge->add_field(array(
'id' => array(
'type' => 'INTEGER',
'constraint' => 3
@@ -68,11 +68,11 @@ class Mock_Database_Schema_Skeleton {
'constraint' => 40
)
));
- static::$forge->add_key('id', TRUE);
- static::$forge->create_table('user', TRUE);
+ self::$forge->add_key('id', TRUE);
+ self::$forge->create_table('user', TRUE);
// Job Table
- static::$forge->add_field(array(
+ self::$forge->add_field(array(
'id' => array(
'type' => 'INTEGER',
'constraint' => 3
@@ -85,11 +85,11 @@ class Mock_Database_Schema_Skeleton {
'type' => 'TEXT'
)
));
- static::$forge->add_key('id', TRUE);
- static::$forge->create_table('job', TRUE);
+ self::$forge->add_key('id', TRUE);
+ self::$forge->create_table('job', TRUE);
// Misc Table
- static::$forge->add_field(array(
+ self::$forge->add_field(array(
'id' => array(
'type' => 'INTEGER',
'constraint' => 3
@@ -102,8 +102,8 @@ class Mock_Database_Schema_Skeleton {
'type' => 'TEXT'
)
));
- static::$forge->add_key('id', TRUE);
- static::$forge->create_table('misc', TRUE);
+ self::$forge->add_key('id', TRUE);
+ self::$forge->create_table('misc', TRUE);
}
/**
@@ -136,13 +136,13 @@ class Mock_Database_Schema_Skeleton {
foreach ($data as $table => $dummy_data)
{
- static::$db->truncate($table);
+ self::$db->truncate($table);
foreach ($dummy_data as $single_dummy_data)
{
- static::$db->insert($table, $single_dummy_data);
+ self::$db->insert($table, $single_dummy_data);
}
}
}
-} \ No newline at end of file
+}