11<?php
22namespace Tests \Unit ;
33
4+ use App \Mail \CheckoutAssetMail ;
45use App \Models \User ;
56use App \Models \Asset ;
67use App \Models \AssetModel ;
78use App \Models \Category ;
89use Carbon \Carbon ;
910use App \Notifications \CheckoutAssetNotification ;
11+ use Illuminate \Support \Facades \Mail ;
1012use Illuminate \Support \Facades \Notification ;
1113use Tests \TestCase ;
1214
@@ -29,13 +31,13 @@ public function testAUserIsEmailedIfTheyCheckoutAnAssetWithEULA()
2931 'purchase_date ' => Carbon::createFromDate (2017 , 1 , 1 )->hour (0 )->minute (0 )->second (0 )->format ('Y-m-d ' )
3032 ]);
3133
32- Notification ::fake ();
34+ Mail ::fake ();
3335 $ asset ->checkOut ($ user , $ admin ->id );
34- Notification:: assertSentTo ($ user , CheckoutAssetNotification ::class);
36+ Mail:: assertSent ($ user , CheckoutAssetMail ::class);
3537 }
3638 public function testDefaultEulaIsSentWhenSetInCategory ()
3739 {
38- Notification ::fake ();
40+ Mail ::fake ();
3941
4042 $ this ->settings ->setEula ('My Custom EULA Text ' );
4143
@@ -51,10 +53,10 @@ public function testDefaultEulaIsSentWhenSetInCategory()
5153
5254 $ asset ->checkOut ($ user , User::factory ()->superuser ()->create ()->id );
5355
54- Notification:: assertSentTo ( $ user , CheckoutAssetNotification ::class, function ($ notification ) {
55- $ content = $ notification -> toMail ()-> render ();
56-
57- return str_contains ( $ content , ' My Custom EULA Text ' ) && !str_contains ($ content , 'EULA Text that should not be used ' );
56+ Mail:: assertSent (CheckoutAssetMail ::class, function ($ mail ) use ( $ user ) {
57+ return $ mail -> hasTo ( $ user -> email ) &&
58+ str_contains ( $ mail -> render (), ' My Custom EULA Text ' ) &&
59+ !str_contains ($ mail -> render () , 'EULA Text that should not be used ' );
5860 });
5961 }
6062}
0 commit comments