2024-10-22 17:50:40 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Feature\ReportTemplates;
|
|
|
|
|
|
|
|
use App\Models\ReportTemplate;
|
|
|
|
use App\Models\User;
|
2024-10-28 14:42:44 -07:00
|
|
|
use PHPUnit\Framework\Attributes\Group;
|
2024-10-22 17:50:40 -07:00
|
|
|
use Tests\Concerns\TestsPermissionsRequirement;
|
|
|
|
use Tests\TestCase;
|
|
|
|
|
2024-10-28 14:42:44 -07:00
|
|
|
#[Group('custom-reporting')]
|
2024-10-22 17:50:40 -07:00
|
|
|
class EditReportTemplateTest extends TestCase implements TestsPermissionsRequirement
|
|
|
|
{
|
|
|
|
public function testRequiresPermission()
|
|
|
|
{
|
|
|
|
$this->actingAs(User::factory()->create())
|
2024-11-07 16:54:55 -08:00
|
|
|
->get(route('report-templates.edit', ReportTemplate::factory()->create()))
|
2024-10-31 12:34:06 -07:00
|
|
|
->assertNotFound();
|
2024-10-22 17:50:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testCannotLoadEditPageForAnotherUsersReportTemplate()
|
|
|
|
{
|
|
|
|
$user = User::factory()->canViewReports()->create();
|
|
|
|
$reportTemplate = ReportTemplate::factory()->create();
|
|
|
|
|
|
|
|
$this->actingAs($user)
|
2024-11-07 16:54:55 -08:00
|
|
|
->get(route('report-templates.edit', $reportTemplate))
|
2024-10-31 12:34:06 -07:00
|
|
|
->assertNotFound();
|
2024-10-22 17:50:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testCanLoadEditReportTemplatePage()
|
|
|
|
{
|
|
|
|
$user = User::factory()->canViewReports()->create();
|
2024-10-23 16:40:03 -07:00
|
|
|
$reportTemplate = ReportTemplate::factory()->for($user, 'creator')->create();
|
2024-10-22 17:50:40 -07:00
|
|
|
|
|
|
|
$this->actingAs($user)
|
2024-11-07 16:54:55 -08:00
|
|
|
->get(route('report-templates.edit', $reportTemplate))
|
2024-10-22 17:50:40 -07:00
|
|
|
->assertOk();
|
|
|
|
}
|
|
|
|
}
|