Add tests to support logoutpage_hook function

This commit is contained in:
Dmitrii Metelkin 2016-08-19 12:06:13 +10:00
parent 97cd90dcfe
commit 01949baf71

View file

@ -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.
*/