3
0
mirror of https://github.com/snipe/snipe-it.git synced 2026-04-03 06:20:22 +00:00
Files
snipe-it/tests/Feature/ReportTemplates/EditReportTemplateTest.php
2026-03-16 17:40:57 -07:00

51 lines
1.7 KiB
PHP

<?php
namespace Tests\Feature\ReportTemplates;
use App\Models\ReportTemplate;
use App\Models\User;
use PHPUnit\Framework\Attributes\Group;
use Tests\Concerns\TestsPermissionsRequirement;
use Tests\TestCase;
#[Group('custom-reporting')]
class EditReportTemplateTest extends TestCase implements TestsPermissionsRequirement
{
public function test_requires_permission()
{
$this->actingAs(User::factory()->create())
->get(route('report-templates.edit', ReportTemplate::factory()->create()))
->assertRedirectToRoute('reports/custom');
}
public function test_cannot_load_edit_page_for_another_users_report_template()
{
$user = User::factory()->canViewReports()->create();
$reportTemplate = ReportTemplate::factory()->create();
$this->actingAs($user)
->get(route('report-templates.edit', $reportTemplate))
->assertRedirectToRoute('reports/custom');
}
public function test_cannot_load_edit_page_for_another_users_shared_report_template()
{
$user = User::factory()->canViewReports()->create();
$reportTemplate = ReportTemplate::factory()->shared()->create();
$this->actingAs($user)
->get(route('report-templates.edit', $reportTemplate))
->assertRedirectToRoute('report-templates.show', $reportTemplate->id);
}
public function test_can_load_edit_report_template_page()
{
$user = User::factory()->canViewReports()->create();
$reportTemplate = ReportTemplate::factory()->for($user, 'creator')->create();
$this->actingAs($user)
->get(route('report-templates.edit', $reportTemplate))
->assertOk();
}
}