From 5a396cc9979c9fc0280f695788c161d6bcff0dcc Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Wed, 17 Jan 2024 11:24:50 -0800 Subject: [PATCH] Add assertion --- tests/Unit/ReportTemplateTest.php | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/tests/Unit/ReportTemplateTest.php b/tests/Unit/ReportTemplateTest.php index ff36175382..465f167adb 100644 --- a/tests/Unit/ReportTemplateTest.php +++ b/tests/Unit/ReportTemplateTest.php @@ -131,11 +131,6 @@ class ReportTemplateTest extends TestCase $this->assertNull((new ReportTemplate)->selectValue('value_on_unsaved_template', Location::class)); } - public function testSelectValueDoesNotIncludeModelUserDoesNotHaveAccessTo() - { - $this->markTestIncomplete(); - } - public function testSelectValuesDoNotIncludeDeletedOrNonExistentModels() { [$locationA, $locationB] = Location::factory()->count(2)->create(); @@ -160,16 +155,10 @@ class ReportTemplateTest extends TestCase $this->assertNotContains($invalidId, $parsedValues); } - public function testSelectValuesDoesNotIncludeModelUserDoesNotHaveAccessTo() - { - $this->markTestIncomplete(); - } - public function testGracefullyHandlesSingleSelectBecomingMultiSelect() { $department = Department::factory()->create(); - // Given a report template saved with a property that is a string value $templateWithValue = ReportTemplate::factory()->create([ 'options' => ['single_value' => 'a string'], ]); @@ -178,8 +167,15 @@ class ReportTemplateTest extends TestCase 'options' => ['by_dept_id' => $department->id], ]); + // If nothing is selected for a single select then it is stored + // as null and should be returned as an empty array. + $templateWithNull = ReportTemplate::factory()->create([ + 'options' => ['by_dept_id' => null], + ]); + $this->assertEquals(['a string'], $templateWithValue->selectValues('single_value')); $this->assertContains($department->id, $templateWithModelId->selectValues('by_dept_id', Department::class)); + $this->assertEquals([], $templateWithNull->selectValues('by_dept_id')); } public function testGracefullyHandlesMultiSelectBecomingSingleSelectBySelectingTheFirstValue()