Skip to content
Snippets Groups Projects
Commit ebbbfaef authored by Eirik Morland's avatar Eirik Morland
Browse files

Issue #3420052: ::isAdmin should use user ids

parent 020ba0b6
No related branches found
No related tags found
1 merge request!30Make sure the admins return true for is admin
Pipeline #90463 passed
......@@ -228,7 +228,7 @@ class TeamNode extends Node {
if (!$user->id()) {
return FALSE;
}
return in_array($user->id(), $this->getAdministrators());
return in_array($user->id(), $this->getAdministratorIds());
}
/**
......
......@@ -60,6 +60,31 @@ class TeamNodeTest extends KernelTestBase {
self::assertEquals([$user->id()], $node->getAdministratorIds());
}
/**
* Tests checking admins.
*/
public function testCheckAdmins() {
/** @var \Drupal\violinist_teams\TeamNode $node */
$node = Node::create([
'type' => $this->nodeType->id(),
]);
$user = User::create([
'name' => 'test',
'mail' => 'test@example.com',
]);
$user->save();
self::assertEquals([], $node->getAdministrators());
$node->appendAdmin($user);
self::assertEquals(TRUE, $node->isAdmin($user));
// Other user, not so much.
$user2 = User::create([
'name' => 'test2',
'mail' => 'test2@example.com',
]);
$user2->save();
self::assertEquals(FALSE, $node->isAdmin($user2));
}
/**
* Test the notification variations.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment