diff --git a/src/Api/Jobs/UserJobs/AcceptUserRegistrationJob.php b/src/Api/Jobs/UserJobs/AcceptUserRegistrationJob.php index 110a5142..079fc247 100644 --- a/src/Api/Jobs/UserJobs/AcceptUserRegistrationJob.php +++ b/src/Api/Jobs/UserJobs/AcceptUserRegistrationJob.php @@ -10,7 +10,7 @@ class AcceptUserRegistrationJob extends AbstractJob public function execute() { - $user = $this->userRetriever->getRequiredArguments(); + $user = $this->userRetriever->retrieve(); $user->setStaffConfirmed(true); UserModel::save($user); @@ -18,6 +18,8 @@ class AcceptUserRegistrationJob extends AbstractJob Logger::log('{user} confirmed {subject}\'s account', [ 'user' => TextHelper::reprUser(Auth::getCurrentUser()), 'subject' => TextHelper::reprUser($user)]); + + return $user; } public function getRequiredArguments() diff --git a/tests/JobTests/AcceptUserRegistrationJobTest.php b/tests/JobTests/AcceptUserRegistrationJobTest.php new file mode 100644 index 00000000..a1e8c839 --- /dev/null +++ b/tests/JobTests/AcceptUserRegistrationJobTest.php @@ -0,0 +1,22 @@ +grantAccess('acceptUserRegistration'); + + $user = $this->mockUser(); + $this->assert->isFalse($user->isStaffConfirmed()); + + $user = $this->assert->doesNotThrow(function() use ($user) + { + return Api::run( + new AcceptUserRegistrationJob(), + [ + JobArgs::ARG_USER_NAME => $user->getName(), + ]); + }); + + $this->assert->isTrue($user->isStaffConfirmed()); + } +} diff --git a/tests/MiscTests/AuthTest.php b/tests/MiscTests/AuthTest.php index 3ae96c56..a78da3b4 100644 --- a/tests/MiscTests/AuthTest.php +++ b/tests/MiscTests/AuthTest.php @@ -78,7 +78,7 @@ class AuthTest extends AbstractTest }, 'You are banned'); } - public function testStaffConfirmationEnabled() + public function testStaffConfirmationEnabledFail() { getConfig()->registration->staffActivation = true; getConfig()->registration->needEmailForRegistering = false; @@ -93,7 +93,24 @@ class AuthTest extends AbstractTest }, 'staff hasn\'t confirmed'); } - public function testStaffConfirmationDisabled() + public function testStaffConfirmationEnabledPass() + { + getConfig()->registration->staffActivation = true; + getConfig()->registration->needEmailForRegistering = false; + + $user = $this->prepareValidUser(); + $user->setStaffConfirmed(true); + UserModel::save($user); + + $this->assert->doesNotThrow(function() + { + Auth::login('existing', 'bleee', false); + }); + + $this->assert->isTrue(Auth::isLoggedIn()); + } + + public function testStaffConfirmationDisabledPass() { getConfig()->registration->staffActivation = false; getConfig()->registration->needEmailForRegistering = false; @@ -106,6 +123,8 @@ class AuthTest extends AbstractTest { Auth::login('existing', 'bleee', false); }); + + $this->assert->isTrue(Auth::isLoggedIn()); } public function testMailConfirmationEnabledFail1()