Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohammad-Alavi committed Oct 3, 2021
1 parent fa0bd0e commit 452a4c7
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function run(string $name, string $description = null, string $displayNam

try {
$permission = $this->repository->create([
'name' => $name,
'name' => strtolower($name),
'description' => $description,
'display_name' => $displayName,
'guard_name' => 'web',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace App\Containers\AppSection\Authorization\Tests\Unit;

use App\Containers\AppSection\Authorization\Tasks\CreatePermissionTask;
use App\Containers\AppSection\Authorization\Tests\TestCase;

/**
* Class CreatePermissionTaskTest.
*
* @group authorization
* @group unit
*/
class CreatePermissionTaskTest extends TestCase
{
public function testCreatePermission(): void
{
$name = 'fuLl_coNtroL';
$description = 'Gives full control of everything!';
$display_name = 'Controller of All';

$permission = app(CreatePermissionTask::class)->run($name, $description, $display_name);

$this->assertEquals(strtolower($name), $permission->name);
$this->assertEquals($description, $permission->description);
$this->assertEquals($display_name, $permission->display_name);
$this->assertEquals('web', $permission->guard_name);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace App\Containers\AppSection\Authorization\Tests\Unit;

use App\Containers\AppSection\Authorization\Tasks\CreateRoleTask;
use App\Containers\AppSection\Authorization\Tests\TestCase;

/**
* Class CreateRoleTaskTest.
*
* @group authorization
* @group unit
*/
class CreateRoleTaskTest extends TestCase
{
public function testCreateRole(): void
{
$name = 'MEga_AdmIn';
$description = 'The One above all';
$display_name = 'Mega Admin the Almighty';

$role = app(CreateRoleTask::class)->run($name, $description, $display_name);

$this->assertEquals(strtolower($name), $role->name);
$this->assertEquals($description, $role->description);
$this->assertEquals($display_name, $role->display_name);
$this->assertEquals('web', $role->guard_name);
}
}

0 comments on commit 452a4c7

Please sign in to comment.