From 4aedbb52fa0ca2756a9f8aea6b16eb38e7a2553b Mon Sep 17 00:00:00 2001 From: Marcus Moore Date: Thu, 31 Oct 2024 12:15:05 -0700 Subject: [PATCH] Implement activity logging transformer tests --- ...ReportTemplateActionLogTransformerTest.php | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/tests/Unit/ActionLogTransformer/ReportTemplateActionLogTransformerTest.php b/tests/Unit/ActionLogTransformer/ReportTemplateActionLogTransformerTest.php index 829a4b8301..b6f67d741e 100644 --- a/tests/Unit/ActionLogTransformer/ReportTemplateActionLogTransformerTest.php +++ b/tests/Unit/ActionLogTransformer/ReportTemplateActionLogTransformerTest.php @@ -28,16 +28,41 @@ class ReportTemplateActionLogTransformerTest extends TestCase public function testLogEntryForUpdatingReportTemplateCanBeDisplayedTransformed() { - $this->markTestIncomplete(); + $reportTemplate = ReportTemplate::factory()->create(); + + $reportTemplate->update([ + 'options' => ['new' => 'value'] + ]); + + $actionLogs = Actionlog::query() + ->whereMorphedTo('item', ReportTemplate::class) + ->where('action_type', 'update') + ->get(); + + $this->assertCount(1, $actionLogs); + + $results = (new ActionlogsTransformer())->transformActionlogs($actionLogs, 10); + + $this->assertArrayHasKey('rows', $results); + $this->assertCount(1, $results['rows']); } public function testLogEntryForDeletingReportTemplateCanBeDisplayedTransformed() { - $this->markTestIncomplete(); - } + $reportTemplate = ReportTemplate::factory()->create(); - public function testLogsScopedProperly() - { - $this->markTestIncomplete(); + $reportTemplate->delete(); + + $actionLogs = Actionlog::query() + ->whereMorphedTo('item', ReportTemplate::class) + ->where('action_type', 'delete') + ->get(); + + $this->assertCount(1, $actionLogs); + + $results = (new ActionlogsTransformer())->transformActionlogs($actionLogs, 10); + + $this->assertArrayHasKey('rows', $results); + $this->assertCount(1, $results['rows']); } }