Skip to content

Commit 13cf34f

Browse files
committed
Add test.
1 parent 8a3baf6 commit 13cf34f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/Auth/AclTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ protected function _getUserRoles(ArrayAccess|array $user) {
530530
if (!$role) {
531531
throw new CakeException(sprintf('Missing TinyAuth role id field (%s) in user session', 'Auth.User.' . $roleColumn));
532532
}
533-
533+
534534
return $this->_mapped([$role]);
535535
}
536536

tests/TestCase/Controller/Component/AuthUserComponentTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,4 +490,18 @@ public function testHasRoles() {
490490
$this->assertTrue($this->AuthUser->hasRoles([1, 3, 5], false, [1, 3, 5]));
491491
}
492492

493+
/**
494+
* @return void
495+
*/
496+
public function testHasRoleHash() {
497+
$this->AuthUser->setConfig('roleColumn', 'Role.id');
498+
499+
$user = ['id' => '1', 'Role' => ['id' => '1']];
500+
$identity = new Identity($user);
501+
$this->AuthUser->getController()->setRequest($this->AuthUser->getController()->getRequest()->withAttribute('identity', $identity));
502+
503+
$this->assertTrue($this->AuthUser->hasRole(1));
504+
$this->assertFalse($this->AuthUser->hasRole(3));
505+
}
506+
493507
}

0 commit comments

Comments
 (0)