From 01949baf71332e4952d22d0ab5e2ab0fcb0404e9 Mon Sep 17 00:00:00 2001 From: Dmitrii Metelkin Date: Fri, 19 Aug 2016 12:06:13 +1000 Subject: [PATCH] Add tests to support logoutpage_hook function --- tests/auth_plugin_test.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/auth_plugin_test.php b/tests/auth_plugin_test.php index 7033fa8..41f585c 100644 --- a/tests/auth_plugin_test.php +++ b/tests/auth_plugin_test.php @@ -105,6 +105,33 @@ class auth_plugin_userkey_testcase extends advanced_testcase { $this->assertEquals($expected, $actual); } + /** + * Test that logout page hook sets global redirect variable correctly. + */ + public function test_logoutpage_hook_sets_global_redirect_correctly() { + global $redirect, $SESSION; + + $this->auth->logoutpage_hook(); + $this->assertEquals('', $redirect); + + $SESSION->userkey = true; + $this->auth = new auth_plugin_userkey(); + $this->auth->logoutpage_hook(); + $this->assertEquals('', $redirect); + + unset($SESSION->userkey); + set_config('redirecturl', 'http://example.com', 'auth_userkey'); + $this->auth = new auth_plugin_userkey(); + $this->auth->logoutpage_hook(); + $this->assertEquals('', $redirect); + + $SESSION->userkey = true; + set_config('redirecturl', 'http://example.com', 'auth_userkey'); + $this->auth = new auth_plugin_userkey(); + $this->auth->logoutpage_hook(); + $this->assertEquals('http://example.com', $redirect); + } + /** * Test that configured mapping field gets returned correctly. */