summaryrefslogtreecommitdiffstats
path: root/tests/codeigniter
diff options
context:
space:
mode:
Diffstat (limited to 'tests/codeigniter')
-rw-r--r--tests/codeigniter/Setup_test.php6
-rw-r--r--tests/codeigniter/core/Benchmark_test.php11
-rw-r--r--tests/codeigniter/core/Common_test.php6
-rw-r--r--tests/codeigniter/core/Config_test.php38
-rw-r--r--tests/codeigniter/core/Input_test.php28
-rw-r--r--tests/codeigniter/core/Lang_test.php12
-rw-r--r--tests/codeigniter/core/Loader_test.php132
-rw-r--r--tests/codeigniter/core/Security_test.php23
-rw-r--r--tests/codeigniter/core/URI_test.php225
-rw-r--r--tests/codeigniter/database/query_builder/count_test.php12
-rw-r--r--tests/codeigniter/database/query_builder/delete_test.php16
-rw-r--r--tests/codeigniter/database/query_builder/distinct_test.php9
-rw-r--r--tests/codeigniter/database/query_builder/escape_test.php5
-rw-r--r--tests/codeigniter/database/query_builder/from_test.php18
-rw-r--r--tests/codeigniter/database/query_builder/get_test.php6
-rw-r--r--tests/codeigniter/database/query_builder/group_test.php26
-rw-r--r--tests/codeigniter/database/query_builder/join_test.php2
-rw-r--r--tests/codeigniter/database/query_builder/like_test.php2
-rw-r--r--tests/codeigniter/database/query_builder/limit_test.php7
-rw-r--r--tests/codeigniter/database/query_builder/order_test.php6
-rw-r--r--tests/codeigniter/database/query_builder/select_test.php12
-rw-r--r--tests/codeigniter/database/query_builder/truncate_test.php7
-rw-r--r--tests/codeigniter/database/query_builder/update_test.php26
-rw-r--r--tests/codeigniter/database/query_builder/where_test.php28
-rw-r--r--tests/codeigniter/helpers/number_helper_test.php2
-rw-r--r--tests/codeigniter/libraries/Encrypt_test.php131
-rw-r--r--tests/codeigniter/libraries/Parser_test.php61
-rw-r--r--tests/codeigniter/libraries/Table_test.php153
-rw-r--r--tests/codeigniter/libraries/Typography_test.php40
-rw-r--r--tests/codeigniter/libraries/Useragent_test.php6
30 files changed, 463 insertions, 593 deletions
diff --git a/tests/codeigniter/Setup_test.php b/tests/codeigniter/Setup_test.php
index b48e32bfb..5317c56c7 100644
--- a/tests/codeigniter/Setup_test.php
+++ b/tests/codeigniter/Setup_test.php
@@ -1,13 +1,13 @@
<?php
class Setup_test extends PHPUnit_Framework_TestCase {
-
- function test_bootstrap_constants()
+
+ public function test_bootstrap_constants()
{
$this->assertTrue(defined('PROJECT_BASE'));
$this->assertTrue(defined('BASEPATH'));
$this->assertTrue(defined('APPPATH'));
$this->assertTrue(defined('VIEWPATH'));
}
-
+
} \ No newline at end of file
diff --git a/tests/codeigniter/core/Benchmark_test.php b/tests/codeigniter/core/Benchmark_test.php
index 109b38821..a239ba51d 100644
--- a/tests/codeigniter/core/Benchmark_test.php
+++ b/tests/codeigniter/core/Benchmark_test.php
@@ -1,14 +1,14 @@
<?php
class Benchmark_test extends CI_TestCase {
-
+
public function set_up()
{
$this->benchmark = new Mock_Core_Benchmark();
}
-
+
// --------------------------------------------------------------------
-
+
public function test_mark()
{
$this->assertEmpty($this->benchmark->marker);
@@ -18,7 +18,7 @@ class Benchmark_test extends CI_TestCase {
$this->assertEquals(1, count($this->benchmark->marker));
$this->assertArrayHasKey('code_start', $this->benchmark->marker);
}
-
+
// --------------------------------------------------------------------
public function test_elapsed_time()
@@ -29,7 +29,7 @@ class Benchmark_test extends CI_TestCase {
$this->benchmark->mark('code_start');
sleep(1);
$this->benchmark->mark('code_end');
-
+
$this->assertEquals('1.0', $this->benchmark->elapsed_time('code_start', 'code_end', 1));
}
@@ -39,4 +39,5 @@ class Benchmark_test extends CI_TestCase {
{
$this->assertEquals('{memory_usage}', $this->benchmark->memory_usage());
}
+
} \ No newline at end of file
diff --git a/tests/codeigniter/core/Common_test.php b/tests/codeigniter/core/Common_test.php
index dded2e824..f9bf6c27f 100644
--- a/tests/codeigniter/core/Common_test.php
+++ b/tests/codeigniter/core/Common_test.php
@@ -1,13 +1,13 @@
<?php
class Common_test extends CI_TestCase {
-
+
// ------------------------------------------------------------------------
-
+
public function test_is_php()
{
$this->assertEquals(TRUE, is_php('1.2.0'));
$this->assertEquals(FALSE, is_php('9999.9.9'));
}
-
+
} \ No newline at end of file
diff --git a/tests/codeigniter/core/Config_test.php b/tests/codeigniter/core/Config_test.php
index 30f0cc61d..30cb90a28 100644
--- a/tests/codeigniter/core/Config_test.php
+++ b/tests/codeigniter/core/Config_test.php
@@ -5,7 +5,7 @@ class Config_test extends CI_TestCase {
public function set_up()
{
$cls =& $this->ci_core_class('cfg');
-
+
// set predictable config values
$this->ci_set_config(array(
'index_page' => 'index.php',
@@ -13,9 +13,9 @@ class Config_test extends CI_TestCase {
'subclass_prefix' => 'MY_'
));
- $this->config = new $cls;
+ $this->config = new $cls;
}
-
+
// --------------------------------------------------------------------
public function test_item()
@@ -24,30 +24,30 @@ class Config_test extends CI_TestCase {
// Bad Config value
$this->assertFalse($this->config->item('no_good_item'));
-
+
// Index
$this->assertFalse($this->config->item('no_good_item', 'bad_index'));
$this->assertFalse($this->config->item('no_good_item', 'default'));
}
-
+
// --------------------------------------------------------------------
-
+
public function test_set_item()
{
$this->assertFalse($this->config->item('not_yet_set'));
-
+
$this->config->set_item('not_yet_set', 'is set');
-
+
$this->assertEquals('is set', $this->config->item('not_yet_set'));
}
// --------------------------------------------------------------------
-
+
public function test_slash_item()
{
// Bad Config value
$this->assertFalse($this->config->slash_item('no_good_item'));
-
+
$this->assertEquals('http://example.com/', $this->config->slash_item('base_url'));
$this->assertEquals('MY_/', $this->config->slash_item('subclass_prefix'));
@@ -58,33 +58,33 @@ class Config_test extends CI_TestCase {
public function test_site_url()
{
$this->assertEquals('http://example.com/index.php', $this->config->site_url());
-
+
$base_url = $this->config->item('base_url');
-
+
$this->config->set_item('base_url', '');
-
+
$q_string = $this->config->item('enable_query_strings');
-
+
$this->config->set_item('enable_query_strings', FALSE);
$this->assertEquals('index.php/test', $this->config->site_url('test'));
$this->assertEquals('index.php/test/1', $this->config->site_url(array('test', '1')));
-
+
$this->config->set_item('enable_query_strings', TRUE);
$this->assertEquals('index.php?test', $this->config->site_url('test'));
$this->assertEquals('index.php?0=test&1=1', $this->config->site_url(array('test', '1')));
-
+
$this->config->set_item('base_url', $base_url);
$this->assertEquals('http://example.com/index.php?test', $this->config->site_url('test'));
-
+
// back to home base
- $this->config->set_item('enable_query_strings', $q_string);
+ $this->config->set_item('enable_query_strings', $q_string);
}
// --------------------------------------------------------------------
-
+
public function test_system_url()
{
$this->assertEquals('http://example.com/system/', $this->config->system_url());
diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php
index c9322c027..fe8738832 100644
--- a/tests/codeigniter/core/Input_test.php
+++ b/tests/codeigniter/core/Input_test.php
@@ -1,7 +1,7 @@
<?php
class Input_test extends CI_TestCase {
-
+
public function set_up()
{
// Set server variable to GET as default, since this will leave unset in STDIN env
@@ -17,9 +17,9 @@ class Input_test extends CI_TestCase {
$this->input = new Mock_Core_Input($security, $utf8);
}
-
+
// --------------------------------------------------------------------
-
+
public function test_get_not_exists()
{
$this->assertEmpty($this->input->get());
@@ -38,7 +38,7 @@ class Input_test extends CI_TestCase {
}
// --------------------------------------------------------------------
-
+
public function test_get_exist()
{
$_SERVER['REQUEST_METHOD'] = 'GET';
@@ -49,7 +49,7 @@ class Input_test extends CI_TestCase {
}
// --------------------------------------------------------------------
-
+
public function test_get_exist_with_xss_clean()
{
$_SERVER['REQUEST_METHOD'] = 'GET';
@@ -61,7 +61,7 @@ class Input_test extends CI_TestCase {
}
// --------------------------------------------------------------------
-
+
public function test_post_not_exists()
{
$this->assertEmpty($this->input->post());
@@ -78,7 +78,7 @@ class Input_test extends CI_TestCase {
}
// --------------------------------------------------------------------
-
+
public function test_post_exist()
{
$_SERVER['REQUEST_METHOD'] = 'POST';
@@ -89,7 +89,7 @@ class Input_test extends CI_TestCase {
}
// --------------------------------------------------------------------
-
+
public function test_post_exist_with_xss_clean()
{
$_SERVER['REQUEST_METHOD'] = 'POST';
@@ -101,7 +101,7 @@ class Input_test extends CI_TestCase {
}
// --------------------------------------------------------------------
-
+
public function test_get_post()
{
$_SERVER['REQUEST_METHOD'] = 'POST';
@@ -111,7 +111,7 @@ class Input_test extends CI_TestCase {
}
// --------------------------------------------------------------------
-
+
public function test_cookie()
{
$_COOKIE['foo'] = 'bar';
@@ -120,14 +120,14 @@ class Input_test extends CI_TestCase {
}
// --------------------------------------------------------------------
-
+
public function test_server()
{
$this->assertEquals('GET', $this->input->server('REQUEST_METHOD'));
}
// --------------------------------------------------------------------
-
+
public function test_fetch_from_array()
{
$data = array(
@@ -145,14 +145,14 @@ class Input_test extends CI_TestCase {
}
// --------------------------------------------------------------------
-
+
public function test_valid_ip()
{
$ip_v4 = '192.18.0.1';
$this->assertTrue($this->input->valid_ip($ip_v4));
$ip_v6 = array('2001:0db8:0000:85a3:0000:0000:ac1f:8001', '2001:db8:0:85a3:0:0:ac1f:8001', '2001:db8:0:85a3::ac1f:8001');
- foreach($ip_v6 as $ip)
+ foreach ($ip_v6 as $ip)
{
$this->assertTrue($this->input->valid_ip($ip));
}
diff --git a/tests/codeigniter/core/Lang_test.php b/tests/codeigniter/core/Lang_test.php
index 874230feb..a410dabfa 100644
--- a/tests/codeigniter/core/Lang_test.php
+++ b/tests/codeigniter/core/Lang_test.php
@@ -1,9 +1,9 @@
<?php
class Lang_test extends CI_TestCase {
-
+
protected $lang;
-
+
public function set_up()
{
$loader_cls = $this->ci_core_class('load');
@@ -12,9 +12,9 @@ class Lang_test extends CI_TestCase {
$cls = $this->ci_core_class('lang');
$this->lang = new $cls;
}
-
+
// --------------------------------------------------------------------
-
+
public function test_load()
{
$this->assertTrue($this->lang->load('profiler', 'english'));
@@ -22,11 +22,11 @@ class Lang_test extends CI_TestCase {
}
// --------------------------------------------------------------------
-
+
public function test_load_with_unspecified_language()
{
$this->assertTrue($this->lang->load('profiler'));
$this->assertEquals('URI STRING', $this->lang->line('profiler_uri_string'));
}
-
+
} \ No newline at end of file
diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php
index 43008651e..fdea962b7 100644
--- a/tests/codeigniter/core/Loader_test.php
+++ b/tests/codeigniter/core/Loader_test.php
@@ -1,35 +1,35 @@
<?php
class Loader_test extends CI_TestCase {
-
+
private $ci_obj;
-
+
public function set_up()
{
// Instantiate a new loader
$this->load = new Mock_Core_Loader();
-
+
// mock up a ci instance
- $this->ci_obj = new StdClass;
-
+ $this->ci_obj = new stdClass;
+
// Fix get_instance()
$this->ci_instance($this->ci_obj);
}
// --------------------------------------------------------------------
-
+
public function test_library()
{
$this->_setup_config_mock();
-
+
// Test loading as an array.
$this->assertNull($this->load->library(array('table')));
$this->assertTrue(class_exists('CI_Table'), 'Table class exists');
$this->assertAttributeInstanceOf('CI_Table', 'table', $this->ci_obj);
-
+
// Test no lib given
$this->assertEquals(FALSE, $this->load->library());
-
+
// Test a string given to params
$this->assertEquals(NULL, $this->load->library('table', ' '));
}
@@ -39,20 +39,18 @@ class Loader_test extends CI_TestCase {
public function test_load_library_in_application_dir()
{
$this->_setup_config_mock();
-
+
$content = '<?php class Super_test_library {} ';
-
- $model = vfsStream::newFile('Super_test_library.php')->withContent($content)
- ->at($this->load->libs_dir);
-
+
+ $model = vfsStream::newFile('Super_test_library.php')->withContent($content)->at($this->load->libs_dir);
$this->assertNull($this->load->library('super_test_library'));
-
+
// Was the model class instantiated.
- $this->assertTrue(class_exists('Super_test_library'));
+ $this->assertTrue(class_exists('Super_test_library'));
}
-
+
// --------------------------------------------------------------------
-
+
private function _setup_config_mock()
{
// Mock up a config object until we
@@ -61,7 +59,7 @@ class Loader_test extends CI_TestCase {
$config->expects($this->any())
->method('load')
->will($this->returnValue(TRUE));
-
+
// Add the mock to our stdClass
$this->ci_instance_var('config', $config);
}
@@ -73,64 +71,62 @@ class Loader_test extends CI_TestCase {
$this->setExpectedException(
'RuntimeException',
'CI Error: Unable to locate the model you have specified: ci_test_nonexistent_model.php'
- );
-
+ );
+
$this->load->model('ci_test_nonexistent_model.php');
}
// --------------------------------------------------------------------
-
+
/**
* @coverts CI_Loader::model
*/
public function test_models()
{
$this->ci_set_core_class('model', 'CI_Model');
-
+
$content = '<?php class Unit_test_model extends CI_Model {} ';
-
- $model = vfsStream::newFile('unit_test_model.php')->withContent($content)
- ->at($this->load->models_dir);
-
+
+ $model = vfsStream::newFile('unit_test_model.php')->withContent($content)->at($this->load->models_dir);
+
$this->assertNull($this->load->model('unit_test_model'));
-
+
// Was the model class instantiated.
$this->assertTrue(class_exists('Unit_test_model'));
-
+
// Test no model given
- $this->assertNull($this->load->model(''));
+ $this->assertNull($this->load->model(''));
}
// --------------------------------------------------------------------
-
+
// public function testDatabase()
// {
// $this->assertEquals(NULL, $this->load->database());
- // $this->assertEquals(NULL, $this->load->dbutil());
+ // $this->assertEquals(NULL, $this->load->dbutil());
// }
// --------------------------------------------------------------------
-
+
/**
* @coverts CI_Loader::view
*/
public function test_load_view()
{
$this->ci_set_core_class('output', 'CI_Output');
-
+
$content = 'This is my test page. <?php echo $hello; ?>';
- $view = vfsStream::newFile('unit_test_view.php')->withContent($content)
- ->at($this->load->views_dir);
-
+ $view = vfsStream::newFile('unit_test_view.php')->withContent($content)->at($this->load->views_dir);
+
// Use the optional return parameter in this test, so the view is not
// run through the output class.
$this->assertEquals('This is my test page. World!',
$this->load->view('unit_test_view', array('hello' => "World!"), TRUE));
-
+
}
// --------------------------------------------------------------------
-
+
/**
* @coverts CI_Loader::view
*/
@@ -139,8 +135,8 @@ class Loader_test extends CI_TestCase {
$this->setExpectedException(
'RuntimeException',
'CI Error: Unable to load the requested file: ci_test_nonexistent_view.php'
- );
-
+ );
+
$this->load->view('ci_test_nonexistent_view', array('foo' => 'bar'));
}
@@ -149,87 +145,77 @@ class Loader_test extends CI_TestCase {
public function test_file()
{
$content = 'Here is a test file, which we will load now.';
- $file = vfsStream::newFile('ci_test_mock_file.php')->withContent($content)
- ->at($this->load->views_dir);
-
+ $file = vfsStream::newFile('ci_test_mock_file.php')->withContent($content)->at($this->load->views_dir);
+
// Just like load->view(), take the output class out of the mix here.
- $load = $this->load->file(vfsStream::url('application').'/views/ci_test_mock_file.php',
- TRUE);
-
+ $load = $this->load->file(vfsStream::url('application').'/views/ci_test_mock_file.php', TRUE);
+
$this->assertEquals($content, $load);
-
+
$this->setExpectedException(
'RuntimeException',
'CI Error: Unable to load the requested file: ci_test_file_not_exists'
- );
-
+ );
+
$this->load->file('ci_test_file_not_exists', TRUE);
-
}
// --------------------------------------------------------------------
-
+
public function test_vars()
{
- $vars = array(
- 'foo' => 'bar'
- );
-
- $this->assertNull($this->load->vars($vars));
+ $this->assertNull($this->load->vars(array('foo' => 'bar')));
$this->assertNull($this->load->vars('foo', 'bar'));
}
// --------------------------------------------------------------------
-
+
public function test_helper()
{
$this->assertEquals(NULL, $this->load->helper('array'));
-
+
$this->setExpectedException(
'RuntimeException',
'CI Error: Unable to load the requested file: helpers/bad_helper.php'
- );
-
+ );
+
$this->load->helper('bad');
}
-
+
// --------------------------------------------------------------------
public function test_loading_multiple_helpers()
{
$this->assertEquals(NULL, $this->load->helpers(array('file', 'array', 'string')));
}
-
+
// --------------------------------------------------------------------
-
+
// public function testLanguage()
// {
// $this->assertEquals(NULL, $this->load->language('test'));
- // }
+ // }
// --------------------------------------------------------------------
public function test_load_config()
{
$this->_setup_config_mock();
-
$this->assertNull($this->load->config('config', FALSE));
}
-
+
// --------------------------------------------------------------------
public function test_load_bad_config()
{
$this->_setup_config_mock();
-
+
$this->setExpectedException(
'RuntimeException',
'CI Error: The configuration file foobar.php does not exist.'
- );
-
+ );
+
$this->load->config('foobar', FALSE);
}
- // --------------------------------------------------------------------
-
-}
+} \ No newline at end of file
diff --git a/tests/codeigniter/core/Security_test.php b/tests/codeigniter/core/Security_test.php
index b2f8c69d2..3f6e3b07a 100644
--- a/tests/codeigniter/core/Security_test.php
+++ b/tests/codeigniter/core/Security_test.php
@@ -1,7 +1,7 @@
<?php
class Security_test extends CI_TestCase {
-
+
public function set_up()
{
// Set cookie for security test
@@ -14,9 +14,9 @@ class Security_test extends CI_TestCase {
$this->security = new Mock_Core_Security();
}
-
+
// --------------------------------------------------------------------
-
+
public function test_csrf_verify()
{
$_SERVER['REQUEST_METHOD'] = 'GET';
@@ -25,7 +25,7 @@ class Security_test extends CI_TestCase {
}
// --------------------------------------------------------------------
-
+
public function test_csrf_verify_invalid()
{
// Without issuing $_POST[csrf_token_name], this request will triggering CSRF error
@@ -37,7 +37,7 @@ class Security_test extends CI_TestCase {
}
// --------------------------------------------------------------------
-
+
public function test_csrf_verify_valid()
{
$_SERVER['REQUEST_METHOD'] = 'POST';
@@ -47,21 +47,21 @@ class Security_test extends CI_TestCase {
}
// --------------------------------------------------------------------
-
+
public function test_get_csrf_hash()
{
$this->assertEquals($this->security->csrf_hash, $this->security->get_csrf_hash());
}
// --------------------------------------------------------------------
-
+
public function test_get_csrf_token_name()
{
$this->assertEquals('ci_csrf_token', $this->security->get_csrf_token_name());
}
// --------------------------------------------------------------------
-
+
public function test_xss_clean()
{
$harm_string = "Hello, i try to <script>alert('Hack');</script> your site";
@@ -72,7 +72,7 @@ class Security_test extends CI_TestCase {
}
// --------------------------------------------------------------------
-
+
public function test_xss_hash()
{
$this->assertEmpty($this->security->xss_hash);
@@ -84,7 +84,7 @@ class Security_test extends CI_TestCase {
}
// --------------------------------------------------------------------
-
+
public function test_entity_decode()
{
$encoded = '&lt;div&gt;Hello &lt;b&gt;Booya&lt;/b&gt;&lt;/div&gt;';
@@ -94,7 +94,7 @@ class Security_test extends CI_TestCase {
}
// --------------------------------------------------------------------
-
+
public function test_sanitize_filename()
{
$filename = './<!--foo-->';
@@ -102,4 +102,5 @@ class Security_test extends CI_TestCase {
$this->assertEquals('foo', $safe_filename);
}
+
} \ No newline at end of file
diff --git a/tests/codeigniter/core/URI_test.php b/tests/codeigniter/core/URI_test.php
index e340ddf73..0ba694b46 100644
--- a/tests/codeigniter/core/URI_test.php
+++ b/tests/codeigniter/core/URI_test.php
@@ -1,7 +1,7 @@
<?php
class URI_test extends CI_TestCase {
-
+
public function set_up()
{
$this->uri = new Mock_Core_URI();
@@ -13,19 +13,12 @@ class URI_test extends CI_TestCase {
{
// Slashes get killed
$this->uri->_set_uri_string('/');
-
- $a = '';
- $b =& $this->uri->uri_string;
-
- $this->assertEquals($a, $b);
-
+ $this->assertEquals('', $this->uri->uri_string);
+
$this->uri->_set_uri_string('nice/uri');
-
- $a = 'nice/uri';
-
- $this->assertEquals($a, $b);
+ $this->assertEquals('nice/uri', $this->uri->uri_string);
}
-
+
// --------------------------------------------------------------------
public function test_fetch_uri_string()
@@ -34,75 +27,61 @@ class URI_test extends CI_TestCase {
// uri_protocol: AUTO
$this->uri->config->set_item('uri_protocol', 'AUTO');
-
+
// Test a variety of request uris
$requests = array(
'/index.php/controller/method' => 'controller/method',
'/index.php?/controller/method' => 'controller/method',
'/index.php?/controller/method/?var=foo' => 'controller/method'
);
-
+
foreach($requests as $request => $expected)
{
$_SERVER['SCRIPT_NAME'] = '/index.php';
$_SERVER['REQUEST_URI'] = $request;
-
+
$this->uri->_fetch_uri_string();
$this->assertEquals($expected, $this->uri->uri_string );
}
-
+
// Test a subfolder
$_SERVER['SCRIPT_NAME'] = '/subfolder/index.php';
$_SERVER['REQUEST_URI'] = '/subfolder/index.php/controller/method';
-
+
$this->uri->_fetch_uri_string();
-
- $a = 'controller/method';
- $b = $this->uri->uri_string;
-
- $this->assertEquals($a, $b);
-
+ $this->assertEquals('controller/method', $this->uri->uri_string);
+
// death to request uri
unset($_SERVER['REQUEST_URI']);
-
+
// life to path info
- $_SERVER['PATH_INFO'] = '/controller/method/';
-
+ $_SERVER['PATH_INFO'] = $a = '/controller/method/';
+
$this->uri->_fetch_uri_string();
-
- $a = '/controller/method/';
- $b =& $this->uri->uri_string;
+ $this->assertEquals($a, $this->uri->uri_string);
- $this->assertEquals($a, $b);
-
// death to path info
// At this point your server must be seriously drunk
unset($_SERVER['PATH_INFO']);
-
+
$_SERVER['QUERY_STRING'] = '/controller/method/';
-
+
$this->uri->_fetch_uri_string();
+ $this->assertEquals($a, $this->uri->uri_string);
- $a = '/controller/method/';
- $b = $this->uri->uri_string;
-
- $this->assertEquals($a, $b);
-
// At this point your server is a labotomy victim
-
unset($_SERVER['QUERY_STRING']);
-
+
$_GET['/controller/method/'] = '';
-
+
$this->uri->_fetch_uri_string();
- $this->assertEquals($a, $b);
+ $this->assertEquals($a, $this->uri->uri_string);
// Test coverage implies that these will work
// uri_protocol: REQUEST_URI
// uri_protocol: CLI
-
}
-
+
// --------------------------------------------------------------------
public function test_explode_segments()
@@ -113,18 +92,15 @@ class URI_test extends CI_TestCase {
'/test2/uri2' => array('test2', 'uri2'),
'//test3/test3///' => array('test3', 'test3')
);
-
- foreach($uris as $uri => $a)
+
+ foreach ($uris as $uri => $a)
{
$this->uri->segments = array();
$this->uri->uri_string = $uri;
$this->uri->_explode_segments();
-
- $b = $this->uri->segments;
-
- $this->assertEquals($a, $b);
+
+ $this->assertEquals($a, $this->uri->segments);
}
-
}
// --------------------------------------------------------------------
@@ -133,7 +109,7 @@ class URI_test extends CI_TestCase {
{
$this->uri->config->set_item('enable_query_strings', FALSE);
$this->uri->config->set_item('permitted_uri_chars', 'a-z 0-9~%.:_\-');
-
+
$str_in = 'abc01239~%.:_-';
$str = $this->uri->_filter_uri($str_in);
@@ -145,52 +121,52 @@ class URI_test extends CI_TestCase {
public function test_filter_uri_escaping()
{
// ensure escaping even if dodgey characters are permitted
-
+
$this->uri->config->set_item('enable_query_strings', FALSE);
$this->uri->config->set_item('permitted_uri_chars', 'a-z 0-9~%.:_\-()$');
$str = $this->uri->_filter_uri('$destroy_app(foo)');
-
+
$this->assertEquals($str, '&#36;destroy_app&#40;foo&#41;');
}
// --------------------------------------------------------------------
- public function test_filter_uri_throws_error()
- {
+ public function test_filter_uri_throws_error()
+ {
$this->setExpectedException('RuntimeException');
-
+
$this->uri->config->set_item('enable_query_strings', FALSE);
$this->uri->config->set_item('permitted_uri_chars', 'a-z 0-9~%.:_\-');
$this->uri->_filter_uri('$this()');
- }
+ }
// --------------------------------------------------------------------
public function test_remove_url_suffix()
{
$this->uri->config->set_item('url_suffix', '.html');
-
+
$this->uri->uri_string = 'controller/method/index.html';
$this->uri->_remove_url_suffix();
-
+
$this->assertEquals($this->uri->uri_string, 'controller/method/index');
-
+
$this->uri->uri_string = 'controller/method/index.htmlify.html';
$this->uri->_remove_url_suffix();
-
+
$this->assertEquals($this->uri->uri_string, 'controller/method/index.htmlify');
}
// --------------------------------------------------------------------
-
+
public function test_segment()
{
$this->uri->segments = array(1 => 'controller');
$this->assertEquals($this->uri->segment(1), 'controller');
$this->assertEquals($this->uri->segment(2, 'default'), 'default');
}
-
+
// --------------------------------------------------------------------
public function test_rsegment()
@@ -205,32 +181,33 @@ class URI_test extends CI_TestCase {
public function test_uri_to_assoc()
{
$this->uri->segments = array('a', '1', 'b', '2', 'c', '3');
-
- $a = array('a' => '1', 'b' => '2', 'c' => '3');
- $b = $this->uri->uri_to_assoc(1);
- $this->assertEquals($a, $b);
-
- $a = array('b' => '2', 'c' => '3');
- $b = $this->uri->uri_to_assoc(3);
- $this->assertEquals($a, $b);
-
-
+
+ $this->assertEquals(
+ array('a' => '1', 'b' => '2', 'c' => '3'),
+ $this->uri->uri_to_assoc(1)
+ );
+
+ $this->assertEquals(
+ array('b' => '2', 'c' => '3'),
+ $this->uri->uri_to_assoc(3)
+ );
+
$this->uri->keyval = array(); // reset cache
-
$this->uri->segments = array('a', '1', 'b', '2', 'c');
-
- $a = array('a' => '1', 'b' => '2', 'c' => FALSE);
- $b = $this->uri->uri_to_assoc(1);
- $this->assertEquals($a, $b);
-
+
+ $this->assertEquals(
+ array('a' => '1', 'b' => '2', 'c' => FALSE),
+ $this->uri->uri_to_assoc(1)
+ );
+
$this->uri->keyval = array(); // reset cache
-
$this->uri->segments = array('a', '1');
-
+
// test default
- $a = array('a' => '1', 'b' => FALSE);
- $b = $this->uri->uri_to_assoc(1, array('a', 'b'));
- $this->assertEquals($a, $b);
+ $this->assertEquals(
+ array('a' => '1', 'b' => FALSE),
+ $this->uri->uri_to_assoc(1, array('a', 'b'))
+ );
}
// --------------------------------------------------------------------
@@ -238,33 +215,33 @@ class URI_test extends CI_TestCase {
public function test_ruri_to_assoc()
{
$this->uri->rsegments = array('x', '1', 'y', '2', 'z', '3');
-
- $a = array('x' => '1', 'y' => '2', 'z' => '3');
- $b = $this->uri->ruri_to_assoc(1);
- $this->assertEquals($a, $b);
-
- $a = array('y' => '2', 'z' => '3');
- $b = $this->uri->ruri_to_assoc(3);
- $this->assertEquals($a, $b);
-
-
+
+ $this->assertEquals(
+ array('x' => '1', 'y' => '2', 'z' => '3'),
+ $this->uri->ruri_to_assoc(1)
+ );
+
+ $this->assertEquals(
+ array('y' => '2', 'z' => '3'),
+ $this->uri->ruri_to_assoc(3)
+ );
+
$this->uri->keyval = array(); // reset cache
-
$this->uri->rsegments = array('x', '1', 'y', '2', 'z');
-
- $a = array('x' => '1', 'y' => '2', 'z' => FALSE);
- $b = $this->uri->ruri_to_assoc(1);
- $this->assertEquals($a, $b);
-
+
+ $this->assertEquals(
+ array('x' => '1', 'y' => '2', 'z' => FALSE),
+ $this->uri->ruri_to_assoc(1)
+ );
+
$this->uri->keyval = array(); // reset cache
-
$this->uri->rsegments = array('x', '1');
-
- // test default
- $a = array('x' => '1', 'y' => FALSE);
- $b = $this->uri->ruri_to_assoc(1, array('x', 'y'));
- $this->assertEquals($a, $b);
+ // test default
+ $this->assertEquals(
+ array('x' => '1', 'y' => FALSE),
+ $this->uri->ruri_to_assoc(1, array('x', 'y'))
+ );
}
// --------------------------------------------------------------------
@@ -272,11 +249,7 @@ class URI_test extends CI_TestCase {
public function test_assoc_to_uri()
{
$this->uri->config->set_item('uri_string_slashes', 'none');
-
- $arr = array('a' => 1, 'b' => 2);
- $a = 'a/1/b/2';
- $b = $this->uri->assoc_to_uri($arr);
- $this->assertEquals($a, $b);
+ $this->assertEquals('a/1/b/2', $this->uri->assoc_to_uri(array('a' => '1', 'b' => '2')));
}
// --------------------------------------------------------------------
@@ -286,28 +259,18 @@ class URI_test extends CI_TestCase {
$this->uri->segments[1] = 'segment';
$this->uri->rsegments[1] = 'segment';
- $a = '/segment/';
- $b = $this->uri->slash_segment(1, 'both');
- $this->assertEquals($a, $b);
- $b = $this->uri->slash_rsegment(1, 'both');
- $this->assertEquals($a, $b);
-
+ $this->assertEquals('/segment/', $this->uri->slash_segment(1, 'both'));
+ $this->assertEquals('/segment/', $this->uri->slash_rsegment(1, 'both'));
+
$a = '/segment';
- $b = $this->uri->slash_segment(1, 'leading');
- $this->assertEquals($a, $b);
- $b = $this->uri->slash_rsegment(1, 'leading');
- $this->assertEquals($a, $b);
-
- $a = 'segment/';
- $b = $this->uri->slash_segment(1, 'trailing');
- $this->assertEquals($a, $b);
- $b = $this->uri->slash_rsegment(1, 'trailing');
- $this->assertEquals($a, $b);
- }
+ $this->assertEquals('/segment', $this->uri->slash_segment(1, 'leading'));
+ $this->assertEquals('/segment', $this->uri->slash_rsegment(1, 'leading'));
+ $this->assertEquals('segment/', $this->uri->slash_segment(1, 'trailing'));
+ $this->assertEquals('segment/', $this->uri->slash_rsegment(1, 'trailing'));
+ }
}
-// END URI_test Class
/* End of file URI_test.php */
-/* Location: ./tests/core/URI_test.php */
+/* Location: ./tests/core/URI_test.php */ \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/count_test.php b/tests/codeigniter/database/query_builder/count_test.php
index 5e691692d..90ac5283e 100644
--- a/tests/codeigniter/database/query_builder/count_test.php
+++ b/tests/codeigniter/database/query_builder/count_test.php
@@ -22,10 +22,7 @@ class Count_test extends CI_TestCase {
*/
public function test_count_all()
{
- $job_count = $this->db->count_all('job');
-
- // Check the result
- $this->assertEquals(4, $job_count);
+ $this->assertEquals(4, $this->db->count_all('job'));
}
// ------------------------------------------------------------------------
@@ -35,10 +32,7 @@ class Count_test extends CI_TestCase {
*/
public function test_count_all_results()
{
- $job_count = $this->db->like('name', 'ian')
- ->count_all_results('job');
-
- // Check the result
- $this->assertEquals(2, $job_count);
+ $this->assertEquals(2, $this->db->like('name', 'ian')->count_all_results('job'));
}
+
} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/delete_test.php b/tests/codeigniter/database/query_builder/delete_test.php
index 84ea7616f..ab9d97f56 100644
--- a/tests/codeigniter/database/query_builder/delete_test.php
+++ b/tests/codeigniter/database/query_builder/delete_test.php
@@ -23,9 +23,7 @@ class Delete_test extends CI_TestCase {
public function test_delete()
{
// Check initial record
- $job1 = $this->db->where('id', 1)
- ->get('job')
- ->row();
+ $job1 = $this->db->where('id', 1)->get('job')->row();
$this->assertEquals('Developer', $job1->name);
@@ -33,8 +31,7 @@ class Delete_test extends CI_TestCase {
$this->db->delete('job', array('id' => 1));
// Check the record
- $job1 = $this->db->where('id', 1)
- ->get('job');
+ $job1 = $this->db->where('id', 1)->get('job');
$this->assertEmpty($job1->result_array());
}
@@ -47,13 +44,8 @@ class Delete_test extends CI_TestCase {
public function test_delete_several_tables()
{
// Check initial record
- $user4 = $this->db->where('id', 4)
- ->get('user')
- ->row();
-
- $job4 = $this->db->where('id', 4)
- ->get('job')
- ->row();
+ $user4 = $this->db->where('id', 4)->get('user')->row();
+ $job4 = $this->db->where('id', 4)->get('job')->row();
$this->assertEquals('Musician', $job4->name);
$this->assertEquals('Chris Martin', $user4->name);
diff --git a/tests/codeigniter/database/query_builder/distinct_test.php b/tests/codeigniter/database/query_builder/distinct_test.php
index 925eadb19..cc98009ce 100644
--- a/tests/codeigniter/database/query_builder/distinct_test.php
+++ b/tests/codeigniter/database/query_builder/distinct_test.php
@@ -23,11 +23,10 @@ class Distinct_test extends CI_TestCase {
public function test_distinct()
{
$users = $this->db->select('country')
- ->distinct()
- ->get('user')
- ->result_array();
-
- // Check the result
+ ->distinct()
+ ->get('user')
+ ->result_array();
+
$this->assertEquals(3, count($users));
}
diff --git a/tests/codeigniter/database/query_builder/escape_test.php b/tests/codeigniter/database/query_builder/escape_test.php
index 5d575a37b..c6380ddf1 100644
--- a/tests/codeigniter/database/query_builder/escape_test.php
+++ b/tests/codeigniter/database/query_builder/escape_test.php
@@ -35,7 +35,7 @@ class Escape_test extends CI_TestCase {
}
$res = $this->db->query($sql)->result_array();
-
+
// Check the result
$this->assertEquals(1, count($res));
}
@@ -60,8 +60,9 @@ class Escape_test extends CI_TestCase {
}
$res = $this->db->query($sql)->result_array();
-
+
// Check the result
$this->assertEquals(2, count($res));
}
+
} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/from_test.php b/tests/codeigniter/database/query_builder/from_test.php
index 95ae4dfdb..7aaae348d 100644
--- a/tests/codeigniter/database/query_builder/from_test.php
+++ b/tests/codeigniter/database/query_builder/from_test.php
@@ -23,10 +23,9 @@ class From_test extends CI_TestCase {
public function test_from_simple()
{
$jobs = $this->db->from('job')
- ->get()
- ->result_array();
-
- // Check items
+ ->get()
+ ->result_array();
+
$this->assertEquals(4, count($jobs));
}
@@ -38,14 +37,13 @@ class From_test extends CI_TestCase {
public function test_from_with_where()
{
$job1 = $this->db->from('job')
- ->where('id', 1)
- ->get()
- ->row();
-
- // Check the result
+ ->where('id', 1)
+ ->get()
+ ->row();
+
$this->assertEquals('1', $job1->id);
$this->assertEquals('Developer', $job1->name);
$this->assertEquals('Awesome job, but sometimes makes you bored', $job1->description);
}
-
+
} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/get_test.php b/tests/codeigniter/database/query_builder/get_test.php
index 0751c9332..699d2906a 100644
--- a/tests/codeigniter/database/query_builder/get_test.php
+++ b/tests/codeigniter/database/query_builder/get_test.php
@@ -23,7 +23,7 @@ class Get_test extends CI_TestCase {
public function test_get_simple()
{
$jobs = $this->db->get('job')->result_array();
-
+
// Dummy jobs contain 4 rows
$this->assertCount(4, $jobs);
@@ -42,12 +42,12 @@ class Get_test extends CI_TestCase {
public function test_get_where()
{
$job1 = $this->db->get('job', array('id' => 1))->result_array();
-
+
// Dummy jobs contain 1 rows
$this->assertCount(1, $job1);
// Check rows item
$this->assertEquals('Developer', $job1[0]['name']);
}
-
+
} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/group_test.php b/tests/codeigniter/database/query_builder/group_test.php
index 7d8abc33f..5249f7c87 100644
--- a/tests/codeigniter/database/query_builder/group_test.php
+++ b/tests/codeigniter/database/query_builder/group_test.php
@@ -23,12 +23,11 @@ class Group_test extends CI_TestCase {
public function test_group_by()
{
$jobs = $this->db->select('name')
- ->from('job')
- ->group_by('name')
- ->get()
- ->result_array();
-
- // Check the result
+ ->from('job')
+ ->group_by('name')
+ ->get()
+ ->result_array();
+
$this->assertEquals(4, count($jobs));
}
@@ -40,14 +39,13 @@ class Group_test extends CI_TestCase {
public function test_having_by()
{
$jobs = $this->db->select('name')
- ->from('job')
- ->group_by('name')
- ->having('SUM(id) > 2')
- ->get()
- ->result_array();
-
- // Check the result
+ ->from('job')
+ ->group_by('name')
+ ->having('SUM(id) > 2')
+ ->get()
+ ->result_array();
+
$this->assertEquals(2, count($jobs));
}
-
+
} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/join_test.php b/tests/codeigniter/database/query_builder/join_test.php
index e05329d67..b8cf2a822 100644
--- a/tests/codeigniter/database/query_builder/join_test.php
+++ b/tests/codeigniter/database/query_builder/join_test.php
@@ -34,5 +34,5 @@ class Join_test extends CI_TestCase {
$this->assertEquals('Derek Jones', $job_user[0]['user_name']);
$this->assertEquals('Developer', $job_user[0]['job_name']);
}
-
+
} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/like_test.php b/tests/codeigniter/database/query_builder/like_test.php
index df98c713f..5f3e52228 100644
--- a/tests/codeigniter/database/query_builder/like_test.php
+++ b/tests/codeigniter/database/query_builder/like_test.php
@@ -86,5 +86,5 @@ class Like_test extends CI_TestCase {
$this->assertEquals('Accountant', $jobs[1]['name']);
$this->assertEquals('Musician', $jobs[2]['name']);
}
-
+
} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/limit_test.php b/tests/codeigniter/database/query_builder/limit_test.php
index 704f3b651..a0954c7ab 100644
--- a/tests/codeigniter/database/query_builder/limit_test.php
+++ b/tests/codeigniter/database/query_builder/limit_test.php
@@ -25,8 +25,7 @@ class Limit_test extends CI_TestCase {
$jobs = $this->db->limit(2)
->get('job')
->result_array();
-
- // Check the result
+
$this->assertEquals(2, count($jobs));
}
@@ -40,10 +39,10 @@ class Limit_test extends CI_TestCase {
$jobs = $this->db->limit(2, 2)
->get('job')
->result_array();
-
- // Check the result
+
$this->assertEquals(2, count($jobs));
$this->assertEquals('Accountant', $jobs[0]['name']);
$this->assertEquals('Musician', $jobs[1]['name']);
}
+
} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/order_test.php b/tests/codeigniter/database/query_builder/order_test.php
index 01aa1c2b4..46f452bae 100644
--- a/tests/codeigniter/database/query_builder/order_test.php
+++ b/tests/codeigniter/database/query_builder/order_test.php
@@ -25,7 +25,7 @@ class Order_test extends CI_TestCase {
$jobs = $this->db->order_by('name', 'asc')
->get('job')
->result_array();
-
+
// Check the result
$this->assertEquals(4, count($jobs));
$this->assertEquals('Accountant', $jobs[0]['name']);
@@ -44,12 +44,12 @@ class Order_test extends CI_TestCase {
$jobs = $this->db->order_by('name', 'desc')
->get('job')
->result_array();
-
- // Check the result
+
$this->assertEquals(4, count($jobs));
$this->assertEquals('Politician', $jobs[0]['name']);
$this->assertEquals('Musician', $jobs[1]['name']);
$this->assertEquals('Developer', $jobs[2]['name']);
$this->assertEquals('Accountant', $jobs[3]['name']);
}
+
} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/select_test.php b/tests/codeigniter/database/query_builder/select_test.php
index 0d299ed16..877b5d8c0 100644
--- a/tests/codeigniter/database/query_builder/select_test.php
+++ b/tests/codeigniter/database/query_builder/select_test.php
@@ -25,7 +25,7 @@ class Select_test extends CI_TestCase {
$jobs_name = $this->db->select('name')
->get('job')
->result_array();
-
+
// Check rows item
$this->assertArrayHasKey('name',$jobs_name[0]);
$this->assertFalse(array_key_exists('id', $jobs_name[0]));
@@ -42,7 +42,7 @@ class Select_test extends CI_TestCase {
$job_min = $this->db->select_min('id')
->get('job')
->row();
-
+
// Minimum id was 1
$this->assertEquals('1', $job_min->id);
}
@@ -57,7 +57,7 @@ class Select_test extends CI_TestCase {
$job_max = $this->db->select_max('id')
->get('job')
->row();
-
+
// Maximum id was 4
$this->assertEquals('4', $job_max->id);
}
@@ -72,7 +72,7 @@ class Select_test extends CI_TestCase {
$job_avg = $this->db->select_avg('id')
->get('job')
->row();
-
+
// Average should be 2.5
$this->assertEquals('2.5', $job_avg->id);
}
@@ -87,9 +87,9 @@ class Select_test extends CI_TestCase {
$job_sum = $this->db->select_sum('id')
->get('job')
->row();
-
+
// Sum of ids should be 10
$this->assertEquals('10', $job_sum->id);
}
-
+
} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/truncate_test.php b/tests/codeigniter/database/query_builder/truncate_test.php
index 2a9c8a91e..09923c7f1 100644
--- a/tests/codeigniter/database/query_builder/truncate_test.php
+++ b/tests/codeigniter/database/query_builder/truncate_test.php
@@ -24,7 +24,6 @@ class Truncate_test extends CI_TestCase {
{
// Check initial record
$jobs = $this->db->get('job')->result_array();
-
$this->assertEquals(4, count($jobs));
// Do the empty
@@ -32,7 +31,6 @@ class Truncate_test extends CI_TestCase {
// Check the record
$jobs = $this->db->get('job');
-
$this->assertEmpty($jobs->result_array());
}
@@ -45,16 +43,13 @@ class Truncate_test extends CI_TestCase {
{
// Check initial record
$users = $this->db->get('user')->result_array();
-
$this->assertEquals(4, count($users));
// Do the empty
- $this->db->from('user')
- ->truncate();
+ $this->db->from('user')->truncate();
// Check the record
$users = $this->db->get('user');
-
$this->assertEmpty($users->result_array());
}
diff --git a/tests/codeigniter/database/query_builder/update_test.php b/tests/codeigniter/database/query_builder/update_test.php
index f5bbffd4f..27a647c45 100644
--- a/tests/codeigniter/database/query_builder/update_test.php
+++ b/tests/codeigniter/database/query_builder/update_test.php
@@ -23,23 +23,14 @@ class Update_test extends CI_TestCase {
public function test_update()
{
// Check initial record
- $job1 = $this->db->where('id', 1)
- ->get('job')
- ->row();
-
+ $job1 = $this->db->where('id', 1)->get('job')->row();
$this->assertEquals('Developer', $job1->name);
// Do the update
- $job_data = array('name' => 'Programmer');
-
- $this->db->where('id', 1)
- ->update('job', $job_data);
+ $this->db->where('id', 1)->update('job', array('name' => 'Programmer'));
// Check updated record
- $job1 = $this->db->where('id', 1)
- ->get('job')
- ->row();
-
+ $job1 = $this->db->where('id', 1)->get('job')->row();
$this->assertEquals('Programmer', $job1->name);
}
@@ -51,10 +42,7 @@ class Update_test extends CI_TestCase {
public function test_update_with_set()
{
// Check initial record
- $job1 = $this->db->where('id', 4)
- ->get('job')
- ->row();
-
+ $job1 = $this->db->where('id', 4)->get('job')->row();
$this->assertEquals('Musician', $job1->name);
// Do the update
@@ -62,10 +50,8 @@ class Update_test extends CI_TestCase {
$this->db->update('job', NULL, 'id = 4');
// Check updated record
- $job1 = $this->db->where('id', 4)
- ->get('job')
- ->row();
-
+ $job1 = $this->db->where('id', 4)->get('job')->row();
$this->assertEquals('Vocalist', $job1->name);
}
+
} \ No newline at end of file
diff --git a/tests/codeigniter/database/query_builder/where_test.php b/tests/codeigniter/database/query_builder/where_test.php
index 607eaa076..20b7a567c 100644
--- a/tests/codeigniter/database/query_builder/where_test.php
+++ b/tests/codeigniter/database/query_builder/where_test.php
@@ -22,11 +22,8 @@ class Where_test extends CI_TestCase {
*/
public function test_where_simple_key_value()
{
- $job1 = $this->db->where('id', 1)
- ->get('job')
- ->row();
+ $job1 = $this->db->where('id', 1)->get('job')->row();
- // Check the result
$this->assertEquals('1', $job1->id);
$this->assertEquals('Developer', $job1->name);
}
@@ -38,11 +35,7 @@ class Where_test extends CI_TestCase {
*/
public function test_where_custom_key_value()
{
- $jobs = $this->db->where('id !=', 1)
- ->get('job')
- ->result_array();
-
- // Check the result
+ $jobs = $this->db->where('id !=', 1)->get('job')->result_array();
$this->assertEquals(3, count($jobs));
}
@@ -54,16 +47,12 @@ class Where_test extends CI_TestCase {
public function test_where_associative_array()
{
$where = array('id >' => 2, 'name !=' => 'Accountant');
- $jobs = $this->db->where($where)
- ->get('job')
- ->result_array();
+ $jobs = $this->db->where($where)->get('job')->result_array();
- // Check the result
$this->assertEquals(1, count($jobs));
// Should be Musician
$job = current($jobs);
-
$this->assertEquals('Musician', $job['name']);
}
@@ -75,16 +64,12 @@ class Where_test extends CI_TestCase {
public function test_where_custom_string()
{
$where = "id > 2 AND name != 'Accountant'";
- $jobs = $this->db->where($where)
- ->get('job')
- ->result_array();
+ $jobs = $this->db->where($where)->get('job')->result_array();
- // Check the result
$this->assertEquals(1, count($jobs));
// Should be Musician
$job = current($jobs);
-
$this->assertEquals('Musician', $job['name']);
}
@@ -100,7 +85,6 @@ class Where_test extends CI_TestCase {
->get('job')
->result_array();
- // Check the result
$this->assertEquals(3, count($jobs));
$this->assertEquals('Developer', $jobs[0]['name']);
$this->assertEquals('Politician', $jobs[1]['name']);
@@ -118,7 +102,6 @@ class Where_test extends CI_TestCase {
->get('job')
->result_array();
- // Check the result
$this->assertEquals(2, count($jobs));
$this->assertEquals('Politician', $jobs[0]['name']);
$this->assertEquals('Accountant', $jobs[1]['name']);
@@ -135,10 +118,9 @@ class Where_test extends CI_TestCase {
->get('job')
->result_array();
- // Check the result
$this->assertEquals(2, count($jobs));
$this->assertEquals('Developer', $jobs[0]['name']);
$this->assertEquals('Musician', $jobs[1]['name']);
}
-
+
} \ No newline at end of file
diff --git a/tests/codeigniter/helpers/number_helper_test.php b/tests/codeigniter/helpers/number_helper_test.php
index 23d5c5c1a..ef6aae138 100644
--- a/tests/codeigniter/helpers/number_helper_test.php
+++ b/tests/codeigniter/helpers/number_helper_test.php
@@ -25,7 +25,7 @@ class Number_helper_test extends CI_TestCase {
// a cheap class to act as our super object.
// Make sure it has a lang attribute.
- $obj = new StdClass;
+ $obj = new stdClass;
$obj->lang = $lang;
$this->ci_instance($obj);
}
diff --git a/tests/codeigniter/libraries/Encrypt_test.php b/tests/codeigniter/libraries/Encrypt_test.php
index 066990186..153a25e1d 100644
--- a/tests/codeigniter/libraries/Encrypt_test.php
+++ b/tests/codeigniter/libraries/Encrypt_test.php
@@ -2,70 +2,71 @@
class Encrypt_test extends CI_TestCase {
- public function set_up()
- {
- $obj = new StdClass;
- $obj->encrypt = new Mock_Libraries_Encrypt();
-
- $this->ci_instance($obj);
- $this->encrypt = $obj->encrypt;
-
- $this->ci_set_config('encryption_key', "Encryptin'glike@boss!");
- $this->msg = 'My secret message';
- }
-
- // --------------------------------------------------------------------
-
- public function test_encode()
- {
- $this->assertNotEquals($this->msg, $this->encrypt->encode($this->msg));
- }
-
- // --------------------------------------------------------------------
-
- public function test_decode()
- {
- $encoded_msg = $this->encrypt->encode($this->msg);
- $this->assertEquals($this->msg, $this->encrypt->decode($encoded_msg));
- }
-
- // --------------------------------------------------------------------
-
- public function test_optional_key()
- {
- $key = 'Ohai!ù0129°03182%HD1892P0';
- $encoded_msg = $this->encrypt->encode($this->msg, $key);
- $this->assertEquals($this->msg, $this->encrypt->decode($encoded_msg, $key));
- }
-
- // --------------------------------------------------------------------
-
- public function test_default_cipher()
- {
- $this->assertEquals('rijndael-256', $this->encrypt->get_cipher());
- }
-
- // --------------------------------------------------------------------
-
- public function test_set_cipher()
- {
- $this->encrypt->set_cipher(MCRYPT_BLOWFISH);
- $this->assertEquals('blowfish', $this->encrypt->get_cipher());
- }
-
- // --------------------------------------------------------------------
-
- public function test_default_mode()
- {
- $this->assertEquals('cbc', $this->encrypt->get_mode());
- }
-
- // --------------------------------------------------------------------
-
- public function test_set_mode()
- {
- $this->encrypt->set_mode(MCRYPT_MODE_CFB);
- $this->assertEquals('cfb', $this->encrypt->get_mode());
- }
+ public function set_up()
+ {
+ $obj = new stdClass;
+ $obj->encrypt = new Mock_Libraries_Encrypt();
+
+ $this->ci_instance($obj);
+ $this->encrypt = $obj->encrypt;
+
+ $this->ci_set_config('encryption_key', "Encryptin'glike@boss!");
+ $this->msg = 'My secret message';
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_encode()
+ {
+ $this->assertNotEquals($this->msg, $this->encrypt->encode($this->msg));
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_decode()
+ {
+ $encoded_msg = $this->encrypt->encode($this->msg);
+ $this->assertEquals($this->msg, $this->encrypt->decode($encoded_msg));
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_optional_key()
+ {
+ $key = 'Ohai!ù0129°03182%HD1892P0';
+ $encoded_msg = $this->encrypt->encode($this->msg, $key);
+ $this->assertEquals($this->msg, $this->encrypt->decode($encoded_msg, $key));
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_default_cipher()
+ {
+ $this->assertEquals('rijndael-256', $this->encrypt->get_cipher());
+ }
+
+ // --------------------------------------------------------------------
+
+
+ public function test_set_cipher()
+ {
+ $this->encrypt->set_cipher(MCRYPT_BLOWFISH);
+ $this->assertEquals('blowfish', $this->encrypt->get_cipher());
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_default_mode()
+ {
+ $this->assertEquals('cbc', $this->encrypt->get_mode());
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_set_mode()
+ {
+ $this->encrypt->set_mode(MCRYPT_MODE_CFB);
+ $this->assertEquals('cfb', $this->encrypt->get_mode());
+ }
} \ No newline at end of file
diff --git a/tests/codeigniter/libraries/Parser_test.php b/tests/codeigniter/libraries/Parser_test.php
index c3d88fa85..b68f44a33 100644
--- a/tests/codeigniter/libraries/Parser_test.php
+++ b/tests/codeigniter/libraries/Parser_test.php
@@ -1,73 +1,74 @@
<?php
class Parser_test extends CI_TestCase {
-
+
public function set_up()
{
- $obj = new StdClass;
+ $obj = new stdClass;
$obj->parser = new Mock_Libraries_Parser();
-
+
$this->ci_instance($obj);
-
+
$this->parser = $obj->parser;
}
+
// --------------------------------------------------------------------
-
+
public function test_set_delimiters()
{
// Make sure default delimiters are there
$this->assertEquals('{', $this->parser->l_delim);
$this->assertEquals('}', $this->parser->r_delim);
-
+
// Change them to square brackets
$this->parser->set_delimiters('[', ']');
-
+
// Make sure they changed
$this->assertEquals('[', $this->parser->l_delim);
$this->assertEquals(']', $this->parser->r_delim);
-
+
// Reset them
$this->parser->set_delimiters();
-
+
// Make sure default delimiters are there
$this->assertEquals('{', $this->parser->l_delim);
$this->assertEquals('}', $this->parser->r_delim);
}
-
+
// --------------------------------------------------------------------
-
+
public function test_parse_simple_string()
{
$data = array(
'title' => 'Page Title',
'body' => 'Lorem ipsum dolor sit amet.'
);
-
+
$template = "{title}\n{body}";
-
+
$result = implode("\n", $data);
-
+
$this->assertEquals($result, $this->parser->parse_string($template, $data, TRUE));
}
-
+
// --------------------------------------------------------------------
-
+
public function test_parse()
{
$this->_parse_no_template();
$this->_parse_var_pair();
$this->_mismatched_var_pair();
}
-
+
// --------------------------------------------------------------------
-
+
private function _parse_no_template()
{
$this->assertFalse($this->parser->parse_string('', '', TRUE));
}
-
+
// --------------------------------------------------------------------
-
+
private function _parse_var_pair()
{
$data = array(
@@ -78,16 +79,14 @@ class Parser_test extends CI_TestCase {
'flying' => 'no'),
)
);
-
+
$template = "{title}\n{powers}{invisibility}\n{flying}{/powers}";
-
- $result = "Super Heroes\nyes\nno";
-
- $this->assertEquals($result, $this->parser->parse_string($template, $data, TRUE));
+
+ $this->assertEquals("Super Heroes\nyes\nno", $this->parser->parse_string($template, $data, TRUE));
}
-
+
// --------------------------------------------------------------------
-
+
private function _mismatched_var_pair()
{
$data = array(
@@ -98,13 +97,11 @@ class Parser_test extends CI_TestCase {
'flying' => 'no'),
)
);
-
+
$template = "{title}\n{powers}{invisibility}\n{flying}";
-
$result = "Super Heroes\n{powers}{invisibility}\n{flying}";
-
- $this->assertEquals($result, $this->parser->parse_string($template, $data, TRUE));
+
+ $this->assertEquals($result, $this->parser->parse_string($template, $data, TRUE));
}
- // --------------------------------------------------------------------
} \ No newline at end of file
diff --git a/tests/codeigniter/libraries/Table_test.php b/tests/codeigniter/libraries/Table_test.php
index f5133de1e..edfc83dd0 100644
--- a/tests/codeigniter/libraries/Table_test.php
+++ b/tests/codeigniter/libraries/Table_test.php
@@ -4,43 +4,39 @@ class Table_test extends CI_TestCase {
public function set_up()
{
- $obj = new StdClass;
+ $obj = new stdClass;
$obj->table = new Mock_Libraries_Table();
-
+
$this->ci_instance($obj);
-
+
$this->table = $obj->table;
}
-
// Setter Methods
// --------------------------------------------------------------------
-
+
public function test_set_template()
{
$this->assertFalse($this->table->set_template('not an array'));
-
- $template = array(
- 'a' => 'b'
- );
-
+
+ $template = array('a' => 'b');
+
$this->table->set_template($template);
$this->assertEquals($template, $this->table->template);
}
-
+
public function test_set_empty()
{
$this->table->set_empty('nada');
$this->assertEquals('nada', $this->table->empty_cells);
}
-
+
public function test_set_caption()
{
$this->table->set_caption('awesome cap');
$this->assertEquals('awesome cap', $this->table->caption);
}
-
-
+
/*
* @depends testPrepArgs
*/
@@ -49,9 +45,9 @@ class Table_test extends CI_TestCase {
// uses _prep_args internally, so we'll just do a quick
// check to verify that func_get_args and prep_args are
// being called.
-
+
$this->table->set_heading('name', 'color', 'size');
-
+
$this->assertEquals(
array(
array('data' => 'name'),
@@ -61,8 +57,7 @@ class Table_test extends CI_TestCase {
$this->table->heading
);
}
-
-
+
/*
* @depends testPrepArgs
*/
@@ -71,13 +66,13 @@ class Table_test extends CI_TestCase {
// uses _prep_args internally, so we'll just do a quick
// check to verify that func_get_args and prep_args are
// being called.
-
+
$this->table->add_row('my', 'pony', 'sings');
$this->table->add_row('your', 'pony', 'stinks');
$this->table->add_row('my pony', '>', 'your pony');
-
+
$this->assertEquals(count($this->table->rows), 3);
-
+
$this->assertEquals(
array(
array('data' => 'your'),
@@ -87,11 +82,10 @@ class Table_test extends CI_TestCase {
$this->table->rows[1]
);
}
-
-
+
// Uility Methods
// --------------------------------------------------------------------
-
+
public function test_prep_args()
{
$expected = array(
@@ -99,7 +93,7 @@ class Table_test extends CI_TestCase {
array('data' => 'color'),
array('data' => 'size')
);
-
+
$this->assertEquals(
$expected,
$this->table->prep_args(array('name', 'color', 'size'))
@@ -114,7 +108,7 @@ class Table_test extends CI_TestCase {
$this->table->prep_args(array('name', 'color', 'size', array('data' => 'weight', 'class' => 'awesome')))
);
}
-
+
public function test_default_template_keys()
{
$keys = array(
@@ -126,132 +120,124 @@ class Table_test extends CI_TestCase {
'row_alt_start', 'row_alt_end', 'cell_alt_start', 'cell_alt_end',
'table_close'
);
-
+
foreach ($keys as $key)
{
$this->assertArrayHasKey($key, $this->table->default_template());
}
}
-
+
public function test_compile_template()
{
$this->assertFalse($this->table->set_template('invalid_junk'));
-
+
// non default key
$this->table->set_template(array('nonsense' => 'foo'));
$this->table->compile_template();
-
+
$this->assertArrayHasKey('nonsense', $this->table->template);
$this->assertEquals('foo', $this->table->template['nonsense']);
-
+
// override default
$this->table->set_template(array('table_close' => '</table junk>'));
$this->table->compile_template();
-
+
$this->assertArrayHasKey('table_close', $this->table->template);
$this->assertEquals('</table junk>', $this->table->template['table_close']);
}
-
+
public function test_make_columns()
{
// Test bogus parameters
$this->assertFalse($this->table->make_columns('invalid_junk'));
$this->assertFalse($this->table->make_columns(array()));
$this->assertFalse($this->table->make_columns(array('one', 'two'), '2.5'));
-
-
+
// Now on to the actual column creation
-
+
$five_values = array(
'Laura', 'Red', '15',
'Katie', 'Blue'
);
-
+
// No column count - no changes to the array
$this->assertEquals(
$five_values,
$this->table->make_columns($five_values)
);
-
+
// Column count of 3 leaves us with one &nbsp;
$this->assertEquals(
array(
array('Laura', 'Red', '15'),
- array('Katie', 'Blue', '&nbsp;')
+ array('Katie', 'Blue', '&nbsp;')
),
$this->table->make_columns($five_values, 3)
);
}
-
+
public function test_clear()
{
$this->table->set_heading('Name', 'Color', 'Size');
-
+
// Make columns changes auto_heading
$rows = $this->table->make_columns(array(
'Laura', 'Red', '15',
'Katie', 'Blue'
), 3);
-
+
foreach ($rows as $row)
{
$this->table->add_row($row);
}
-
+
$this->assertFalse($this->table->auto_heading);
$this->assertEquals(count($this->table->heading), 3);
$this->assertEquals(count($this->table->rows), 2);
-
+
$this->table->clear();
-
+
$this->assertTrue($this->table->auto_heading);
$this->assertEmpty($this->table->heading);
$this->assertEmpty($this->table->rows);
}
-
-
+
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')
+ array('Katie', 'Blue')
);
-
+
$this->table->set_from_array($data, FALSE);
$this->assertEmpty($this->table->heading);
-
+
$this->table->clear();
-
- $expected_heading = array(
+
+ $this->table->set_from_array($data);
+ $this->assertEquals(count($this->table->rows), 2);
+
+ $expected = array(
array('data' => 'name'),
array('data' => 'color'),
array('data' => 'number')
);
-
- $expected_second = array(
+
+ $this->assertEquals($expected, $this->table->heading);
+
+ $expected = array(
array('data' => 'Katie'),
array('data' => 'Blue'),
);
-
- $this->table->set_from_array($data);
- $this->assertEquals(count($this->table->rows), 2);
-
- $this->assertEquals(
- $expected_heading,
- $this->table->heading
- );
-
- $this->assertEquals(
- $expected_second,
- $this->table->rows[1]
- );
+
+ $this->assertEquals($expected, $this->table->rows[1]);
}
-
- function test_set_from_object()
+
+ public function test_set_from_object()
{
// Make a stub of query instance
$query = new CI_TestCase();
@@ -268,37 +254,31 @@ class Table_test extends CI_TestCase {
return 2;
};
- $expected_heading = array(
+ $this->table->set_from_object($query);
+
+ $expected = array(
array('data' => 'name'),
array('data' => 'email')
);
- $expected_second = array(
+ $this->assertEquals($expected, $this->table->heading);
+
+ $expected = array(
'name' => array('data' => 'Foo Bar'),
'email' => array('data' => 'foo@bar.com'),
);
- $this->table->set_from_object($query);
-
- $this->assertEquals(
- $expected_heading,
- $this->table->heading
- );
-
- $this->assertEquals(
- $expected_second,
- $this->table->rows[1]
- );
+ $this->assertEquals($expected, $this->table->rows[1]);
}
-
- function test_generate()
+
+ public function test_generate()
{
// Prepare the data
$data = array(
array('Name', 'Color', 'Size'),
array('Fred', 'Blue', 'Small'),
array('Mary', 'Red', 'Large'),
- array('John', 'Green', 'Medium')
+ array('John', 'Green', 'Medium')
);
$table = $this->table->generate($data);
@@ -313,4 +293,5 @@ class Table_test extends CI_TestCase {
$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/codeigniter/libraries/Typography_test.php b/tests/codeigniter/libraries/Typography_test.php
index 250aefb24..eb6dacb73 100644
--- a/tests/codeigniter/libraries/Typography_test.php
+++ b/tests/codeigniter/libraries/Typography_test.php
@@ -4,11 +4,11 @@ class Typography_test extends CI_TestCase {
public function set_up()
{
- $obj = new StdClass;
+ $obj = new stdClass;
$obj->type = new Mock_Libraries_Typography();
-
+
$this->ci_instance($obj);
-
+
$this->type = $obj->type;
}
@@ -33,18 +33,18 @@ class Typography_test extends CI_TestCase {
'foo..' => 'foo..',
'foo...bar.' => 'foo&#8230;bar.',
'test. new' => 'test.&nbsp; new',
- );
-
+ );
+
foreach ($strs as $str => $expected)
{
- $this->assertEquals($expected, $this->type->format_characters($str));
+ $this->assertEquals($expected, $this->type->format_characters($str));
}
}
// --------------------------------------------------------------------
public function test_nl2br_except_pre()
- {
+ {
$str = <<<EOH
Hello, I'm a happy string with some new lines.
@@ -85,12 +85,11 @@ That's my story and I'm sticking to it.<br />
The End.
EOH;
- $this->assertEquals($expected,
- $this->type->nl2br_except_pre($str));
+ $this->assertEquals($expected, $this->type->nl2br_except_pre($str));
}
// --------------------------------------------------------------------
-
+
public function test_auto_typography()
{
$this->_blank_string();
@@ -103,7 +102,7 @@ EOH;
}
// --------------------------------------------------------------------
-
+
private function _blank_string()
{
// Test blank string
@@ -131,7 +130,7 @@ EOH;
{
$str = "This has way too many linebreaks.\n\n\n\nSee?";
$expect = "<p>This has way too many linebreaks.</p>\n\n<p>See?</p>";
-
+
$this->assertEquals($expect, $this->type->auto_typography($str, TRUE));
}
@@ -141,7 +140,7 @@ EOH;
{
$str = '<!-- I can haz comments? --> But no!';
$expect = '<p><!-- I can haz comments? -->&nbsp; But no!</p>';
-
+
$this->assertEquals($expect, $this->type->auto_typography($str));
}
@@ -151,7 +150,7 @@ EOH;
{
$str = '<p>My Sentence</p><pre>var_dump($this);</pre>';
$expect = '<p>My Sentence</p><pre>var_dump($this);</pre>';
-
+
$this->assertEquals($expect, $this->type->auto_typography($str));
}
@@ -161,7 +160,7 @@ EOH;
{
$str = 'My Sentence<pre>var_dump($this);</pre>';
$expect = '<p>My Sentence</p><pre>var_dump($this);</pre>';
-
+
$this->assertEquals($expect, $this->type->auto_typography($str));
}
@@ -170,19 +169,18 @@ EOH;
public function _protect_braced_quotes()
{
$this->type->protect_braced_quotes = TRUE;
-
+
$str = 'Test {parse="foobar"}';
$expect = '<p>Test {parse="foobar"}</p>';
-
+
$this->assertEquals($expect, $this->type->auto_typography($str));
$this->type->protect_braced_quotes = FALSE;
-
+
$str = 'Test {parse="foobar"}';
$expect = '<p>Test {parse=&#8220;foobar&#8221;}</p>';
-
- $this->assertEquals($expect, $this->type->auto_typography($str));
-
+ $this->assertEquals($expect, $this->type->auto_typography($str));
}
+
} \ No newline at end of file
diff --git a/tests/codeigniter/libraries/Useragent_test.php b/tests/codeigniter/libraries/Useragent_test.php
index 7dad7ac54..89383f807 100644
--- a/tests/codeigniter/libraries/Useragent_test.php
+++ b/tests/codeigniter/libraries/Useragent_test.php
@@ -1,7 +1,7 @@
<?php
class UserAgent_test extends CI_TestCase {
-
+
protected $_user_agent = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-us) AppleWebKit/533.20.25 (KHTML, like Gecko) Version/5.0.4 Safari/533.20.27';
protected $_mobile_ua = 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_1 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8B117 Safari/6531.22.7';
@@ -10,7 +10,7 @@ class UserAgent_test extends CI_TestCase {
// set a baseline user agent
$_SERVER['HTTP_USER_AGENT'] = $this->_user_agent;
- $obj = new StdClass;
+ $obj = new stdClass;
$obj->agent = new Mock_Libraries_UserAgent();
$this->ci_instance($obj);
@@ -82,6 +82,4 @@ class UserAgent_test extends CI_TestCase {
$this->assertFalse($this->agent->accept_charset());
}
- // --------------------------------------------------------------------
-
} \ No newline at end of file