mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 14:27:33 -08:00
Improve tests
This commit is contained in:
parent
3d28a9090c
commit
4217d7402b
43
tests/Feature/ReportTemplates/EditReportTemplateTest.php
Normal file
43
tests/Feature/ReportTemplates/EditReportTemplateTest.php
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature\ReportTemplates;
|
||||||
|
|
||||||
|
use App\Models\ReportTemplate;
|
||||||
|
use App\Models\User;
|
||||||
|
use Tests\Concerns\TestsPermissionsRequirement;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class EditReportTemplateTest extends TestCase implements TestsPermissionsRequirement
|
||||||
|
{
|
||||||
|
public function testRequiresPermission()
|
||||||
|
{
|
||||||
|
$this->markTestIncomplete('Returning 404 instead of 403...');
|
||||||
|
|
||||||
|
$this->actingAs(User::factory()->create())
|
||||||
|
->get(route('report-templates.edit', ReportTemplate::factory()->create()))
|
||||||
|
->assertForbidden();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCannotLoadEditPageForAnotherUsersReportTemplate()
|
||||||
|
{
|
||||||
|
$this->markTestIncomplete('Returns 404...');
|
||||||
|
|
||||||
|
$user = User::factory()->canViewReports()->create();
|
||||||
|
$reportTemplate = ReportTemplate::factory()->create();
|
||||||
|
|
||||||
|
$this->actingAs($user)
|
||||||
|
->get(route('report-templates.edit', $reportTemplate))
|
||||||
|
->assertSessionHas('error')
|
||||||
|
->assertRedirect(route('reports/custom'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCanLoadEditReportTemplatePage()
|
||||||
|
{
|
||||||
|
$user = User::factory()->canViewReports()->create();
|
||||||
|
$reportTemplate = ReportTemplate::factory()->for($user)->create();
|
||||||
|
|
||||||
|
$this->actingAs($user)
|
||||||
|
->get(route('report-templates.edit', $reportTemplate))
|
||||||
|
->assertOk();
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,18 +12,16 @@ class UpdateReportTemplateTest extends TestCase implements TestsPermissionsRequi
|
||||||
public function testRequiresPermission()
|
public function testRequiresPermission()
|
||||||
{
|
{
|
||||||
$this->actingAs(User::factory()->create())
|
$this->actingAs(User::factory()->create())
|
||||||
->post(route('report-templates.update', 1))
|
->post(route('report-templates.update', ReportTemplate::factory()->create()))
|
||||||
->assertForbidden();
|
->assertForbidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCanLoadEditReportTemplatePage()
|
public function testCannotUpdateAnotherUsersReportTemplate()
|
||||||
{
|
{
|
||||||
$user = User::factory()->canViewReports()->create();
|
$this->actingAs(User::factory()->canViewReports()->create())
|
||||||
$reportTemplate = ReportTemplate::factory()->for($user)->create();
|
->post(route('report-templates.update', ReportTemplate::factory()->create()))
|
||||||
|
->assertSessionHas('error')
|
||||||
$this->actingAs($user)
|
->assertRedirect(route('reports/custom'));
|
||||||
->get(route('report-templates.edit', $reportTemplate))
|
|
||||||
->assertOk();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCanUpdateAReportTemplate()
|
public function testCanUpdateAReportTemplate()
|
||||||
|
|
Loading…
Reference in a new issue