From 2711e8b1fed340a8d83bfc4daccdf3e0eb933490 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Tournayre?= Date: Mon, 24 Nov 2025 23:09:45 +0100 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=A8=20feat(wrapper):=20enhance=20SplF?= =?UTF-8?q?ileInfo=20toLog()=20method=20with=20comprehensive=20file=20info?= =?UTF-8?q?rmation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add detailed logging support with filename, extension, size, relativePath, and relativePathname --- src/Wrapper/SplFileInfo.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Wrapper/SplFileInfo.php b/src/Wrapper/SplFileInfo.php index 1dac665..52619fa 100644 --- a/src/Wrapper/SplFileInfo.php +++ b/src/Wrapper/SplFileInfo.php @@ -40,8 +40,11 @@ public static function of(string $file, string $relativePath, string $relativePa public function toLog(): array { return [ - 'pathname' => $this->pathname(), + 'filename' => $this->filename()->toString(), + 'extension' => $this->extension()->toString(), 'size' => $this->size()->humanReadable(), + 'relativePath' => $this->relativePath()->toString(), + 'relativePathname' => $this->relativePathname()->toString(), ]; } From 8e55f37423bb95ccc8780adb5705408fd707189c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Tournayre?= Date: Mon, 24 Nov 2025 23:09:53 +0100 Subject: [PATCH 2/2] =?UTF-8?q?=E2=9C=85=20test(wrapper):=20add=20comprehe?= =?UTF-8?q?nsive=20unit=20tests=20for=20SplFileInfo=20toLog()=20method?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add 13 unit tests covering array structure, data types, and values validation --- tests/Unit/Wrapper/SplFileInfoTest.php | 102 +++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 tests/Unit/Wrapper/SplFileInfoTest.php diff --git a/tests/Unit/Wrapper/SplFileInfoTest.php b/tests/Unit/Wrapper/SplFileInfoTest.php new file mode 100644 index 0000000..c8fabf1 --- /dev/null +++ b/tests/Unit/Wrapper/SplFileInfoTest.php @@ -0,0 +1,102 @@ +toLog(); + self::assertArrayHasKey('filename', $result, 'toLog() must contain filename key'); + } + + public function testToLogReturnsArrayWithExtensionKey(): void + { + $file = SplFileInfo::of(__FILE__, '', ''); + $result = $file->toLog(); + self::assertArrayHasKey('extension', $result, 'toLog() must contain extension key'); + } + + public function testToLogReturnsArrayWithSizeKey(): void + { + $file = SplFileInfo::of(__FILE__, '', ''); + $result = $file->toLog(); + self::assertArrayHasKey('size', $result, 'toLog() must contain size key'); + } + + public function testToLogReturnsArrayWithRelativePathKey(): void + { + $file = SplFileInfo::of(__FILE__, '', ''); + $result = $file->toLog(); + self::assertArrayHasKey('relativePath', $result, 'toLog() must contain relativePath key'); + } + + public function testToLogReturnsArrayWithRelativePathnameKey(): void + { + $file = SplFileInfo::of(__FILE__, '', ''); + $result = $file->toLog(); + self::assertArrayHasKey('relativePathname', $result, 'toLog() must contain relativePathname key'); + } + + public function testToLogFilenameIsString(): void + { + $file = SplFileInfo::of(__FILE__, '', ''); + $result = $file->toLog(); + self::assertIsString($result['filename'], 'filename must be a string'); + } + + public function testToLogExtensionIsString(): void + { + $file = SplFileInfo::of(__FILE__, '', ''); + $result = $file->toLog(); + self::assertIsString($result['extension'], 'extension must be a string'); + } + + public function testToLogSizeIsString(): void + { + $file = SplFileInfo::of(__FILE__, '', ''); + $result = $file->toLog(); + self::assertIsString($result['size'], 'size must be a string'); + } + + public function testToLogRelativePathIsString(): void + { + $file = SplFileInfo::of(__FILE__, '', ''); + $result = $file->toLog(); + self::assertIsString($result['relativePath'], 'relativePath must be a string'); + } + + public function testToLogRelativePathnameIsString(): void + { + $file = SplFileInfo::of(__FILE__, '', ''); + $result = $file->toLog(); + self::assertIsString($result['relativePathname'], 'relativePathname must be a string'); + } + + public function testToLogFilenameMatchesActualFilename(): void + { + $file = SplFileInfo::of(__FILE__, '', ''); + $result = $file->toLog(); + self::assertEquals('SplFileInfoTest.php', $result['filename'], 'filename must match actual filename'); + } + + public function testToLogExtensionMatchesActualExtension(): void + { + $file = SplFileInfo::of(__FILE__, '', ''); + $result = $file->toLog(); + self::assertEquals('php', $result['extension'], 'extension must match php'); + } + + public function testToLogSizeContainsUnit(): void + { + $file = SplFileInfo::of(__FILE__, '', ''); + $result = $file->toLog(); + self::assertMatchesRegularExpression('/\d+(\.\d+)?\s*(B|KB|MB|GB)/', $result['size'], 'size must contain unit'); + } +}