Skip to content

Commit f17d701

Browse files
committed
dumpWithoutTrace
1 parent aac15b5 commit f17d701

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,12 @@ use Binarcode\LaravelDeveloper\Middleware\DevAuthMiddleware;
268268

269269
If you're using laravel sanctum, and want to explicitely use / generate a Bearer for the resolved user, you can use the `\Binarcode\LaravelDeveloper\Middleware\DevAuthMiddleware::class` instead, which follow the same syntax as the `DevAuthMiddleware`.
270270

271+
## Tests macros
272+
273+
### dumpWithoutTrace
274+
275+
If you're annoying to always scroll up to message in your test when `->dump()` the response, you can use `->dumpWithoutTrace()` instead, it will return you back everything except the long array of trace.
276+
271277
## Testing
272278

273279
``` bash

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"php": "^7.4|^8.0",
2020
"illuminate/contracts": "^8.0",
2121
"illuminate/support": "^7.0|^8.0",
22-
"laravel/slack-notification-channel": "^2.3"
22+
"laravel/slack-notification-channel": "^2.3",
23+
"ext-json": "*"
2324
},
2425
"require-dev": {
2526
"laravel/sanctum": "^2.8",

src/LaravelDeveloperServiceProvider.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Binarcode\LaravelDeveloper\Commands\PruneCommand;
66
use Illuminate\Support\ServiceProvider;
7+
use Illuminate\Testing\TestResponse;
78

89
class LaravelDeveloperServiceProvider extends ServiceProvider
910
{
@@ -30,6 +31,26 @@ public function boot()
3031
public function register()
3132
{
3233
$this->mergeConfigFrom(__DIR__ . '/../config/laravel-developer.php', 'developer');
34+
$this->registerMacros();
35+
}
36+
37+
protected function registerMacros(): self
38+
{
39+
TestResponse::macro('dumpWithoutTrace', function() {
40+
$content = $this->getContent();
41+
42+
$json = json_decode($content);
43+
44+
if (json_last_error() === JSON_ERROR_NONE) {
45+
$content = $json;
46+
}
47+
48+
unset($content->trace);
49+
50+
dump($content);
51+
52+
return $this;
53+
});
3354
}
3455

3556
public static function migrationFileExists(string $migrationFileName): bool

0 commit comments

Comments
 (0)