Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add media import/export assertions to ScreenTemplateTest
  • Loading branch information
mcraeteisha committed Sep 21, 2026
commit a8b2baf3472b6f74ab640920ff6cc69daf920a44
17 changes: 17 additions & 0 deletions tests/Feature/Templates/Api/ScreenTemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,13 @@ public function testImportExportScreenTemplate()
{
$adminUser = User::factory()->create();
$screenTemplate = ScreenTemplates::factory()->create(['name' => 'ScreenTemplate', 'user_id' => $adminUser->id]);
$mediaCollection = 'st-' . $screenTemplate->uuid . '-media';
$screenTemplate->media_collection = $mediaCollection;
$screenTemplate->save();
$screenTemplate->addMedia(UploadedFile::fake()->image('thumbnail.png'))
->withCustomProperties(['media_type' => 'thumbnail'])
->toMediaCollection($mediaCollection);

$payload = $this->export($screenTemplate, ScreenTemplatesExporter::class);
$screenTemplate->delete();
$this->assertDatabaseMissing('screen_templates', ['name' => $screenTemplate->name]);
Expand All @@ -346,6 +353,16 @@ public function testImportExportScreenTemplate()
$this->assertDatabaseHas('screen_templates', ['name' => $screenTemplate->name]);
$importedTemplate = ScreenTemplates::where('name', $screenTemplate->name)->first();
$this->assertEquals($actingAsUser->id, $importedTemplate->user_id);

$importedCollection = 'st-' . $importedTemplate->uuid . '-media';
$this->assertEquals($importedCollection, $importedTemplate->media_collection);
$this->assertCount(1, $importedTemplate->getMedia($importedCollection));

$templateMedia = $importedTemplate->template_media;
$this->assertNotEmpty($templateMedia['thumbnail']);
$this->assertNotEmpty($templateMedia['thumbnail']->url);
$this->assertNotFalse(filter_var($templateMedia['thumbnail']->url, FILTER_VALIDATE_URL));
$this->assertFileExists($importedTemplate->getMedia($importedCollection)->first()->getPath());
}

public function testImportExportScreenTemplatesRoutes()
Expand Down
Loading