Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added mock Input class to work with Session test

Signed-off-by: dchill42 <dchill42@gmail.com>
  • Loading branch information...
commit 22b795980dd87a5c54ae0e726f9ee267dc3faf5e 1 parent 2e3e230
Darren Hill authored
Showing with 20 additions and 9 deletions.
  1. +20 −9 tests/codeigniter/libraries/Session_test.php
29 tests/codeigniter/libraries/Session_test.php
View
@@ -29,16 +29,28 @@ public function set_up()
$_COOKIE = array();
// Establish necessary support classes
+ $cfg = $this->ci_core_class('cfg');
+ $ldr = $this->ci_core_class('load');
$obj = new stdClass;
- $classes = array(
- 'config' => 'cfg',
- 'load' => 'load',
- 'input' => 'in'
- );
- foreach ($classes as $name => $abbr) {
- $class = $this->ci_core_class($abbr);
- $obj->$name = new $class;
+ $obj->config = new $cfg();
+ $obj->load = new $ldr();
+
+ // Mock up Input
+ $input = 'Session_Input';
+ if ( ! class_exists($input))
+ {
+ $code = 'class '.$input.' { public $cookie = \'\'; public $ip_addr = \'\'; public $agent = \'\'; '.
+ 'public function cookie($name) { return $this->cookie; } '.
+ 'public function ip_address() { return $this->ip_addr; } '.
+ 'public function user_agent() { return $this->agent; } '.
+ 'public function is_cli_request() { return FALSE; } '.
+ 'public function is_ajax_request() { return FALSE; } }';
+ eval($code);
}
+ $obj->input = new $input();
+ $obj->input->ip_addr = '127.0.0.1';
+ $obj->input->agent = 'Mozilla/5.0 (Unit Test OS) AppleWebKit/537.4 (KHTML, like Gecko) CLI/1.2.3.4 PHP/5.x';
+
$this->ci_instance($obj);
// Attach session instance locally
@@ -402,4 +414,3 @@ public function test_sess_destroy()
$this->assertNull($this->session->native->userdata($key));
}
}
-
Please sign in to comment.
Something went wrong with that request. Please try again.