summaryrefslogtreecommitdiffstats
path: root/tests/codeigniter
diff options
context:
space:
mode:
authorDaniel Hunsaker <danhunsaker@gmail.com>2013-02-22 21:49:33 +0100
committerDaniel Hunsaker <danhunsaker@gmail.com>2013-02-22 21:49:33 +0100
commit44a6d1da2be916fe0f23a3ea4d5fcb391d7f65dd (patch)
tree31549ebf6ea5ea98e4347eb640d1caa685316f3e /tests/codeigniter
parent353f9834adf3f44c6c7a0f924089bb2b43360404 (diff)
parenteb291c1d1e1116a4420fa30e587adeea0451eeb7 (diff)
Merge branch 'develop' of github.com:EllisLab/CodeIgniter into feature/exit-status
Diffstat (limited to 'tests/codeigniter')
-rw-r--r--tests/codeigniter/core/Input_test.php25
-rw-r--r--tests/codeigniter/core/Loader_test.php18
-rw-r--r--tests/codeigniter/core/Output_test.php35
-rw-r--r--tests/codeigniter/core/URI_test.php2
-rw-r--r--tests/codeigniter/core/Utf8_test.php20
-rw-r--r--tests/codeigniter/helpers/form_helper_test.php2
-rw-r--r--tests/codeigniter/helpers/url_helper_test.php11
-rw-r--r--tests/codeigniter/libraries/Upload_test.php6
8 files changed, 96 insertions, 23 deletions
diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php
index ca1c6dfd7..5cf25fefa 100644
--- a/tests/codeigniter/core/Input_test.php
+++ b/tests/codeigniter/core/Input_test.php
@@ -95,8 +95,8 @@ class Input_test extends CI_TestCase {
public function test_cookie()
{
$_COOKIE['foo'] = 'bar';
-
$this->assertEquals('bar', $this->input->cookie('foo'));
+ $this->assertNull($this->input->cookie('bar'));
}
// --------------------------------------------------------------------
@@ -138,4 +138,27 @@ class Input_test extends CI_TestCase {
}
}
+ // --------------------------------------------------------------------
+
+ public function test_method()
+ {
+ $_SERVER['REQUEST_METHOD'] = 'GET';
+ $this->assertEquals('get', $this->input->method());
+ $this->assertEquals('GET', $this->input->method(TRUE));
+ $_SERVER['REQUEST_METHOD'] = 'POST';
+ $this->assertEquals('post', $this->input->method());
+ $this->assertEquals('POST', $this->input->method(TRUE));
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_is_ajax_request()
+ {
+ $this->assertFalse($this->input->is_ajax_request());
+ $_SERVER['HTTP_X_REQUESTED_WITH'] = 'test';
+ $this->assertFalse($this->input->is_ajax_request());
+ $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
+ $this->assertTrue($this->input->is_ajax_request());
+ }
+
} \ No newline at end of file
diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php
index ecc5ca933..dea01a555 100644
--- a/tests/codeigniter/core/Loader_test.php
+++ b/tests/codeigniter/core/Loader_test.php
@@ -25,7 +25,7 @@ class Loader_test extends CI_TestCase {
// Create library in VFS
$lib = 'unit_test_lib';
$class = 'CI_'.ucfirst($lib);
- $this->ci_vfs_create($lib, '<?php class '.$class.' { }', $this->ci_base_root, 'libraries');
+ $this->ci_vfs_create(ucfirst($lib), '<?php class '.$class.' { }', $this->ci_base_root, 'libraries');
// Test is_loaded fail
$this->assertFalse($this->load->is_loaded($lib));
@@ -48,7 +48,7 @@ class Loader_test extends CI_TestCase {
// Test non-existent class
$this->setExpectedException(
'RuntimeException',
- 'CI Error: Non-existent class: '.$lib
+ 'CI Error: Unable to load the requested class: '.ucfirst($lib)
);
$this->assertNull($this->load->library($lib));
}
@@ -105,7 +105,7 @@ class Loader_test extends CI_TestCase {
$lib = 'unit_test_config_lib';
$class = 'CI_'.ucfirst($lib);
$content = '<?php class '.$class.' { public function __construct($params) { $this->config = $params; } }';
- $this->ci_vfs_create($lib, $content, $this->ci_base_root, 'libraries');
+ $this->ci_vfs_create(ucfirst($lib), $content, $this->ci_base_root, 'libraries');
// Create config file
$cfg = array(
@@ -133,7 +133,7 @@ class Loader_test extends CI_TestCase {
// Create library in VFS
$lib = 'super_test_library';
$class = ucfirst($lib);
- $this->ci_vfs_create($lib, '<?php class '.$class.' { }', $this->ci_app_root, 'libraries');
+ $this->ci_vfs_create(ucfirst($lib), '<?php class '.$class.' { }', $this->ci_app_root, 'libraries');
// Load library
$this->assertNull($this->load->library($lib));
@@ -152,7 +152,7 @@ class Loader_test extends CI_TestCase {
$dir = ucfirst($driver);
$class = 'CI_'.$dir;
$content = '<?php class '.$class.' { } ';
- $this->ci_vfs_create($driver, $content, $this->ci_base_root, 'libraries/'.$dir);
+ $this->ci_vfs_create(ucfirst($driver), $content, $this->ci_base_root, 'libraries/'.$dir);
// Test loading as an array.
$this->assertNull($this->load->driver(array($driver)));
@@ -410,7 +410,7 @@ class Loader_test extends CI_TestCase {
$dir = 'third-party';
$lib = 'unit_test_package';
$class = 'CI_'.ucfirst($lib);
- $this->ci_vfs_create($lib, '<?php class '.$class.' { }', $this->ci_app_root, array($dir, 'libraries'));
+ $this->ci_vfs_create(ucfirst($lib), '<?php class '.$class.' { }', $this->ci_app_root, array($dir, 'libraries'));
// Get paths
$paths = $this->load->get_package_paths(TRUE);
@@ -440,7 +440,7 @@ class Loader_test extends CI_TestCase {
// Test failed load without path
$this->setExpectedException(
'RuntimeException',
- 'CI Error: Unable to load the requested class: '.$lib
+ 'CI Error: Unable to load the requested class: '.ucfirst($lib)
);
$this->load->library($lib);
}
@@ -467,13 +467,13 @@ class Loader_test extends CI_TestCase {
// Create library in VFS
$lib = 'autolib';
$lib_class = 'CI_'.ucfirst($lib);
- $this->ci_vfs_create($lib, '<?php class '.$lib_class.' { }', $this->ci_base_root, 'libraries');
+ $this->ci_vfs_create(ucfirst($lib), '<?php class '.$lib_class.' { }', $this->ci_base_root, 'libraries');
// Create driver in VFS
$drv = 'autodrv';
$subdir = ucfirst($drv);
$drv_class = 'CI_'.$subdir;
- $this->ci_vfs_create($drv, '<?php class '.$drv_class.' { }', $this->ci_base_root, array('libraries', $subdir));
+ $this->ci_vfs_create(ucfirst($drv), '<?php class '.$drv_class.' { }', $this->ci_base_root, array('libraries', $subdir));
// Create model in VFS package path
$dir = 'testdir';
diff --git a/tests/codeigniter/core/Output_test.php b/tests/codeigniter/core/Output_test.php
index 728df3bf6..0eeb93f7b 100644
--- a/tests/codeigniter/core/Output_test.php
+++ b/tests/codeigniter/core/Output_test.php
@@ -3,6 +3,16 @@
class Output_test extends CI_TestCase {
public $output;
+ protected $_output_data = <<<HTML
+<html>
+ <head>
+ <title>Basic HTML</title>
+ </head>
+ <body>
+ Test
+ </body>
+</html>
+HTML;
public function set_up()
{
@@ -13,6 +23,31 @@ class Output_test extends CI_TestCase {
// --------------------------------------------------------------------
+ public function test_set_get_append_output()
+ {
+ $append = "<!-- comment /-->\n";
+
+ $this->assertEquals(
+ $this->_output_data.$append,
+ $this->output
+ ->set_output($this->_output_data)
+ ->append_output("<!-- comment /-->\n")
+ ->get_output()
+ );
+ }
+
+ // --------------------------------------------------------------------
+
+ 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());
diff --git a/tests/codeigniter/core/URI_test.php b/tests/codeigniter/core/URI_test.php
index e2deabe51..7fa0e6265 100644
--- a/tests/codeigniter/core/URI_test.php
+++ b/tests/codeigniter/core/URI_test.php
@@ -91,7 +91,7 @@ class URI_test extends CI_TestCase {
public function test_explode_segments()
{
- // Lets test the function's ability to clean up this mess
+ // Let's test the function's ability to clean up this mess
$uris = array(
'test/uri' => array('test', 'uri'),
'/test2/uri2' => array('test2', 'uri2'),
diff --git a/tests/codeigniter/core/Utf8_test.php b/tests/codeigniter/core/Utf8_test.php
new file mode 100644
index 000000000..caa7b6986
--- /dev/null
+++ b/tests/codeigniter/core/Utf8_test.php
@@ -0,0 +1,20 @@
+<?php
+
+class Utf8_test extends CI_TestCase {
+
+ public function set_up()
+ {
+ $this->utf8 = new Mock_Core_Utf8();
+ }
+
+ // --------------------------------------------------------------------
+
+ public function test_convert_to_utf8()
+ {
+ $this->assertEquals(
+ $this->utf8->convert_to_utf8('', 'WINDOWS-1251'),
+ 'тест'
+ );
+ }
+
+} \ No newline at end of file
diff --git a/tests/codeigniter/helpers/form_helper_test.php b/tests/codeigniter/helpers/form_helper_test.php
index 89165271e..e234f9c83 100644
--- a/tests/codeigniter/helpers/form_helper_test.php
+++ b/tests/codeigniter/helpers/form_helper_test.php
@@ -58,7 +58,7 @@ EOH;
public function test_form_upload()
{
$expected = <<<EOH
-<input type="file" name="attachment" value="" />
+<input type="file" name="attachment" />
EOH;
diff --git a/tests/codeigniter/helpers/url_helper_test.php b/tests/codeigniter/helpers/url_helper_test.php
index 5fc364238..24823a634 100644
--- a/tests/codeigniter/helpers/url_helper_test.php
+++ b/tests/codeigniter/helpers/url_helper_test.php
@@ -48,11 +48,12 @@ class Url_helper_test extends CI_TestCase {
public function test_auto_link_url()
{
$strings = array(
- 'www.codeigniter.com test' => '<a href="http://www.codeigniter.com">http://www.codeigniter.com</a> test',
+ 'www.codeigniter.com test' => '<a href="http://www.codeigniter.com">www.codeigniter.com</a> test',
'This is my noreply@codeigniter.com test' => 'This is my noreply@codeigniter.com test',
- '<br />www.google.com' => '<br /><a href="http://www.google.com">http://www.google.com</a>',
- 'Download CodeIgniter at www.codeigniter.com. Period test.' => 'Download CodeIgniter at <a href="http://www.codeigniter.com">http://www.codeigniter.com</a>. Period test.',
- 'Download CodeIgniter at www.codeigniter.com, comma test' => 'Download CodeIgniter at <a href="http://www.codeigniter.com">http://www.codeigniter.com</a>, comma test'
+ '<br />www.google.com' => '<br /><a href="http://www.google.com">www.google.com</a>',
+ 'Download CodeIgniter at www.codeigniter.com. Period test.' => 'Download CodeIgniter at <a href="http://www.codeigniter.com">www.codeigniter.com</a>. Period test.',
+ 'Download CodeIgniter at www.codeigniter.com, comma test' => 'Download CodeIgniter at <a href="http://www.codeigniter.com">www.codeigniter.com</a>, comma test',
+ 'This one: ://codeigniter.com must not break this one: http://codeigniter.com' => 'This one: <a href="://codeigniter.com">://codeigniter.com</a> must not break this one: <a href="http://codeigniter.com">http://codeigniter.com</a>'
);
foreach ($strings as $in => $out)
@@ -66,7 +67,7 @@ class Url_helper_test extends CI_TestCase {
public function test_pull_675()
{
$strings = array(
- '<br />www.google.com' => '<br /><a href="http://www.google.com">http://www.google.com</a>',
+ '<br />www.google.com' => '<br /><a href="http://www.google.com">www.google.com</a>',
);
foreach ($strings as $in => $out)
diff --git a/tests/codeigniter/libraries/Upload_test.php b/tests/codeigniter/libraries/Upload_test.php
index 1bd8f1430..4d9e4a46e 100644
--- a/tests/codeigniter/libraries/Upload_test.php
+++ b/tests/codeigniter/libraries/Upload_test.php
@@ -208,12 +208,6 @@ class Upload_test extends CI_TestCase {
$this->assertEquals('', $this->upload->get_extension('hello'));
}
- function test_clean_file_name()
- {
- $this->assertEquals('hello.txt', $this->upload->clean_file_name('hello.txt'));
- $this->assertEquals('hello.txt', $this->upload->clean_file_name('%253chell>o.txt'));
- }
-
function test_limit_filename_length()
{
$this->assertEquals('hello.txt', $this->upload->limit_filename_length('hello.txt', 10));