Files
loghandler/tests/TestCase.php
2025-09-18 12:26:04 +02:00

54 lines
1.5 KiB
PHP

<?php
namespace HerrleinIT\LogHandler\Tests;
use HerrleinIT\LogHandler\LogHandlerServiceProvider;
use Illuminate\Support\Facades\Log;
use Orchestra\Testbench\TestCase as Orchestra;
abstract class TestCase extends Orchestra
{
protected function getPackageProviders($app): array
{
return [LogHandlerServiceProvider::class];
}
protected function defineEnvironment($app): void
{
$app['config']->set('logging.default', 'stack');
$app['config']->set('logging.channels.loghandler', [
'driver' => 'loghandler',
'level' => 'debug',
'bubble' => true,
]);
$app['config']->set('logging.channels.single', [
'driver' => 'single',
'path' => storage_path('logs/laravel.log'),
'level' => 'debug',
'replace_placeholders' => true,
]);
$app['config']->set('logging.channels.stack', [
'driver' => 'stack',
'channels' => ['single', 'loghandler'],
'ignore_exceptions' => false,
]);
$app['config']->set('loghandler', [
'endpoint' => 'http://test.example/api/error/create',
'token' => 'test-token',
'source' => 'Project Name',
'enabled' => true,
'timeout_ms' => 3000,
'retry_times' => 0,
'include_trace' => false,
]);
}
protected function tearDown(): void
{
parent::tearDown();
Log::forgetChannel('loghandler');
Log::forgetChannel('stack');
}
}