Commit 2a07f8ac authored by Viral Solani's avatar Viral Solani

Feature Tests For Permission Module

parent 53183ef9
......@@ -16,3 +16,16 @@ $factory->define(Permission::class, function (Generator $faker) {
'sort' => $faker->numberBetween(1, 100),
];
});
$factory->state(Permission::class, 'active', function () {
return [
'status' => 1,
];
});
$factory->state(Permission::class, 'inactive', function () {
return [
'status' => 0,
];
});
\ No newline at end of file
<?php
namespace Tests\Feature\Backend;
use App\Models\Access\Permission\Permission;
use Illuminate\Support\Facades\Event;
use Tests\TestCase;
class ManagePermissionsTest extends TestCase
{
/** @test */
public function a_user_can_view_permissions()
{
$this->actingAs($this->admin)
->get(route('admin.access.permission.index'))
->assertViewIs('backend.access.permissions.index')
->assertSee(trans('labels.backend.access.permissions.management'))
->assertSee('Export')
->assertSee('Action');
}
/** @test */
public function a_permission_requires_a_name()
{
$permission = make(Permission::class, ['name' => null])->toArray();
return $this->withExceptionHandling()
->actingAs($this->admin)
->post(route('admin.access.permission.store'), $permission)
->assertSessionHasErrors('name');
}
/** @test */
public function a_permission_requires_a_display_name()
{
$permission = make(Permission::class, ['display_name' => null])->toArray();
return $this->withExceptionHandling()
->actingAs($this->admin)
->post(route('admin.access.permission.store'), $permission)
->assertSessionHasErrors('display_name');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment