Taufan Aditya | 7756af5 | 2012-05-15 23:57:05 +0700 | [diff] [blame] | 1 | <?php |
| 2 | |
| 3 | class Mock_Core_Input extends CI_Input { |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 4 | |
Taufan Aditya | 7756af5 | 2012-05-15 23:57:05 +0700 | [diff] [blame] | 5 | /** |
Andrey Andreev | f243ce1 | 2012-06-09 23:34:21 +0300 | [diff] [blame] | 6 | * Since we use GLOBAL to fetch Security and Utf8 classes, |
| 7 | * we need to use inversion of control to mock up |
Taufan Aditya | 7756af5 | 2012-05-15 23:57:05 +0700 | [diff] [blame] | 8 | * the same process within CI_Input class constructor. |
| 9 | * |
| 10 | * @covers CI_Input::__construct() |
| 11 | */ |
| 12 | public function __construct($security, $utf8) |
| 13 | { |
| 14 | $this->_allow_get_array = (config_item('allow_get_array') === TRUE); |
| 15 | $this->_enable_xss = (config_item('global_xss_filtering') === TRUE); |
| 16 | $this->_enable_csrf = (config_item('csrf_protection') === TRUE); |
| 17 | |
| 18 | // Assign Security and Utf8 classes |
| 19 | $this->security = $security; |
| 20 | $this->uni = $utf8; |
| 21 | |
| 22 | // Sanitize global arrays |
| 23 | $this->_sanitize_globals(); |
| 24 | } |
| 25 | |
| 26 | public function fetch_from_array($array, $index = '', $xss_clean = FALSE) |
| 27 | { |
| 28 | return parent::_fetch_from_array($array, $index, $xss_clean); |
| 29 | } |
| 30 | |
dchill42 | 82003da | 2012-10-09 13:28:17 -0400 | [diff] [blame] | 31 | /** |
| 32 | * Lie about being a CLI request |
| 33 | * |
| 34 | * We take advantage of this in libraries/Session_test |
| 35 | */ |
| 36 | public function is_cli_request() |
| 37 | { |
| 38 | return FALSE; |
| 39 | } |
| 40 | |
Andrey Andreev | 52caf59 | 2015-02-27 15:09:34 +0200 | [diff] [blame] | 41 | public function __set($name, $value) |
| 42 | { |
| 43 | if ($name === 'ip_address') |
| 44 | { |
| 45 | $this->ip_address = $value; |
| 46 | } |
| 47 | } |
| 48 | |
Taufan Aditya | 7756af5 | 2012-05-15 23:57:05 +0700 | [diff] [blame] | 49 | } |