Update permission tests

This commit is contained in:
Marcus Moore 2024-10-22 14:22:19 -07:00
parent a20e03fce9
commit dd97e4ea82
No known key found for this signature in database
4 changed files with 18 additions and 7 deletions

View file

@ -4,11 +4,12 @@ namespace Tests\Feature\ReportTemplates;
use App\Models\ReportTemplate;
use App\Models\User;
use Tests\Concerns\TestsPermissionsRequirement;
use Tests\TestCase;
class CreateReportTemplateTest extends TestCase
class CreateReportTemplateTest extends TestCase implements TestsPermissionsRequirement
{
public function testSavingReportTemplateRequiresCorrectPermission()
public function testRequiresPermission()
{
$this->actingAs(User::factory()->create())
->post(route('report-templates.store'))

View file

@ -4,11 +4,12 @@ namespace Tests\Feature\ReportTemplates;
use App\Models\ReportTemplate;
use App\Models\User;
use Tests\Concerns\TestsPermissionsRequirement;
use Tests\TestCase;
class DeleteReportTemplateTest extends TestCase
class DeleteReportTemplateTest extends TestCase implements TestsPermissionsRequirement
{
public function testDeletingReportTemplateRequiresCorrectPermission()
public function testRequiresPermission()
{
$this->actingAs(User::factory()->create())
->post(route('report-templates.destroy', 1))

View file

@ -4,10 +4,18 @@ namespace Tests\Feature\ReportTemplates;
use App\Models\ReportTemplate;
use App\Models\User;
use Tests\Concerns\TestsPermissionsRequirement;
use Tests\TestCase;
class ShowReportTemplateTest extends TestCase
class ShowReportTemplateTest extends TestCase implements TestsPermissionsRequirement
{
public function testRequiresPermission()
{
$this->actingAs(User::factory()->create())
->get(route('reports/custom'))
->assertForbidden();
}
public function testCanLoadCustomReportPage()
{
$this->actingAs(User::factory()->canViewReports()->create())

View file

@ -4,11 +4,12 @@ namespace Tests\Feature\ReportTemplates;
use App\Models\ReportTemplate;
use App\Models\User;
use Tests\Concerns\TestsPermissionsRequirement;
use Tests\TestCase;
class UpdateReportTemplateTest extends TestCase
class UpdateReportTemplateTest extends TestCase implements TestsPermissionsRequirement
{
public function testUpdatingReportTemplateRequiresCorrectPermission()
public function testRequiresPermission()
{
$this->actingAs(User::factory()->create())
->post(route('report-templates.update', 1))