-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(pipes): Add LimitLengthPipe to CollectorManager
- Added LimitLengthPipe to CollectorManager for processing - Updated toPipes method to handle LimitLengthPipe - Sorted pipes in toPipes method based on rules
- Loading branch information
Showing
2 changed files
with
71 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
/** @noinspection AnonymousFunctionStaticInspection */ | ||
/** @noinspection StaticClosureCanBeUsedInspection */ | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright (c) 2021-2024 guanguans<[email protected]> | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file that was distributed with this source code. | ||
* | ||
* @see https://github.com/guanguans/laravel-exception-notify | ||
*/ | ||
|
||
namespace Guanguans\LaravelExceptionNotify\Tests; | ||
|
||
use Guanguans\LaravelExceptionNotify\CollectorManager; | ||
use Guanguans\LaravelExceptionNotify\Exceptions\RuntimeException; | ||
use Guanguans\LaravelExceptionNotify\Pipes\LimitLengthPipe; | ||
use Guanguans\LaravelExceptionNotify\Pipes\SprintfHtmlPipe; | ||
use Illuminate\Support\Str; | ||
|
||
it('can map to reports', function (): void { | ||
collect(config('exception-notify.channels'))->each(fn (array $config, string $name) => config()->set( | ||
"exception-notify.channels.$name.pipes", | ||
collect($config['pipes'] ?? []) | ||
->reject(fn (string $pipe) => Str::contains($pipe, SprintfHtmlPipe::class)) | ||
->push(hydrate_pipe(LimitLengthPipe::class, 512)) | ||
->all() | ||
)); | ||
|
||
$reports = app(CollectorManager::class)->mapToReports( | ||
array_keys(config('exception-notify.channels')), | ||
new RuntimeException | ||
); | ||
|
||
expect(array_map(fn ($report): string => trim($report, " \n\r\t\v\0`"), $reports))->each->toBeJson(); | ||
})->group(__DIR__, __FILE__); |