-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from dcblogdev/refactored-filtered-load-from-m…
…odel moved filters to model
- Loading branch information
Showing
4 changed files
with
84 additions
and
32 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 |
---|---|---|
|
@@ -4,7 +4,66 @@ | |
use Dcblogdev\LaravelSentEmails\Models\SentEmailAttachment; | ||
|
||
test('can see emails inbox', function () { | ||
$this->get(route('sentemails.index'))->assertOk(); | ||
SentEmail::factory()->count(10)->create(); | ||
$this->get(route('sentemails.index')) | ||
->assertOk() | ||
->assertViewHas('emails', function ($emails) { | ||
return $emails->count() === 10; | ||
} | ||
); | ||
}); | ||
|
||
test('can filter emails by date', function () { | ||
|
||
SentEmail::factory()->create(['date' => '2023-10-20']); | ||
SentEmail::factory()->create(['date' => '2023-10-20']); | ||
SentEmail::factory()->create(); | ||
|
||
$this->get(route('sentemails.index', ['date' => '2023-10-20'])) | ||
->assertOk() | ||
->assertViewHas('emails', function ($emails) { | ||
return $emails->count() === 2; | ||
} | ||
); | ||
}); | ||
|
||
test('can filter emails by from', function () { | ||
|
||
SentEmail::factory()->create(['from' => '[email protected]']); | ||
SentEmail::factory()->create(); | ||
|
||
$this->get(route('sentemails.index', ['from' => '[email protected]'])) | ||
->assertOk() | ||
->assertViewHas('emails', function ($emails) { | ||
return $emails->count() === 1; | ||
} | ||
); | ||
}); | ||
|
||
test('can filter emails by to', function () { | ||
|
||
SentEmail::factory()->create(['to' => '[email protected]']); | ||
SentEmail::factory()->create(); | ||
|
||
$this->get(route('sentemails.index', ['to' => '[email protected]'])) | ||
->assertOk() | ||
->assertViewHas('emails', function ($emails) { | ||
return $emails->count() === 1; | ||
} | ||
); | ||
}); | ||
|
||
test('can filter emails by subject', function () { | ||
|
||
SentEmail::factory()->create(['subject' => 'Demo']); | ||
SentEmail::factory()->create(['subject' => 'Other']); | ||
|
||
$this->get(route('sentemails.index', ['subject' => 'Demo'])) | ||
->assertOk() | ||
->assertViewHas('emails', function ($emails) { | ||
return $emails->count() === 1; | ||
} | ||
); | ||
}); | ||
|
||
test('can see email', function () { | ||
|