Skip to content

Commit d30738d

Browse files
[12.x] Add comprehensive filesystem operation tests to FilesystemTest (#55399)
* Add test for Filesystem lastModified method * add comprehensive filesystem operation tests Add two new test cases to FilesystemTest.php: - testFileCreationAndContentVerification: Tests file creation, existence check, content verification, and size - testDirectoryOperationsWithSubdirectories: Tests directory creation, subdirectory operations, and file listing These tests complement existing filesystem tests by verifying end-to-end operations and directory structure management.
1 parent a7ce5ca commit d30738d

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tests/Filesystem/FilesystemTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,4 +672,42 @@ private function getFilePermissions($file)
672672

673673
return (int) base_convert($filePerms, 8, 10);
674674
}
675+
676+
public function testFileCreationAndContentVerification()
677+
{
678+
$files = new Filesystem;
679+
680+
$testContent = 'This is a test file content';
681+
$filePath = self::$tempDir.'/test.txt';
682+
683+
$files->put($filePath, $testContent);
684+
685+
$this->assertTrue($files->exists($filePath));
686+
$this->assertSame($testContent, $files->get($filePath));
687+
$this->assertEquals(strlen($testContent), $files->size($filePath));
688+
}
689+
690+
public function testDirectoryOperationsWithSubdirectories()
691+
{
692+
$files = new Filesystem;
693+
694+
$dirPath = self::$tempDir.'/test_dir';
695+
$subDirPath = $dirPath.'/sub_dir';
696+
697+
$this->assertTrue($files->makeDirectory($dirPath));
698+
$this->assertTrue($files->isDirectory($dirPath));
699+
700+
$this->assertTrue($files->makeDirectory($subDirPath));
701+
$this->assertTrue($files->isDirectory($subDirPath));
702+
703+
$filePath = $subDirPath.'/test.txt';
704+
$files->put($filePath, 'test content');
705+
706+
$this->assertTrue($files->exists($filePath));
707+
708+
$allFiles = $files->allFiles($dirPath);
709+
710+
$this->assertCount(1, $allFiles);
711+
$this->assertEquals('test.txt', $allFiles[0]->getFilename());
712+
}
675713
}

0 commit comments

Comments
 (0)