generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added test to verify overwriting of mail sender
- Loading branch information
Showing
1 changed file
with
90 additions
and
1 deletion.
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 |
---|---|---|
|
@@ -318,7 +318,7 @@ | |
'subject' => 'Dev Test', | ||
'body' => [ | ||
'contentType' => 'HTML', | ||
'content' => '<b>Test</b><img src="cid:' . $inlineImageContentId . '">'.PHP_EOL, | ||
'content' => '<b>Test</b><img src="cid:'.$inlineImageContentId.'">'.PHP_EOL, | ||
], | ||
'toRecipients' => [ | ||
[ | ||
|
@@ -372,3 +372,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; | ||
}); | ||
}); |