generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mexion
committed
Dec 11, 2024
1 parent
5766db4
commit 1997fcc
Showing
2 changed files
with
45 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
use Illuminate\Support\Facades\Log; | ||
use Spatie\LaravelCipherSweet\Tests\TestClasses\User; | ||
use Spatie\LaravelCipherSweet\Tests\TestClasses\UserObserver; | ||
|
||
|
||
it('whatever', function () { | ||
$user = User::create([ | ||
'name' => 'John Doe', | ||
'password' => bcrypt('password'), | ||
'email' => '[email protected]', | ||
]); | ||
|
||
Log::spy(); | ||
User::observe(UserObserver::class); | ||
$user->update(['email' => '[email protected]']); | ||
|
||
Log::shouldHaveReceived('info') | ||
->with("saving: dirty=2") | ||
->once(); | ||
|
||
Log::shouldHaveReceived('info') | ||
->with("saved: dirty=2") | ||
->once(); | ||
}); |
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,19 @@ | ||
<?php | ||
namespace Spatie\LaravelCipherSweet\Tests\TestClasses; | ||
|
||
class UserObserver | ||
{ | ||
public function saved(User $user) | ||
{ | ||
$msg = "saved: dirty=".sizeof($user->getDirty()); | ||
\Log::info($msg); | ||
} | ||
|
||
public function saving(User $user) | ||
{ | ||
$user->name .="."; | ||
|
||
$msg = "saving: dirty=".sizeof($user->getDirty()); | ||
\Log::info($msg); | ||
} | ||
} |