File tree Expand file tree Collapse file tree 1 file changed +24
-9
lines changed
src/LaravelMailAssertions Expand file tree Collapse file tree 1 file changed +24
-9
lines changed Original file line number Diff line number Diff line change @@ -126,15 +126,13 @@ public function emptyMail()
126126 */
127127 public function fakeMail ()
128128 {
129- Mail::shouldReceive ('send ' )->andReturnUsing (function (...$ args ) {
130- $ this ->getEmailSender ()->send (...$ args );
131- });
132-
133- Mail::shouldReceive ('raw ' )->andReturnUsing (function (...$ args ) {
134- $ this ->getEmailSender ()->sendRaw (...$ args );
135- });
136-
137- Mail::shouldReceive ('failures ' );
129+ if (method_exists ($ this , 'afterApplicationCreated ' )) {
130+ $ this ->afterApplicationCreated (function () {
131+ $ this ->mockMailFacade ();
132+ });
133+ } else {
134+ $ this ->mockMailFacade ();
135+ }
138136 }
139137
140138 /**
@@ -183,4 +181,21 @@ private function getEmailSender()
183181 {
184182 return Mailer::instance ();
185183 }
184+
185+ /**
186+ * Mock the mail facade
187+ * @return void
188+ */
189+ private function mockMailFacade ()
190+ {
191+ Mail::shouldReceive ('send ' )->andReturnUsing (function (...$ args ) {
192+ $ this ->getEmailSender ()->send (...$ args );
193+ });
194+
195+ Mail::shouldReceive ('raw ' )->andReturnUsing (function (...$ args ) {
196+ $ this ->getEmailSender ()->sendRaw (...$ args );
197+ });
198+
199+ Mail::shouldReceive ('failures ' );
200+ }
186201}
You can’t perform that action at this time.
0 commit comments