From 35f8a71c71ec6c9b19f1c19a7bd9c9d942e60906 Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Tue, 29 Oct 2024 16:17:12 -0700 Subject: [PATCH] Test organization --- .../ReportTemplateParsingValuesTest.php} | 24 ++------------ .../ReportTemplateScopingTest.php | 31 +++++++++++++++++++ 2 files changed, 33 insertions(+), 22 deletions(-) rename tests/Unit/Models/{ReportTemplateTest.php => ReportTemplates/ReportTemplateParsingValuesTest.php} (89%) create mode 100644 tests/Unit/Models/ReportTemplates/ReportTemplateScopingTest.php diff --git a/tests/Unit/Models/ReportTemplateTest.php b/tests/Unit/Models/ReportTemplates/ReportTemplateParsingValuesTest.php similarity index 89% rename from tests/Unit/Models/ReportTemplateTest.php rename to tests/Unit/Models/ReportTemplates/ReportTemplateParsingValuesTest.php index 240b8d3892..2973b3b808 100644 --- a/tests/Unit/Models/ReportTemplateTest.php +++ b/tests/Unit/Models/ReportTemplates/ReportTemplateParsingValuesTest.php @@ -1,36 +1,16 @@ create(['name' => 'Report A']); - - // When loading reports/custom while acting as another user that also has a saved template - $user = User::factory()->canViewReports() - ->has(ReportTemplate::factory(['name' => 'Report B'])) - ->create(); - - // The user should not see the other user's template (in view as 'report_templates') - $this->actingAs($user) - ->get(route('reports/custom')) - ->assertViewHas(['report_templates' => function (Collection $reports) { - return $reports->pluck('name')->doesntContain('Report A'); - }]); - } - public function testParsingValuesOnNonExistentReportTemplate() { $unsavedTemplate = new ReportTemplate; diff --git a/tests/Unit/Models/ReportTemplates/ReportTemplateScopingTest.php b/tests/Unit/Models/ReportTemplates/ReportTemplateScopingTest.php new file mode 100644 index 0000000000..67052f7d4f --- /dev/null +++ b/tests/Unit/Models/ReportTemplates/ReportTemplateScopingTest.php @@ -0,0 +1,31 @@ +create(['name' => 'Report A']); + + // When loading reports/custom while acting as another user that also has a saved template + $user = User::factory()->canViewReports() + ->has(ReportTemplate::factory(['name' => 'Report B'])) + ->create(); + + // The user should not see the other user's template (in view as 'report_templates') + $this->actingAs($user) + ->get(route('reports/custom')) + ->assertViewHas(['report_templates' => function (Collection $reports) { + return $reports->pluck('name')->doesntContain('Report A'); + }]); + } +}