generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow overwriting of email sender (#14)
* Allow individual mailable mail senders
- Loading branch information
Showing
4 changed files
with
117 additions
and
25 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 |
---|---|---|
|
@@ -373,3 +373,92 @@ | |
return true; | ||
}); | ||
}); | ||
|
||
test('the configured mail sender can be overwritten', function () { | ||
Config::set('mail.mailers.microsoft-graph', [ | ||
'transport' => 'microsoft-graph', | ||
'client_id' => 'foo_client_id', | ||
'client_secret' => 'foo_client_secret', | ||
'tenant_id' => 'foo_tenant_id', | ||
'from' => [ | ||
'address' => '[email protected]', | ||
'name' => 'Taylor Otwell', | ||
], | ||
]); | ||
Config::set('mail.default', 'microsoft-graph'); | ||
|
||
Cache::set('microsoft-graph-api-access-token', 'foo_access_token', 3600); | ||
|
||
Http::fake(); | ||
|
||
$mailable = new TestMail(false); | ||
$mailable->from('[email protected]', 'Other Mail'); | ||
|
||
Mail::to('[email protected]') | ||
->bcc('[email protected]') | ||
->cc('[email protected]') | ||
->send($mailable); | ||
|
||
Http::assertSent(function (Request $value) { | ||
expect($value) | ||
->url()->toBe('https://graph.microsoft.com/v1.0/users/[email protected]/sendMail') | ||
->hasHeader('Authorization', 'Bearer foo_access_token')->toBeTrue() | ||
->body()->json()->toBe([ | ||
'message' => [ | ||
'subject' => 'Dev Test', | ||
'body' => [ | ||
'contentType' => 'Text', | ||
'content' => 'Test'.PHP_EOL, | ||
], | ||
'toRecipients' => [ | ||
[ | ||
'emailAddress' => [ | ||
'address' => '[email protected]', | ||
], | ||
], | ||
], | ||
'ccRecipients' => [ | ||
[ | ||
'emailAddress' => [ | ||
'address' => '[email protected]', | ||
], | ||
], | ||
], | ||
'bccRecipients' => [ | ||
[ | ||
'emailAddress' => [ | ||
'address' => '[email protected]', | ||
], | ||
], | ||
], | ||
'replyTo' => [], | ||
'sender' => [ | ||
'emailAddress' => [ | ||
'address' => '[email protected]', | ||
], | ||
], | ||
'attachments' => [ | ||
[ | ||
'@odata.type' => '#microsoft.graph.fileAttachment', | ||
'name' => 'test-file-1.txt', | ||
'contentType' => 'text', | ||
'contentBytes' => 'Zm9vCg==', | ||
'contentId' => 'test-file-1.txt', | ||
'isInline' => false, | ||
], | ||
[ | ||
'@odata.type' => '#microsoft.graph.fileAttachment', | ||
'name' => 'test-file-2.txt', | ||
'contentType' => 'text', | ||
'contentBytes' => 'Zm9vCg==', | ||
'contentId' => 'test-file-2.txt', | ||
'isInline' => false, | ||
], | ||
], | ||
], | ||
'saveToSentItems' => false, | ||
]); | ||
|
||
return true; | ||
}); | ||
}); |