Skip to content

A free open source IT asset/license management system

Implement activity log test

Marcus Moored727b03d954d
diff --git a/app/Models/ReportTemplate.php b/app/Models/ReportTemplate.php
index e0f8d3da47..f3537662f1 100644
--- a/app/Models/ReportTemplate.php
+++ b/app/Models/ReportTemplate.php
@@ -230,4 +230,9 @@ class ReportTemplate extends Model
// and return the default value if not.
return $this->options[$fieldName] ?? '';
}
+
+ public function getDisplayNameAttribute()
+ {
+ return $this->name;
+ }
}
diff --git a/tests/Unit/ActionLogTransformer/ReportTemplateActionLogTransformerTest.php b/tests/Unit/ActionLogTransformer/ReportTemplateActionLogTransformerTest.php
new file mode 100644
index 0000000000..37d2efabdf
--- /dev/null
+++ b/tests/Unit/ActionLogTransformer/ReportTemplateActionLogTransformerTest.php
@@ -0,0 +1,41 @@
+<?php
+
+namespace Tests\Unit\ActionLogTransformer;
+
+use App\Http\Transformers\ActionlogsTransformer;
+use App\Models\Actionlog;
+use App\Models\ReportTemplate;
+use Tests\TestCase;
+
+class ReportTemplateActionLogTransformerTest extends TestCase
+{
+ public function testLogEntryForCreatingReportTemplateCanBeTransformed()
+ {
+ ReportTemplate::factory()->create();
+
+ $actionLogs = Actionlog::whereMorphedTo('item', ReportTemplate::class)->get();
+
+ // should be created when ActionLog is created
+ $this->assertCount(1, $actionLogs);
+
+ $results = (new ActionlogsTransformer())->transformActionlogs($actionLogs, 10);
+
+ $this->assertArrayHasKey('rows', $results);
+ $this->assertCount(1, $results['rows']);
+ }
+
+ public function testLogEntryForUpdatingReportTemplateCanBeDisplayedTransformed()
+ {
+ $this->markTestIncomplete();
+ }
+
+ public function testLogEntryForDeletingReportTemplateCanBeDisplayedTransformed()
+ {
+ $this->markTestIncomplete();
+ }
+
+ public function testLogsScopedProperly()
+ {
+ $this->markTestIncomplete();
+ }
+}
diff --git a/tests/Unit/Models/ReportTemplates/ReportTemplateActivityLoggingTest.php b/tests/Unit/Models/ReportTemplates/ReportTemplateActivityLoggingTest.php
index c46040b5c8..de67c50c44 100644
--- a/tests/Unit/Models/ReportTemplates/ReportTemplateActivityLoggingTest.php
+++ b/tests/Unit/Models/ReportTemplates/ReportTemplateActivityLoggingTest.php
@@ -38,11 +38,6 @@ class ReportTemplateActivityLoggingTest extends TestCase
]);
}
- public function testLogEntryForCreatingReportTemplateCanBeDisplayed()
- {
- $this->markTestIncomplete('Updates to ActionlogsTransformer needed');
- }
-
public function testUpdatingReportTemplateIsLogged()
{
$reportTemplate = ReportTemplate::factory()->create([
@@ -137,11 +132,6 @@ class ReportTemplateActivityLoggingTest extends TestCase
]);
}
- public function testLogEntryForUpdatingReportTemplateCanBeDisplayedCorrectly()
- {
- $this->markTestIncomplete();
- }
-
public function testDeletingReportTemplateIsLogged()
{
$user = User::factory()->create();
@@ -169,14 +159,4 @@ class ReportTemplateActivityLoggingTest extends TestCase
'item_id' => $reportTemplateB->id,
]);
}
-
- public function testLogEntryForDeletingReportTemplateCanBeDisplayedCorrectly()
- {
- $this->markTestIncomplete();
- }
-
- public function testLogsScopedProperly()
- {
- $this->markTestIncomplete();
- }
}