Implement activity log test

This commit is contained in:
Marcus Moore 2024-10-30 14:25:07 -07:00
parent 0cc3031864
commit d727b03d95
No known key found for this signature in database
3 changed files with 46 additions and 20 deletions

View file

@ -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;
}
}

View file

@ -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();
}
}

View file

@ -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();
}
}