generated from spatie/package-skeleton-laravel
-
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.
chore: add ability to exclude user email
this can be used for PII compliance. i have chosen to keep the existing functionality as it is for compatibility reasons.
- Loading branch information
Showing
5 changed files
with
34 additions
and
3 deletions.
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
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
|
||
use Illuminate\Database\Events\QueryExecuted; | ||
use Illuminate\Support\Facades\Event; | ||
use Spatie\SqlCommenter\Commenters\CurrentUserCommenter; | ||
use Spatie\SqlCommenter\Tests\TestSupport\TestClasses\User; | ||
|
||
it('logs the current user', function () { | ||
|
@@ -20,3 +21,23 @@ | |
|
||
User::all(); | ||
}); | ||
|
||
|
||
it('can exclude the user email', function () { | ||
$user = User::create([ | ||
'name' => 'John', | ||
'password' => 'dummy', | ||
'email' => '[email protected]', | ||
]); | ||
|
||
auth()->login($user); | ||
|
||
$this->addCommenterToConfig(CurrentUserCommenter::class, ['includeEmail' => false]); | ||
|
||
Event::listen(QueryExecuted::class, function (QueryExecuted $event) use ($user) { | ||
expect($event->sql)->toContainComment('user_id', $user->id) | ||
->and($event->sql)->notToContainComment('user_email', $user->email); | ||
}); | ||
|
||
User::all(); | ||
}); |
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