From e46e7e5f9cc32b650fbfadabbd7ba376e6cc293a Mon Sep 17 00:00:00 2001 From: Thorsten Bus Date: Mon, 30 Mar 2026 08:03:54 +0200 Subject: [PATCH] fix(generator): set slide size and PresentationSlide chordChart --- php/tests/ProFileGeneratorTest.php | 102 +++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/php/tests/ProFileGeneratorTest.php b/php/tests/ProFileGeneratorTest.php index e41d6a7..4941238 100644 --- a/php/tests/ProFileGeneratorTest.php +++ b/php/tests/ProFileGeneratorTest.php @@ -755,4 +755,106 @@ class ProFileGeneratorTest extends TestCase $presentationSlide = $action->getSlide()->getPresentation(); $this->assertNotNull($presentationSlide->getChordChart()); } + + #[Test] + public function testBuildLocalRelativePathMappedDirectory(): void + { + // Test: Known directory mapping (Downloads) → ROOT_USER_DOWNLOADS with correct relative path + $song = ProFileGenerator::generate( + 'Mapped Path Test', + [ + [ + 'name' => 'V1', + 'color' => [0, 0, 0, 1], + 'slides' => [ + [ + 'media' => 'file:///Users/testuser/Downloads/test-image.jpg', + 'format' => 'JPG', + ], + ], + ], + ], + [ + ['name' => 'normal', 'groupNames' => ['V1']], + ], + ); + + // Navigate to the first slide's media action + $cue = $song->getPresentation()->getCues()[0]; + $action = $cue->getActions()[0]; // media action + $url = $action->getMedia()->getUrl(); + + $this->assertNotNull($url); + $this->assertNotNull($url->getLocal()); + $this->assertSame(4, $url->getLocal()->getRoot()); // ROOT_USER_DOWNLOADS = 4 + $this->assertSame('test-image.jpg', $url->getLocal()->getPath()); + } + + #[Test] + public function testBuildLocalRelativePathUnmappedUserDirectory(): void + { + // Test: Unmapped user directory (AI) → ROOT_USER_HOME with full relative path + $song = ProFileGenerator::generate( + 'Unmapped Path Test', + [ + [ + 'name' => 'V1', + 'color' => [0, 0, 0, 1], + 'slides' => [ + [ + 'media' => 'file:///Users/thorsten/AI/propresenter/ref/Media/test.png', + 'format' => 'PNG', + ], + ], + ], + ], + [ + ['name' => 'normal', 'groupNames' => ['V1']], + ], + ); + + // Navigate to the first slide's media action + $cue = $song->getPresentation()->getCues()[0]; + $action = $cue->getActions()[0]; // media action + $url = $action->getMedia()->getUrl(); + + $this->assertNotNull($url); + $this->assertNotNull($url->getLocal()); + $this->assertSame(2, $url->getLocal()->getRoot()); // ROOT_USER_HOME = 2 + $this->assertSame('AI/propresenter/ref/Media/test.png', $url->getLocal()->getPath()); + } + + #[Test] + public function testBuildLocalRelativePathNonUserPath(): void + { + // Test: Non-user path (tmp) → ROOT_BOOT_VOLUME with full path + $song = ProFileGenerator::generate( + 'Non-User Path Test', + [ + [ + 'name' => 'V1', + 'color' => [0, 0, 0, 1], + 'slides' => [ + [ + 'media' => 'file:///tmp/test-image.jpg', + 'format' => 'JPG', + ], + ], + ], + ], + [ + ['name' => 'normal', 'groupNames' => ['V1']], + ], + ); + + // Navigate to the first slide's media action + $cue = $song->getPresentation()->getCues()[0]; + $action = $cue->getActions()[0]; // media action + $url = $action->getMedia()->getUrl(); + + $this->assertNotNull($url); + $this->assertNotNull($url->getLocal()); + $this->assertSame(1, $url->getLocal()->getRoot()); // ROOT_BOOT_VOLUME = 1 + $this->assertSame('tmp/test-image.jpg', $url->getLocal()->getPath()); + } }