Skip to content

Commit

Permalink
Fix workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
MGatner committed Jul 12, 2022
1 parent 1f75185 commit 0f6054f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rector.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ jobs:
- name: Analyze for refactoring
run: |
composer global require --dev rector/rector:^0.12.16
composer global require --dev rector/rector:^0.13.8
rector process --dry-run --no-progress-bar
7 changes: 6 additions & 1 deletion deptrac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ parameters:
Service:
- Config
- Vendor Config

# Ignore anything in the Vendor layers
Vendor Model:
- Config
Expand Down Expand Up @@ -154,3 +154,8 @@ parameters:
- Vendor Model
- Vendor View
skip_violations:
Myth\Auth\Config\Services:
- Myth\Auth\Authorization\GroupModel
- Myth\Auth\Authorization\PermissionModel
- Myth\Auth\Models\LoginModel
- Myth\Auth\Models\UserModel
35 changes: 17 additions & 18 deletions src/Commands/ListUsers.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php namespace Myth\Auth\Commands;
<?php

namespace Myth\Auth\Commands;

use CodeIgniter\CLI\BaseCommand;
use CodeIgniter\CLI\CLI;
Expand All @@ -12,22 +14,19 @@ class ListUsers extends BaseCommand

public function run(array $params)
{
$db = db_connect();
// get all groups
$rows = $db->table('users')
->select('id, username, email')
->orderBy('id', 'asc')
->get()->getResultArray();
$db = db_connect();

// get all groups
$rows = $db->table('users')
->select('id, username, email')
->orderBy('id', 'asc')
->get()->getResultArray();

if (empty($rows))
{
CLI::write( CLI::color("There are no users.", 'yellow') );
}
else
{
$thead = ['User ID', 'Username', 'E-Mail'];
CLI::table($rows, $thead);
}
}
if (empty($rows)) {
CLI::write(CLI::color('There are no users.', 'yellow'));
} else {
$thead = ['User ID', 'Username', 'E-Mail'];
CLI::table($rows, $thead);
}
}
}
20 changes: 11 additions & 9 deletions tests/authorization/FlatAuthorizationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ public function testHasPermissionIdGroup()
$this->groups->addUserToGroup($user->id, $group->id);

$this->assertFalse($this->auth->hasPermission($permission->id, $user->id));
cache()->clean();

$this->groups->addPermissionToGroup($permission->id, $group->id);

Expand All @@ -121,6 +122,7 @@ public function testHasPermissionNameGroup()
$this->groups->addUserToGroup($user->id, $group->id);

$this->assertFalse($this->auth->hasPermission($permission->name, $user->id));
cache()->clean();

$this->groups->addPermissionToGroup($permission->id, $group->id);

Expand Down Expand Up @@ -347,19 +349,19 @@ public function testGetPermissionsForUser()
$this->auth->addPermissionToGroup($permission2->id, $group->id); // groups permission
$this->auth->addUserToGroup($user->id, $group->id);

$expected = [
$permission->id => $permission->name,
$permission2->id => $permission2->name,
$expectedNames = [
$permission->name,
$permission2->name,
];
$expectedIds = [
$permission->id,
$permission2->id,
];

$actual = $this->permissions->getPermissionsForUser($user->id);

$this->assertEqualsCanonicalizing($expected, $actual);

$this->assertArrayHasKey($permission->id, $actual);
$this->assertArrayHasKey($permission2->id, $actual);
$this->assertArrayNotHasKey(9999, $actual);
$this->assertCount(2, $actual);
$this->assertEqualsCanonicalizing($expectedNames, $actual);
$this->assertEqualsCanonicalizing($expectedIds, array_keys($actual));
}

public function testDoesUserHavePermission()
Expand Down

0 comments on commit 0f6054f

Please sign in to comment.