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