Skip to content

Commit

Permalink
changed setAssignments to work with comma separated string
Browse files Browse the repository at this point in the history
  • Loading branch information
hiqsol committed Nov 10, 2016
1 parent 84c6b5a commit c015235
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/SetterTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,14 @@ public function setAssignment($item, $userId)

/**
* Assigns items to a user.
* @param array $items
* @param string|array $items
* @param string|integer $userId
*/
public function setAssignments(array $items, $userId)
public function setAssignments($items, $userId)
{
if (is_string($items)) {
$items = explode(',', $items);
}
foreach ($items as $item) {
$this->setAssignment($item, $userId);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/CheckAccessTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function testPermission()

public function testMighty()
{
$this->auth->setAssignments(['role:admin', 'role:manager', 'bill.create', 'domain.freeze'], 'user:mighty');
$this->auth->setAssignments('role:admin,role:manager,bill.create,domain.freeze', 'user:mighty');

$this->assertTrue ($this->auth->checkAccess('user:mighty', 'support'));
$this->assertTrue ($this->auth->checkAccess('user:mighty', 'manage'));
Expand Down

0 comments on commit c015235

Please sign in to comment.