51336e346a
Daily logs created by root cron were blocking www from appending, which aborted webhook ingest and bot pushes. File channels now use 0664 plus exception-safe stacks, and writes go through SafeLog. Co-authored-by: Cursor <cursoragent@cursor.com>
44 lines
1.1 KiB
PHP
44 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace Tests;
|
|
|
|
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
abstract class TestCase extends BaseTestCase
|
|
{
|
|
/**
|
|
* Point a Laravel log channel at a directory the process cannot write.
|
|
* Used to prove SafeLog / ignore_exceptions do not abort business work.
|
|
*/
|
|
protected function forceLogChannelUnwritable(string $channel): string
|
|
{
|
|
$dir = sys_get_temp_dir().'/coruna-unwritable-log-'.uniqid('', true);
|
|
mkdir($dir, 0700);
|
|
chmod($dir, 0500);
|
|
|
|
config([
|
|
"logging.channels.{$channel}" => [
|
|
'driver' => 'single',
|
|
'path' => $dir.'/blocked.log',
|
|
'level' => 'debug',
|
|
],
|
|
]);
|
|
Log::forgetChannel($channel);
|
|
|
|
return $dir;
|
|
}
|
|
|
|
protected function restoreWritableLogDir(string $dir): void
|
|
{
|
|
if ($dir === '' || ! is_dir($dir)) {
|
|
return;
|
|
}
|
|
@chmod($dir, 0700);
|
|
foreach (glob($dir.'/*') ?: [] as $file) {
|
|
@unlink($file);
|
|
}
|
|
@rmdir($dir);
|
|
}
|
|
}
|