From 07122b524a3a6bbb5d4dba3e5d89f26177264a9d Mon Sep 17 00:00:00 2001 From: "J. King" Date: Thu, 21 Mar 2019 10:19:30 -0400 Subject: [PATCH] Rename Fever user functions for consistency --- lib/REST/Fever/API.php | 4 ++-- tests/cases/REST/Fever/TestAPI.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/REST/Fever/API.php b/lib/REST/Fever/API.php index b5b91ab3..1c0c6696 100644 --- a/lib/REST/Fever/API.php +++ b/lib/REST/Fever/API.php @@ -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"); } } diff --git a/tests/cases/REST/Fever/TestAPI.php b/tests/cases/REST/Fever/TestAPI.php index 0d974d18..8d7867ae 100644 --- a/tests/cases/REST/Fever/TestAPI.php +++ b/tests/cases/REST/Fever/TestAPI.php @@ -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"); } }