return \Civi\Api4\User::get(FALSE)
->addWhere('username', '=', $username)
->execute()
- ->single()['id'] ?? NULL;
+ ->first()['id'] ?? NULL;
}
/**
$this->assertEquals('Password reset link for Demonstrators Anonymous', $result['subject']);
}
+ public function testGetUserIDFromUsername() {
+ [$contactID, $adminUserID, $security] = $this->createFixtureContactAndUser();
+ $this->assertEquals($adminUserID, $security->getUserIDFromUsername('user_one'), 'Should return admin user ID');
+ $this->assertNull($security->getUserIDFromUsername('user_unknown'), 'Should return NULL for non-existent user');
+ }
+
protected function deleteStuffWeMade() {
User::delete(FALSE)->addWhere('username', '=', 'testuser1')->execute();
}