1717use PHPUnit \Framework \TestCase ;
1818
1919#[CoversClass(Filesystem::class)]
20- class FilesystemTest extends TestCase {
20+ class FilesystemTest extends TestCase
21+ {
2122 private ?string $ tempDir ;
2223 private FilesystemInterface $ filesystem ;
2324
24- protected function setUp (): void {
25+ protected function setUp (): void
26+ {
2527 $ this ->filesystem = new Filesystem ();
2628 $ this ->tempDir = sys_get_temp_dir () . DIRECTORY_SEPARATOR . 'tmp ' ;
2729 $ this ->filesystem ->mkdir ($ this ->tempDir );
2830 }
2931
30- protected function tearDown (): void {
32+ protected function tearDown (): void
33+ {
3134 if ($ this ->filesystem ->exists ($ this ->tempDir )) {
3235 $ this ->filesystem ->rmdir ($ this ->tempDir );
3336 }
3437
3538 $ this ->tempDir = null ;
3639 }
3740
38- public function testFileExists (): void {
41+ public function testFileExists (): void
42+ {
3943 $ basePath = $ this ->tempDir . DIRECTORY_SEPARATOR ;
4044 $ this ->filesystem ->touch ($ basePath . 'file.txt ' );
4145
4246 self ::assertFalse ($ this ->filesystem ->exists ($ basePath . 'file122.txt ' ));
4347 self ::assertTrue ($ this ->filesystem ->exists ($ basePath . 'file.txt ' ));
4448 }
4549
46- public function testReadFileContent (): void {
50+ public function testReadFileContent (): void
51+ {
4752 $ basePath = $ this ->tempDir . DIRECTORY_SEPARATOR . 'file1.txt ' ;
4853 \file_put_contents ($ basePath , 'test content ' );
4954 self ::assertSame ('test content ' , $ this ->filesystem ->read ($ basePath ));
5055 }
5156
52- public function testWriteFile (): void {
57+ public function testWriteFile (): void
58+ {
5359 $ basePath = $ this ->tempDir . DIRECTORY_SEPARATOR . 'file.txt ' ;
5460
5561 $ this ->filesystem ->write ($ basePath , 'test content ' );
5662 self ::assertSame ('test content ' , $ this ->filesystem ->read ($ basePath ));
5763 }
5864
59- public function testAppendContentToFile (): void {
65+ public function testAppendContentToFile (): void
66+ {
6067 $ basePath = $ this ->tempDir . DIRECTORY_SEPARATOR . 'file.txt ' ;
6168 $ this ->filesystem ->write ($ basePath , 'test content ' );
6269 $ this ->filesystem ->append ($ basePath , 'test content ' );
6370
6471 self ::assertSame ('test contenttest content ' , $ this ->filesystem ->read ($ basePath ));
6572 }
6673
67- public function testRemoveFiles (): void {
74+ public function testRemoveFiles (): void
75+ {
6876 $ basePath = $ this ->tempDir . DIRECTORY_SEPARATOR . 'file1.txt ' ;
6977 $ this ->filesystem ->touch ($ basePath );
7078 $ this ->filesystem ->unlink ($ basePath );
7179
7280 self ::assertFalse ($ this ->filesystem ->exists ($ basePath ));
7381 }
7482
75- public function testRemoveDirectory (): void {
83+ public function testRemoveDirectory (): void
84+ {
7685 $ this ->filesystem ->mkdir ($ this ->tempDir . DIRECTORY_SEPARATOR . 'dir ' );
7786 $ this ->filesystem ->rmdir ($ this ->tempDir );
7887
7988 self ::assertFalse ($ this ->filesystem ->exists ($ this ->tempDir ));
8089 }
8190
82- public function testRemoveDirectoryRecursive (): void {
91+ public function testRemoveDirectoryRecursive (): void
92+ {
8393 $ this ->filesystem ->mkdir ($ this ->tempDir . DIRECTORY_SEPARATOR . 'dir ' . DIRECTORY_SEPARATOR . 'dir1 ' , 0777 , true );
8494 $ this ->filesystem ->rmdir ($ this ->tempDir );
8595
8696 self ::assertFalse ($ this ->filesystem ->exists ($ this ->tempDir ));
8797 }
98+
8899 public function testCopyFile ()
89100 {
90101 $ source = $ this ->tempDir . '/file1.txt ' ;
@@ -110,35 +121,40 @@ public function testMoveFile()
110121 self ::assertEquals ('test content ' , $ this ->filesystem ->read ($ destination ));
111122 }
112123
113- public function testName (): void {
124+ public function testName (): void
125+ {
114126 $ file = $ this ->tempDir . DIRECTORY_SEPARATOR .'file1.txt ' ;
115127 $ this ->filesystem ->touch ($ file );
116128
117129 self ::assertSame ('file1 ' , $ this ->filesystem ->name ($ file ));
118130 }
119131
120- public function testDirname (): void {
132+ public function testDirname (): void
133+ {
121134 $ file = $ this ->tempDir . DIRECTORY_SEPARATOR .'file1.txt ' ;
122135 $ this ->filesystem ->touch ($ file );
123136
124137 self ::assertSame ('/tmp/tmp ' , $ this ->filesystem ->dirname ($ file ));
125138 }
126139
127- public function testBasename (): void {
140+ public function testBasename (): void
141+ {
128142 $ file = $ this ->tempDir . DIRECTORY_SEPARATOR .'file1.txt ' ;
129143 $ this ->filesystem ->touch ($ file );
130144
131145 self ::assertSame ('file1.txt ' , $ this ->filesystem ->basename ($ file ));
132146 }
133147
134- public function testExtension (): void {
148+ public function testExtension (): void
149+ {
135150 $ file = $ this ->tempDir . DIRECTORY_SEPARATOR .'file1.txt ' ;
136151 $ this ->filesystem ->touch ($ file );
137152
138153 self ::assertSame ('txt ' , $ this ->filesystem ->extension ($ file ));
139154 }
140155
141- public function testFileSize (): void {
156+ public function testFileSize (): void
157+ {
142158 $ file = $ this ->tempDir . DIRECTORY_SEPARATOR .'file1.txt ' ;
143159 $ this ->filesystem ->touch ($ file );
144160
0 commit comments