Skip to content

Commit 2a07f8a

Browse files
committed
Feature Tests For Permission Module
1 parent 53183ef commit 2a07f8a

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

database/factories/PermissionFactory.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,16 @@
1616
'sort' => $faker->numberBetween(1, 100),
1717
];
1818
});
19+
20+
21+
$factory->state(Permission::class, 'active', function () {
22+
return [
23+
'status' => 1,
24+
];
25+
});
26+
27+
$factory->state(Permission::class, 'inactive', function () {
28+
return [
29+
'status' => 0,
30+
];
31+
});
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace Tests\Feature\Backend;
4+
5+
use App\Models\Access\Permission\Permission;
6+
use Illuminate\Support\Facades\Event;
7+
use Tests\TestCase;
8+
9+
class ManagePermissionsTest extends TestCase
10+
{
11+
/** @test */
12+
public function a_user_can_view_permissions()
13+
{
14+
$this->actingAs($this->admin)
15+
->get(route('admin.access.permission.index'))
16+
->assertViewIs('backend.access.permissions.index')
17+
->assertSee(trans('labels.backend.access.permissions.management'))
18+
->assertSee('Export')
19+
->assertSee('Action');
20+
}
21+
22+
/** @test */
23+
public function a_permission_requires_a_name()
24+
{
25+
$permission = make(Permission::class, ['name' => null])->toArray();
26+
27+
return $this->withExceptionHandling()
28+
->actingAs($this->admin)
29+
->post(route('admin.access.permission.store'), $permission)
30+
->assertSessionHasErrors('name');
31+
}
32+
33+
/** @test */
34+
public function a_permission_requires_a_display_name()
35+
{
36+
$permission = make(Permission::class, ['display_name' => null])->toArray();
37+
38+
return $this->withExceptionHandling()
39+
->actingAs($this->admin)
40+
->post(route('admin.access.permission.store'), $permission)
41+
->assertSessionHasErrors('display_name');
42+
}
43+
}

0 commit comments

Comments
 (0)