Skip to content

Commit ff47874

Browse files
committed
[UPD] Added a test as reviewer suggested
1 parent 778c57f commit ff47874

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/auth_plugin_test.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,25 @@ public function test_throwing_exception_if_user_is_not_exist() {
237237
$this->expectExceptionMessage('Invalid parameter value detected (User is not exist)');
238238
$actual = $this->auth->get_login_url($user);
239239
}
240+
/**
241+
* Test that auth plugin throws correct exception if we trying to request not existing user.
242+
*/
243+
public function test_throwing_exception_if_user_is_suspended() {
244+
global $USER;
245+
246+
$user = $this->getDataGenerator()->create_user();
247+
$user->suspended = 1;
248+
$this->setUser($user);
249+
$this->assertEquals($USER->id, $user->id);
250+
251+
$this->create_user_private_key();
252+
$_POST['key'] = 'TestKey';
253+
254+
$this->expectException(invalid_parameter_exception::class);
255+
$this->expectExceptionMessage('Invalid parameter value detected (User is suspended)');
256+
257+
$this->auth->user_login_userkey();
258+
}
240259

241260
/**
242261
* Test that auth plugin throws correct exception if we trying to request user,

0 commit comments

Comments
 (0)