Skip to content

Commit fecdf9d

Browse files
committed
Test mailables are available
1 parent 742805a commit fecdf9d

File tree

5 files changed

+165
-0
lines changed

5 files changed

+165
-0
lines changed

app/Mail/OrderShipped.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
namespace App\Mail;
4+
5+
use Illuminate\Bus\Queueable;
6+
use Illuminate\Contracts\Queue\ShouldQueue;
7+
use Illuminate\Mail\Mailable;
8+
use Illuminate\Mail\Mailables\Content;
9+
use Illuminate\Mail\Mailables\Envelope;
10+
use Illuminate\Queue\SerializesModels;
11+
12+
class OrderShipped extends Mailable
13+
{
14+
use Queueable, SerializesModels;
15+
16+
/**
17+
* Create a new message instance.
18+
*
19+
* @return void
20+
*/
21+
public function __construct()
22+
{
23+
//
24+
}
25+
26+
/**
27+
* Get the message envelope.
28+
*
29+
* @return \Illuminate\Mail\Mailables\Envelope
30+
*/
31+
public function envelope()
32+
{
33+
return new Envelope(
34+
subject: 'Order Shipped',
35+
);
36+
}
37+
38+
/**
39+
* Get the message content definition.
40+
*
41+
* @return \Illuminate\Mail\Mailables\Content
42+
*/
43+
public function content()
44+
{
45+
return new Content(
46+
markdown: 'emails.orders.shipped',
47+
);
48+
}
49+
50+
/**
51+
* Get the attachments for the message.
52+
*
53+
* @return array
54+
*/
55+
public function attachments()
56+
{
57+
return [];
58+
}
59+
}

app/Mail/PostPublished.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
3+
namespace App\Mail;
4+
5+
use Illuminate\Bus\Queueable;
6+
use Illuminate\Contracts\Queue\ShouldQueue;
7+
use Illuminate\Mail\Mailable;
8+
use Illuminate\Mail\Mailables\Content;
9+
use Illuminate\Mail\Mailables\Envelope;
10+
use Illuminate\Queue\SerializesModels;
11+
12+
class PostPublished extends Mailable
13+
{
14+
use Queueable, SerializesModels;
15+
16+
/**
17+
* Create a new message instance.
18+
*
19+
* @return void
20+
*/
21+
public function __construct()
22+
{
23+
//
24+
}
25+
26+
/**
27+
* Get the message envelope.
28+
*
29+
* @return \Illuminate\Mail\Mailables\Envelope
30+
*/
31+
public function envelope()
32+
{
33+
return new Envelope(
34+
subject: 'Post Published',
35+
);
36+
}
37+
38+
/**
39+
* Get the message content definition.
40+
*
41+
* @return \Illuminate\Mail\Mailables\Content
42+
*/
43+
public function content()
44+
{
45+
return new Content(
46+
markdown: 'emails.posts.published',
47+
);
48+
}
49+
50+
/**
51+
* Get the attachments for the message.
52+
*
53+
* @return array
54+
*/
55+
public function attachments()
56+
{
57+
return [];
58+
}
59+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<x-mail::message>
2+
# Introduction
3+
4+
The body of your message.
5+
6+
<x-mail::button :url="''">
7+
Button Text
8+
</x-mail::button>
9+
10+
Thanks,<br>
11+
{{ config('app.name') }}
12+
</x-mail::message>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<x-mail::message>
2+
# Introduction
3+
4+
The body of your message.
5+
6+
<x-mail::button :url="''">
7+
Button Text
8+
</x-mail::button>
9+
10+
Thanks,<br>
11+
{{ config('app.name') }}
12+
</x-mail::message>

tests/Feature/MailTest.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
namespace Tests\Feature;
4+
5+
use App\Mail\OrderShipped;
6+
use App\Mail\PostPublished;
7+
use Illuminate\Contracts\Mail\Mailable;
8+
use Illuminate\Foundation\Testing\RefreshDatabase;
9+
use Illuminate\Foundation\Testing\WithFaker;
10+
use Tests\TestCase;
11+
12+
class MailTest extends TestCase
13+
{
14+
/** @test */
15+
public function mailables_are_available()
16+
{
17+
$postPublished = new PostPublished();
18+
$orderShipped = new OrderShipped();
19+
20+
$this->assertInstanceOf(Mailable::class, $postPublished);
21+
$this->assertInstanceOf(Mailable::class, $orderShipped);
22+
}
23+
}

0 commit comments

Comments
 (0)