aboutsummaryrefslogtreecommitdiffstats
path: root/includes/api/ApiUnblock.php
diff options
context:
space:
mode:
authorDannyS712 <DannyS712.enwiki@gmail.com>2020-10-04 01:28:04 +0000
committerDannyS712 <DannyS712.enwiki@gmail.com>2020-11-19 17:55:42 +0000
commitd0949004221282594e9eaecba0e8c768ab871cea (patch)
treee40adab7126465568a8c950a8f2a872869f4d919 /includes/api/ApiUnblock.php
parentc0874e2d9e1e885c594664bb9062445dadf65075 (diff)
downloadmediawikicore-d0949004221282594e9eaecba0e8c768ab871cea.tar.gz
mediawikicore-d0949004221282594e9eaecba0e8c768ab871cea.zip
Add pure unit tests for ApiUnblock
Bug: T248686 Change-Id: I4de6a01014288973b69c53d236dbf1416dcf66fa
Diffstat (limited to 'includes/api/ApiUnblock.php')
-rw-r--r--includes/api/ApiUnblock.php12
1 files changed, 11 insertions, 1 deletions
diff --git a/includes/api/ApiUnblock.php b/includes/api/ApiUnblock.php
index 97a7eabbae2b..33972e615a64 100644
--- a/includes/api/ApiUnblock.php
+++ b/includes/api/ApiUnblock.php
@@ -60,6 +60,16 @@ class ApiUnblock extends ApiBase {
}
/**
+ * Exists so that the static call to UserCache::singleton can be overriden in tests
+ *
+ * @internal
+ * @return UserCache
+ */
+ protected function getUserCache() {
+ return UserCache::singleton();
+ }
+
+ /**
* Unblocks the specified user or provides the reason the unblock failed.
*/
public function execute() {
@@ -73,7 +83,7 @@ class ApiUnblock extends ApiBase {
}
if ( $params['userid'] !== null ) {
- $username = User::whoIs( $params['userid'] );
+ $username = $this->getUserCache()->getProp( $params['userid'], 'name' );
if ( $username === false ) {
$this->dieWithError( [ 'apierror-nosuchuserid', $params['userid'] ], 'nosuchuserid' );