blob: adbecb32970ab1c52db0ce2834fd17bd2361d3ad [file] [log] [blame]
dchill4257486002012-07-31 09:39:53 -04001<?php
2
3/**
4 * Mock library to add testing features to Session driver library
5 */
6class 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 */
21class 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 Andreev5fd3ae82012-10-24 14:55:35 +030025 protected function _setcookie($name, $value = '', $expire = 0, $path = '', $domain = '', $secure = FALSE, $httponly = FALSE)
dchill4257486002012-07-31 09:39:53 -040026 {
Andrey Andreev5fd3ae82012-10-24 14:55:35 +030027 if (empty($value) OR $expire <= time())
28 {
dchill4257486002012-07-31 09:39:53 -040029 unset($_COOKIE[$name]);
30 }
Andrey Andreev5fd3ae82012-10-24 14:55:35 +030031 else
32 {
dchill4257486002012-07-31 09:39:53 -040033 $_COOKIE[$name] = $value;
34 }
35 }
Andrey Andreeve84c0142013-02-21 15:28:13 +020036}
37
38class Mock_Libraries_Session_native extends CI_Session_native {}