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 | */ |
| 25 | protected function _setcookie($name, $value = '', $expire = 0, $path = '', $domain = '', $secure = false, |
| 26 | $httponly = false) |
| 27 | { |
| 28 | if (empty($value) || $expire <= time()) { |
| 29 | // Clear cookie |
| 30 | unset($_COOKIE[$name]); |
| 31 | } |
| 32 | else { |
| 33 | // Set cookie |
| 34 | $_COOKIE[$name] = $value; |
| 35 | } |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Mock native driver (just for consistency in loading) |
| 41 | */ |
| 42 | class Mock_Libraries_Session_native extends CI_Session_native { } |
| 43 | |