From 8af88f3f729b7bcfd2a106f858b5445deafe5ed0 Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Tue, 15 May 2012 21:52:53 +0700 Subject: Security Code coverage --- tests/mocks/libraries/table.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/mocks/libraries') diff --git a/tests/mocks/libraries/table.php b/tests/mocks/libraries/table.php index 1a6ff8d35..97fbb30bd 100644 --- a/tests/mocks/libraries/table.php +++ b/tests/mocks/libraries/table.php @@ -2,7 +2,7 @@ class Mock_Libraries_Table extends CI_Table { - // Overide inaccesible private or protected method + // Overide inaccesible protected method public function __call($method, $params) { if (is_callable(array($this, '_'.$method))) -- cgit v1.2.3-24-g4f1b From 9d1407523ae585d45171b54123ba29c0ec831f79 Mon Sep 17 00:00:00 2001 From: Joffrey Jaffeux Date: Wed, 6 Jun 2012 01:40:18 +0200 Subject: tests for encryption class --- tests/mocks/libraries/encrypt.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tests/mocks/libraries/encrypt.php (limited to 'tests/mocks/libraries') diff --git a/tests/mocks/libraries/encrypt.php b/tests/mocks/libraries/encrypt.php new file mode 100644 index 000000000..a9bbaafdc --- /dev/null +++ b/tests/mocks/libraries/encrypt.php @@ -0,0 +1,15 @@ + Date: Sat, 9 Jun 2012 23:34:21 +0300 Subject: Cleanup/optimize tests/mocks/ --- tests/mocks/libraries/encrypt.php | 21 +++++++++++---------- tests/mocks/libraries/table.php | 3 ++- 2 files changed, 13 insertions(+), 11 deletions(-) (limited to 'tests/mocks/libraries') diff --git a/tests/mocks/libraries/encrypt.php b/tests/mocks/libraries/encrypt.php index a9bbaafdc..f1859398f 100644 --- a/tests/mocks/libraries/encrypt.php +++ b/tests/mocks/libraries/encrypt.php @@ -2,14 +2,15 @@ class Mock_Libraries_Encrypt extends CI_Encrypt { - // Overide inaccesible protected method - public function __call($method, $params) - { - if (is_callable(array($this, '_'.$method))) - { - return call_user_func_array(array($this, '_'.$method), $params); - } - - throw new BadMethodCallException('Method '.$method.' was not found'); - } + // Overide inaccesible protected method + public function __call($method, $params) + { + if (is_callable(array($this, '_'.$method))) + { + return call_user_func_array(array($this, '_'.$method), $params); + } + + throw new BadMethodCallException('Method '.$method.' was not found'); + } + } \ No newline at end of file diff --git a/tests/mocks/libraries/table.php b/tests/mocks/libraries/table.php index 97fbb30bd..87c278bce 100644 --- a/tests/mocks/libraries/table.php +++ b/tests/mocks/libraries/table.php @@ -1,7 +1,7 @@ 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 From 5fd3ae8d33a4f5d3159b86683b9a670e973a63f5 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 24 Oct 2012 14:55:35 +0300 Subject: [ci skip] style and phpdoc-related changes (rel #1295) --- tests/mocks/libraries/session.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'tests/mocks/libraries') diff --git a/tests/mocks/libraries/session.php b/tests/mocks/libraries/session.php index 9d6feee42..c6e194f58 100644 --- a/tests/mocks/libraries/session.php +++ b/tests/mocks/libraries/session.php @@ -4,6 +4,7 @@ * Mock library to add testing features to Session driver library */ class Mock_Libraries_Session extends CI_Session { + /** * Simulate new page load */ @@ -19,18 +20,18 @@ class Mock_Libraries_Session extends CI_Session { * 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) + protected function _setcookie($name, $value = '', $expire = 0, $path = '', $domain = '', $secure = FALSE, $httponly = FALSE) { - if (empty($value) || $expire <= time()) { - // Clear cookie + if (empty($value) OR $expire <= time()) + { unset($_COOKIE[$name]); } - else { - // Set cookie + else + { $_COOKIE[$name] = $value; } } @@ -39,5 +40,4 @@ class Mock_Libraries_Session_cookie extends CI_Session_cookie { /** * Mock native driver (just for consistency in loading) */ -class Mock_Libraries_Session_native extends CI_Session_native { } - +class Mock_Libraries_Session_native extends CI_Session_native { } \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 6262d053db57957c4445ef7fce76070854c3e30d Mon Sep 17 00:00:00 2001 From: dchill42 Date: Sat, 24 Nov 2012 18:41:13 -0500 Subject: Added support for extending individual driver classes and driver unit tests Signed-off-by: dchill42 --- tests/mocks/libraries/driver.php | 27 +++++++++++++++++++++++++++ tests/mocks/libraries/session.php | 7 ------- 2 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 tests/mocks/libraries/driver.php (limited to 'tests/mocks/libraries') diff --git a/tests/mocks/libraries/driver.php b/tests/mocks/libraries/driver.php new file mode 100644 index 000000000..91bb01596 --- /dev/null +++ b/tests/mocks/libraries/driver.php @@ -0,0 +1,27 @@ +valid_drivers; + } + + $this->valid_drivers = (array) $drivers; + } + + /** + * Get library name + */ + public function get_name() + { + return $this->lib_name; + } +} diff --git a/tests/mocks/libraries/session.php b/tests/mocks/libraries/session.php index c6e194f58..11b27cf67 100644 --- a/tests/mocks/libraries/session.php +++ b/tests/mocks/libraries/session.php @@ -4,7 +4,6 @@ * Mock library to add testing features to Session driver library */ class Mock_Libraries_Session extends CI_Session { - /** * Simulate new page load */ @@ -20,7 +19,6 @@ class Mock_Libraries_Session extends CI_Session { * 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 */ @@ -36,8 +34,3 @@ class Mock_Libraries_Session_cookie extends CI_Session_cookie { } } } - -/** - * Mock native driver (just for consistency in loading) - */ -class Mock_Libraries_Session_native extends CI_Session_native { } \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 1713d322a309d9cf405cfe83e2131368f29b222b Mon Sep 17 00:00:00 2001 From: dchill42 Date: Sat, 24 Nov 2012 20:23:21 -0500 Subject: Replaced Mock_Core_Lang with PHPUnit mockups Signed-off-by: dchill42 --- tests/mocks/libraries/calendar.php | 25 ------------------------- 1 file changed, 25 deletions(-) delete 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 deleted file mode 100644 index 8fee5365e..000000000 --- a/tests/mocks/libraries/calendar.php +++ /dev/null @@ -1,25 +0,0 @@ -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 From 838a9d69a9139b6bcd6f8765fdd2d58b929e70ad Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 3 Dec 2012 14:37:47 +0200 Subject: [ci skip] Cleaned some spaces --- tests/mocks/libraries/driver.php | 2 +- tests/mocks/libraries/session.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/mocks/libraries') diff --git a/tests/mocks/libraries/driver.php b/tests/mocks/libraries/driver.php index 91bb01596..633194345 100644 --- a/tests/mocks/libraries/driver.php +++ b/tests/mocks/libraries/driver.php @@ -24,4 +24,4 @@ class Mock_Libraries_Driver extends CI_Driver_Library { { return $this->lib_name; } -} +} \ No newline at end of file diff --git a/tests/mocks/libraries/session.php b/tests/mocks/libraries/session.php index 11b27cf67..562033bbf 100644 --- a/tests/mocks/libraries/session.php +++ b/tests/mocks/libraries/session.php @@ -33,4 +33,4 @@ class Mock_Libraries_Session_cookie extends CI_Session_cookie { $_COOKIE[$name] = $value; } } -} +} \ No newline at end of file -- cgit v1.2.3-24-g4f1b