|
38 | 38 | ->toContain('"level": 400') |
39 | 39 | ->toContain('"datetime": "2024-01-01 12:00:00"'); |
40 | 40 | }); |
| 41 | + |
| 42 | +it('excludes keys that have dedicated sections', function () { |
| 43 | + $extra = [ |
| 44 | + 'exception' => ['class' => 'RuntimeException'], |
| 45 | + 'environment' => ['app_env' => 'testing'], |
| 46 | + 'request' => ['url' => 'https://example.com'], |
| 47 | + 'route' => ['name' => 'test.route'], |
| 48 | + 'route_summary' => '/dashboard', |
| 49 | + 'user' => ['id' => 123], |
| 50 | + 'queries' => [], |
| 51 | + 'job' => ['name' => 'TestJob'], |
| 52 | + 'command' => ['name' => 'test:command'], |
| 53 | + 'outgoing_requests' => [], |
| 54 | + 'session' => ['data' => []], |
| 55 | + 'livewire' => ['component' => 'App\\Livewire\\Counter'], |
| 56 | + 'livewire_originating_page' => '/dashboard', |
| 57 | + 'inertia' => ['page' => '/dashboard'], |
| 58 | + 'custom_key' => 'custom_value', |
| 59 | + ]; |
| 60 | + |
| 61 | + $result = $this->formatter->format($extra); |
| 62 | + |
| 63 | + expect($result) |
| 64 | + ->not->toContain('exception') |
| 65 | + ->not->toContain('environment') |
| 66 | + ->not->toContain('request') |
| 67 | + ->not->toContain('"route"') |
| 68 | + ->not->toContain('route_summary') |
| 69 | + ->not->toContain('user') |
| 70 | + ->not->toContain('queries') |
| 71 | + ->not->toContain('job') |
| 72 | + ->not->toContain('command') |
| 73 | + ->not->toContain('outgoing_requests') |
| 74 | + ->not->toContain('session') |
| 75 | + ->not->toContain('livewire') |
| 76 | + ->not->toContain('inertia') |
| 77 | + ->toContain('custom_key') |
| 78 | + ->toContain('custom_value'); |
| 79 | +}); |
| 80 | + |
| 81 | +it('returns empty string when all keys are excluded', function () { |
| 82 | + $extra = [ |
| 83 | + 'environment' => ['app_env' => 'testing'], |
| 84 | + 'user' => ['id' => 123], |
| 85 | + 'route' => ['name' => 'home'], |
| 86 | + ]; |
| 87 | + |
| 88 | + expect($this->formatter->format($extra))->toBe(''); |
| 89 | +}); |
0 commit comments