mirror of
https://github.com/grokability/snipe-it.git
synced 2026-03-12 17:52:00 +08:00
51 lines
1.7 KiB
PHP
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 testRequiresPermission()
|
|
{
|
|
$this->actingAs(User::factory()->create())
|
|
->get(route('report-templates.edit', ReportTemplate::factory()->create()))
|
|
->assertRedirectToRoute('reports/custom');
|
|
}
|
|
|
|
public function testCannotLoadEditPageForAnotherUsersReportTemplate()
|
|
{
|
|
$user = User::factory()->canViewReports()->create();
|
|
$reportTemplate = ReportTemplate::factory()->create();
|
|
|
|
$this->actingAs($user)
|
|
->get(route('report-templates.edit', $reportTemplate))
|
|
->assertRedirectToRoute('reports/custom');
|
|
}
|
|
|
|
public function testCannotLoadEditPageForAnotherUsersSharedReportTemplate()
|
|
{
|
|
$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 testCanLoadEditReportTemplatePage()
|
|
{
|
|
$user = User::factory()->canViewReports()->create();
|
|
$reportTemplate = ReportTemplate::factory()->for($user, 'creator')->create();
|
|
|
|
$this->actingAs($user)
|
|
->get(route('report-templates.edit', $reportTemplate))
|
|
->assertOk();
|
|
}
|
|
}
|