3434use Guanguans \LaravelExceptionNotify \Pipes \AddKeywordChorePipe ;
3535use Guanguans \LaravelExceptionNotify \Pipes \FixPrettyJsonPipe ;
3636use Guanguans \LaravelExceptionNotify \Pipes \LimitLengthPipe ;
37- use Guanguans \LaravelExceptionNotify \Pipes \ReplaceStrPipe ;
3837use Guanguans \LaravelExceptionNotify \Pipes \SprintfHtmlPipe ;
3938use Guanguans \LaravelExceptionNotify \Pipes \SprintfMarkdownPipe ;
4039use Guanguans \Notify \Foundation \Client ;
4140use Guanguans \Notify \Foundation \Response ;
4241use GuzzleHttp \MessageFormatter ;
4342use GuzzleHttp \Middleware ;
44- use GuzzleHttp \Psr7 \HttpFactory ;
4543use Illuminate \Support \Facades \Log ;
4644use Mockery \Adapter \Phpunit \MockeryPHPUnitIntegration ;
4745use Symfony \Component \VarDumper \Test \VarDumperTestTrait ;
@@ -81,11 +79,6 @@ protected function getPackageAliases($app): array
8179
8280 protected function defineEnvironment ($ app ): void
8381 {
84- config ()->set ('exception-notify.channels.bark.authenticator.token ' , $ this ->faker ()->uuid ());
85- config ()->set ('exception-notify.channels.bark.client.http_options ' , []);
86- config ()->set ('exception-notify.channels.bark.client.extender ' , static fn (Client $ client ): Client => $ client ->mock ([
87- (new HttpFactory )->createResponse (200 , '{"code":200,"message":"success","timestamp":1708331409} ' ),
88- ]));
8982 config ()->set ('exception-notify.collectors ' , [
9083 ApplicationCollector::class,
9184 ChoreCollector::class,
@@ -107,7 +100,6 @@ protected function defineEnvironment($app): void
107100 SprintfMarkdownPipe::class,
108101 FixPrettyJsonPipe::class,
109102 LimitLengthPipe::with (512 ),
110- ReplaceStrPipe::with ('.PHP ' , '.php ' ),
111103 ]);
112104
113105 collect (config ('exception-notify.channels ' ))->each (static function (array $ configuration , string $ name ): void {
@@ -130,28 +122,37 @@ protected function defineEnvironment($app): void
130122
131123 protected function defineRoutes ($ router ): void
132124 {
133- $ router ->any ('report-exception ' , static fn () => tap (response ('report-exception ' ), static function (): void {
134- config ()->set ('exception-notify.channels.stack.channels ' , [
135- 'dump ' ,
136- 'log ' ,
137- 'mail ' ,
138- 'bark ' ,
139- 'chanify ' ,
140- 'dingTalk ' ,
141- 'discord ' ,
142- 'lark ' ,
143- 'ntfy ' ,
144- 'pushDeer ' ,
145- 'slack ' ,
146- 'telegram ' ,
147- 'weWork ' ,
148- ]);
125+ $ router ->any (
126+ 'proactive-report-exception ' ,
127+ static fn () => tap (
128+ response ('proactive-report-exception ' ),
129+ static function (): void {
130+ config ()->set ('exception-notify.channels.stack.channels ' , [
131+ 'dump ' ,
132+ 'log ' ,
133+ 'mail ' ,
134+ 'bark ' ,
135+ 'chanify ' ,
136+ 'dingTalk ' ,
137+ 'discord ' ,
138+ 'lark ' ,
139+ 'ntfy ' ,
140+ 'pushDeer ' ,
141+ 'slack ' ,
142+ 'telegram ' ,
143+ 'weWork ' ,
144+ ]);
149145
150- ExceptionNotify::report (new RuntimeException ('What happened? ' ));
151- }));
146+ ExceptionNotify::report (new RuntimeException ('What happened? ' ));
147+ }
148+ )
149+ );
152150
153- $ router ->any ('exception ' , static fn () => tap (response ('exception ' ), static function (): void {
154- throw new RuntimeException ('What happened? ' );
155- }));
151+ $ router ->any (
152+ 'automatic-report-exception ' ,
153+ static fn () => tap (response ('automatic-report-exception ' ), static function (): void {
154+ throw new RuntimeException ('What happened? ' );
155+ })
156+ );
156157 }
157158}
0 commit comments