Skip to content

Commit 821edd9

Browse files
committed
refactor(tests): Remove ReplaceStrPipe and update tests
- Deleted the ReplaceStrPipe class to simplify the codebase. - Updated test cases to reflect changes in route naming: - Changed 'report-exception' to 'proactive-report-exception'. - Changed 'exception' to 'automatic-report-exception'. - Renamed test functions for clarity.
1 parent b1ea598 commit 821edd9

File tree

3 files changed

+35
-65
lines changed

3 files changed

+35
-65
lines changed

src/Pipes/ReplaceStrPipe.php

Lines changed: 0 additions & 31 deletions
This file was deleted.

tests/FeatureTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,27 +20,27 @@
2020
use Guanguans\LaravelExceptionNotify\Facades\ExceptionNotify;
2121
use Illuminate\Http\UploadedFile;
2222

23-
it('can report exception', function (): void {
23+
it('can proactive report exception', function (): void {
2424
$this
25-
->post('report-exception?foo=bar', [
25+
->post('proactive-report-exception?foo=bar', [
2626
'bar' => 'baz',
2727
'password' => 'password',
2828
'file' => new UploadedFile(__FILE__, basename(__FILE__)),
2929
])
3030
->assertOk();
3131
})->group(__DIR__, __FILE__);
3232

33-
it('can auto report exception', function (): void {
33+
it('can automatic report exception', function (): void {
3434
$this
35-
->post('exception?foo=bar', [
35+
->post('automatic-report-exception?foo=bar', [
3636
'bar' => 'baz',
3737
'password' => 'password',
3838
'file' => new UploadedFile(__FILE__, basename(__FILE__)),
3939
])
4040
->assertStatus(500);
4141
})->group(__DIR__, __FILE__);
4242

43-
it('can report', function (): void {
43+
it('can all report exception', function (): void {
4444
collect(config('exception-notify.channels'))
4545
->keys()
4646
->each(function (string $channel): void {

tests/TestCase.php

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,12 @@
3434
use Guanguans\LaravelExceptionNotify\Pipes\AddKeywordChorePipe;
3535
use Guanguans\LaravelExceptionNotify\Pipes\FixPrettyJsonPipe;
3636
use Guanguans\LaravelExceptionNotify\Pipes\LimitLengthPipe;
37-
use Guanguans\LaravelExceptionNotify\Pipes\ReplaceStrPipe;
3837
use Guanguans\LaravelExceptionNotify\Pipes\SprintfHtmlPipe;
3938
use Guanguans\LaravelExceptionNotify\Pipes\SprintfMarkdownPipe;
4039
use Guanguans\Notify\Foundation\Client;
4140
use Guanguans\Notify\Foundation\Response;
4241
use GuzzleHttp\MessageFormatter;
4342
use GuzzleHttp\Middleware;
44-
use GuzzleHttp\Psr7\HttpFactory;
4543
use Illuminate\Support\Facades\Log;
4644
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
4745
use 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

Comments
 (0)