@@ -156,34 +156,13 @@ public function testClearLogsFailsOnChmodFailure(): void
156156 $ path = WRITEPATH . 'logs ' . DIRECTORY_SEPARATOR . "log- {$ this ->date }.log " ;
157157 file_put_contents ($ path , 'Lorem ipsum ' );
158158
159- // Attempt to make the file itself undeletable by setting the
160- // immutable/uchg flag on supported platforms.
161- $ immutableSet = false ;
162- if (str_starts_with (PHP_OS , 'Darwin ' )) {
163- @exec (sprintf ('chflags uchg %s ' , escapeshellarg ($ path )), $ output , $ rc );
164- $ immutableSet = $ rc === 0 ;
165- } else {
166- // Try chattr on Linux with sudo (for containerized environments)
167- @exec ('which chattr ' , $ whichOut , $ whichRc );
168-
169- if ($ whichRc === 0 ) {
170- @exec (sprintf ('sudo chattr +i %s ' , escapeshellarg ($ path )), $ output , $ rc );
171- $ immutableSet = $ rc === 0 ;
172- }
173- }
174-
175- if (! $ immutableSet ) {
176- $ this ->markTestSkipped ('Cannot set file immutability in this environment ' );
177- }
159+ // Attempt to make the file itself undeletable
160+ chmod (dirname ($ path ), 0555 );
178161
179162 command ('logs:clear --force ' );
180163
181164 // Restore attributes so other tests are not affected.
182- if (str_starts_with (PHP_OS , 'Darwin ' )) {
183- @exec (sprintf ('chflags nouchg %s ' , escapeshellarg ($ path )));
184- } else {
185- @exec (sprintf ('sudo chattr -i %s ' , escapeshellarg ($ path )));
186- }
165+ chmod (dirname ($ path ), 0755 );
187166
188167 $ this ->assertFileExists ($ path );
189168 $ this ->assertSame (
0 commit comments