39 lines
1.2 KiB
PHP
39 lines
1.2 KiB
PHP
<?php
|
|
|
|
use App\Livewire\Studio\Catalog\Bottle\Audit;
|
|
use App\Models\Bottle;
|
|
use App\Models\Outlet;
|
|
use Spatie\Permission\Models\Permission;
|
|
use Spatie\Permission\Models\Role;
|
|
|
|
beforeEach(function () {
|
|
$this->setupUser();
|
|
|
|
$role = Role::firstOrCreate(['name' => 'Owner']);
|
|
Permission::firstOrCreate(['name' => 'view bottle']);
|
|
Permission::firstOrCreate(['name' => 'audit bottle']);
|
|
$role->givePermissionTo(['view bottle', 'audit bottle']);
|
|
$this->user->assignRole($role);
|
|
});
|
|
|
|
it('renders the bottle audit page correctly', function () {
|
|
$outlet = Outlet::factory()->create();
|
|
$bottle = Bottle::factory()->create();
|
|
|
|
$this->actingAs($this->user)
|
|
->get(route('studio.catalog.bottle.audit', ['outlet' => $outlet, 'bottle' => $bottle]))
|
|
->assertOk()
|
|
->assertSeeLivewire(Audit::class);
|
|
});
|
|
|
|
it('cannot access bottle audit without permission', function () {
|
|
$outlet = Outlet::factory()->create();
|
|
$bottle = Bottle::factory()->create();
|
|
$this->user->roles()->detach();
|
|
$this->user->permissions()->detach();
|
|
|
|
$this->actingAs($this->user)
|
|
->get(route('studio.catalog.bottle.audit', ['outlet' => $outlet, 'bottle' => $bottle]))
|
|
->assertForbidden();
|
|
});
|