1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-22 21:22:40 +00:00

Rename Fever user functions for consistency

This commit is contained in:
J. King 2019-03-21 10:19:30 -04:00
parent f51d20a863
commit 07122b524a
2 changed files with 6 additions and 6 deletions

View file

@ -98,7 +98,7 @@ class API extends \JKingWeb\Arsse\REST\AbstractHandler {
return true;
}
public static function registerUser(string $user, string $password = null): string {
public static function userRegister(string $user, string $password = null): string {
$password = $password ?? Arsse::$user->generatePassword();
$hash = md5("$user:$password");
$tr = Arsse::$db->begin();
@ -108,7 +108,7 @@ class API extends \JKingWeb\Arsse\REST\AbstractHandler {
return $password;
}
public static function unregisterUser(string $user): bool {
public static function userUnregister(string $user): bool {
return (bool) Arsse::$db->tokenRevoke($user, "fever.login");
}
}

View file

@ -146,9 +146,9 @@ class TestAPI extends \JKingWeb\Arsse\Test\AbstractTest {
\Phake::when(Arsse::$db)->tokenCreate("john.doe@example.org", $this->anything(), $this->anything())->thenThrow(new UserException("doesNotExist"));
if ($exp instanceof \JKingWeb\Arsse\AbstractException) {
$this->assertException($exp);
API::registerUser($user, $password);
API::userRegister($user, $password);
} else {
$this->assertSame($exp, API::registerUser($user, $password));
$this->assertSame($exp, API::userRegister($user, $password));
}
\Phake::verify(Arsse::$db)->tokenRevoke($user, "fever.login");
\Phake::verify(Arsse::$db)->tokenCreate($user, "fever.login", md5($user.":".($password ?? "RANDOM_PASSWORD")));
@ -167,10 +167,10 @@ class TestAPI extends \JKingWeb\Arsse\Test\AbstractTest {
public function testUnregisterAUser() {
\Phake::when(Arsse::$db)->tokenRevoke->thenReturn(3);
$this->assertTrue(API::unregisterUser("jane.doe@example.com"));
$this->assertTrue(API::userUnregister("jane.doe@example.com"));
\Phake::verify(Arsse::$db)->tokenRevoke("jane.doe@example.com", "fever.login");
\Phake::when(Arsse::$db)->tokenRevoke->thenReturn(0);
$this->assertFalse(API::unregisterUser("john.doe@example.com"));
$this->assertFalse(API::userUnregister("john.doe@example.com"));
\Phake::verify(Arsse::$db)->tokenRevoke("john.doe@example.com", "fever.login");
}
}