From 57486009573a86d9e286a49c92216ba17aae0d5a Mon Sep 17 00:00:00 2001 From: dchill42 Date: Tue, 31 Jul 2012 09:39:53 -0400 Subject: Added Session driver library unit tests and added driver library autoloading to test framework --- tests/mocks/libraries/session.php | 43 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tests/mocks/libraries/session.php (limited to 'tests/mocks/libraries') diff --git a/tests/mocks/libraries/session.php b/tests/mocks/libraries/session.php new file mode 100644 index 000000000..9d6feee42 --- /dev/null +++ b/tests/mocks/libraries/session.php @@ -0,0 +1,43 @@ +_flashdata_sweep(); + $this->_flashdata_mark(); + $this->_tempdata_sweep(); + } +} + +/** + * Mock cookie driver to overload cookie setting + */ +class Mock_Libraries_Session_cookie extends CI_Session_cookie { + /** + * Overload _setcookie to manage $_COOKIE values, since actual cookies can't be set in unit testing + */ + protected function _setcookie($name, $value = '', $expire = 0, $path = '', $domain = '', $secure = false, + $httponly = false) + { + if (empty($value) || $expire <= time()) { + // Clear cookie + unset($_COOKIE[$name]); + } + else { + // Set cookie + $_COOKIE[$name] = $value; + } + } +} + +/** + * Mock native driver (just for consistency in loading) + */ +class Mock_Libraries_Session_native extends CI_Session_native { } + -- cgit v1.2.3-24-g4f1b From 0c886901bc013e477b8c5eb9bc5e60c91d1fac56 Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Wed, 29 Aug 2012 23:23:22 +0100 Subject: Added lang mock and upload mock --- tests/mocks/libraries/upload.php | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tests/mocks/libraries/upload.php (limited to 'tests/mocks/libraries') diff --git a/tests/mocks/libraries/upload.php b/tests/mocks/libraries/upload.php new file mode 100644 index 000000000..988723e45 --- /dev/null +++ b/tests/mocks/libraries/upload.php @@ -0,0 +1,3 @@ + Date: Mon, 3 Sep 2012 18:57:35 +0100 Subject: Added Calendar library unit test --- tests/mocks/libraries/calendar.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 tests/mocks/libraries/calendar.php (limited to 'tests/mocks/libraries') diff --git a/tests/mocks/libraries/calendar.php b/tests/mocks/libraries/calendar.php new file mode 100644 index 000000000..8fee5365e --- /dev/null +++ b/tests/mocks/libraries/calendar.php @@ -0,0 +1,25 @@ +CI = new stdClass; + $this->CI->lang = new Mock_Core_Lang(); + + if ( ! in_array('calendar_lang.php', $this->CI->lang->is_loaded, TRUE)) + { + $this->CI->lang->load('calendar'); + } + + $this->local_time = time(); + + if (count($config) > 0) + { + $this->initialize($config); + } + + log_message('debug', 'Calendar Class Initialized'); + } + +} \ No newline at end of file -- cgit v1.2.3-24-g4f1b