generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
8dcf677
commit 0e27b96
Showing
6 changed files
with
69 additions
and
15 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
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 |
---|---|---|
@@ -1,28 +1,66 @@ | ||
<?php | ||
|
||
use CleaniqueCoders\MailHistory\Tests\Mail\WelcomeMail; | ||
use CleaniqueCoders\MailHistory\Contracts\HashContract; | ||
use CleaniqueCoders\MailHistory\Exceptions\MailHistoryException; | ||
use Illuminate\Mail\Events\MessageSending; | ||
use Illuminate\Mail\Events\MessageSent; | ||
use Illuminate\Support\Facades\Artisan; | ||
use Illuminate\Support\Facades\Mail; | ||
use Illuminate\Support\Facades\Event; | ||
|
||
beforeEach(function () { | ||
config()->set('view.paths', [ | ||
dirname(__FILE__).'/resources/views', | ||
]); | ||
|
||
Artisan::call('vendor:publish', [ | ||
'--tag' => 'mailhistory-migrations', | ||
'--force' => true, | ||
]); | ||
Artisan::call('migrate:fresh'); | ||
}); | ||
|
||
it('can store sent email in database', function ($email) { | ||
Mail::fake(); | ||
// assert email sending / sent | ||
it('has HashContract', function () { | ||
$this->assertTrue( | ||
file_exists(dirname(__FILE__).'/../src/Contracts/HashContract.php') | ||
); | ||
|
||
$this->assertTrue( | ||
in_array(HashContract::class, class_implements(config('mailhistory.model'))) | ||
); | ||
|
||
$this->assertTrue( | ||
class_exists(MailHistoryException::class) | ||
); | ||
|
||
$this->assertTrue( | ||
method_exists( | ||
MailHistoryException::class, | ||
'throwIfHashContractMissing' | ||
) | ||
); | ||
}); | ||
|
||
it('has MessageSending and MessageSent event listened to if the package is enabled', function () { | ||
$this->assertTrue( | ||
Event::hasListeners(MessageSending::class), | ||
); | ||
|
||
$this->assertTrue( | ||
Event::hasListeners(MessageSent::class), | ||
); | ||
}); | ||
|
||
it('does not has the MessageSending and MessageSent event listened to if the package is disabled', function () { | ||
|
||
Mail::to($email) | ||
->send(new WelcomeMail); | ||
config([ | ||
'mailhistory.enabled' => false, | ||
]); | ||
|
||
Mail::assertSent(WelcomeMail::class); | ||
$this->assertTrue( | ||
Event::hasListeners(MessageSending::class), | ||
); | ||
|
||
// $this->assertDatabaseCount('mail_histories', 2); | ||
})->with([ | ||
'[email protected]', | ||
'[email protected]', | ||
]); | ||
$this->assertTrue( | ||
Event::hasListeners(MessageSent::class), | ||
); | ||
}); |
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,10 @@ | ||
<x-mail::message> | ||
Hi, welcome to {{ config('app.name') }}! | ||
|
||
<x-mail::button url="{{ url('/') }}"> | ||
{{ config('app.name') }} | ||
</x-mail::button> | ||
|
||
Thanks,<br> | ||
{{ config('app.name') }} | ||
</x-mail::message> |