Skip to content

Commit

Permalink
Added more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cradu committed Jan 15, 2025
1 parent e977714 commit a9eeabf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/FileDirectory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
30 changes: 18 additions & 12 deletions tests/IsoFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
}
}

Expand Down Expand Up @@ -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
Expand All @@ -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;
}
}

Expand Down

0 comments on commit a9eeabf

Please sign in to comment.