dchill42 | 5748600 | 2012-07-31 09:39:53 -0400 | [diff] [blame] | 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Mock library to add testing features to Session driver library |
| 5 | */ |
| 6 | class Mock_Libraries_Session extends CI_Session { |
| 7 | /** |
| 8 | * Simulate new page load |
| 9 | */ |
| 10 | public function reload() |
| 11 | { |
| 12 | $this->_flashdata_sweep(); |
| 13 | $this->_flashdata_mark(); |
| 14 | $this->_tempdata_sweep(); |
| 15 | } |
| 16 | } |
| 17 | |
| 18 | /** |
| 19 | * Mock cookie driver to overload cookie setting |
| 20 | */ |
| 21 | class Mock_Libraries_Session_cookie extends CI_Session_cookie { |
| 22 | /** |
| 23 | * Overload _setcookie to manage $_COOKIE values, since actual cookies can't be set in unit testing |
| 24 | */ |
Andrey Andreev | 5fd3ae8 | 2012-10-24 14:55:35 +0300 | [diff] [blame] | 25 | protected function _setcookie($name, $value = '', $expire = 0, $path = '', $domain = '', $secure = FALSE, $httponly = FALSE) |
dchill42 | 5748600 | 2012-07-31 09:39:53 -0400 | [diff] [blame] | 26 | { |
Andrey Andreev | 5fd3ae8 | 2012-10-24 14:55:35 +0300 | [diff] [blame] | 27 | if (empty($value) OR $expire <= time()) |
| 28 | { |
dchill42 | 5748600 | 2012-07-31 09:39:53 -0400 | [diff] [blame] | 29 | unset($_COOKIE[$name]); |
| 30 | } |
Andrey Andreev | 5fd3ae8 | 2012-10-24 14:55:35 +0300 | [diff] [blame] | 31 | else |
| 32 | { |
dchill42 | 5748600 | 2012-07-31 09:39:53 -0400 | [diff] [blame] | 33 | $_COOKIE[$name] = $value; |
| 34 | } |
| 35 | } |
Andrey Andreev | e84c014 | 2013-02-21 15:28:13 +0200 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | class Mock_Libraries_Session_native extends CI_Session_native {} |