From a9eeabfe45532f64f7ae8b1877680358eeb506da Mon Sep 17 00:00:00 2001 From: cradu Date: Wed, 15 Jan 2025 12:55:07 +0200 Subject: [PATCH] Added more tests --- src/FileDirectory.php | 2 +- tests/IsoFileTest.php | 30 ++++++++++++++++++------------ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/src/FileDirectory.php b/src/FileDirectory.php index 2f0ee52..6e83018 100644 --- a/src/FileDirectory.php +++ b/src/FileDirectory.php @@ -250,7 +250,7 @@ public function loadExtents(IsoFile $isoFile, int $blockSize, bool $supplementar */ public static function loadExtentsSt(IsoFile $isoFile, int $blockSize, int $location, bool $supplementary = false): array|false { - if ($isoFile->seek($location * $blockSize, SEEK_SET) === false) { + if ($isoFile->seek($location * $blockSize, SEEK_SET) === -1) { return false; } diff --git a/tests/IsoFileTest.php b/tests/IsoFileTest.php index d30e548..3a7c60e 100644 --- a/tests/IsoFileTest.php +++ b/tests/IsoFileTest.php @@ -86,6 +86,7 @@ public function testDescriptorsTestIso(): void $rootDirectory = $primaryVolumeDescriptor->rootDirectory; $this->assertSame('.', $rootDirectory->fileId); $this->assertTrue($rootDirectory->isDirectory()); + $this->assertNotNull($rootDirectory->recordingDate); $this->assertSame(Carbon::create(2025, 1, 12, 15, 0, 53, 'Europe/Paris')?->toDateTimeString(), $rootDirectory->recordingDate->toDateTimeString()); // check path table @@ -103,13 +104,15 @@ public function testDescriptorsTestIso(): void // check extents $extents = $pathRecord->loadExtents($isoFile, $primaryVolumeDescriptor->blockSize); - /** @var FileDirectory $extentRecord */ - foreach ($extents as $extentRecord) { - $path = $extentRecord->fileId; - if ($extentRecord->isDirectory()) { - $path .= '/'; + if ($extents !== false) { + /** @var FileDirectory $extentRecord */ + foreach ($extents as $extentRecord) { + $path = $extentRecord->fileId; + if ($extentRecord->isDirectory()) { + $path .= '/'; + } + $paths[$currentPath][] = $path; } - $paths[$currentPath][] = $path; } } @@ -194,6 +197,7 @@ public function testDescriptorsTestDirIso(): void $rootDirectory = $primaryVolumeDescriptor->rootDirectory; $this->assertSame('.', $rootDirectory->fileId); $this->assertTrue($rootDirectory->isDirectory()); + $this->assertNotNull($rootDirectory->recordingDate); $this->assertSame(Carbon::create(2025, 1, 15, 9, 41, 9, 'Europe/Paris')?->toDateTimeString(), $rootDirectory->recordingDate->toDateTimeString()); // check path table @@ -211,13 +215,15 @@ public function testDescriptorsTestDirIso(): void // check extents $extents = $pathRecord->loadExtents($isoFile, $primaryVolumeDescriptor->blockSize); - /** @var FileDirectory $extentRecord */ - foreach ($extents as $extentRecord) { - $path = $extentRecord->fileId; - if ($extentRecord->isDirectory()) { - $path .= '/'; + if ($extents !== false) { + /** @var FileDirectory $extentRecord */ + foreach ($extents as $extentRecord) { + $path = $extentRecord->fileId; + if ($extentRecord->isDirectory()) { + $path .= '/'; + } + $paths[$currentPath][] = $path; } - $paths[$currentPath][] = $path; } }