Skip to content

Commit

Permalink
Test mailables are available
Browse files Browse the repository at this point in the history
  • Loading branch information
unclexo committed Jan 6, 2023
1 parent 742805a commit fecdf9d
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 0 deletions.
59 changes: 59 additions & 0 deletions app/Mail/OrderShipped.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;

class OrderShipped extends Mailable
{
use Queueable, SerializesModels;

/**
* Create a new message instance.
*
* @return void
*/
public function __construct()
{
//
}

/**
* Get the message envelope.
*
* @return \Illuminate\Mail\Mailables\Envelope
*/
public function envelope()
{
return new Envelope(
subject: 'Order Shipped',
);
}

/**
* Get the message content definition.
*
* @return \Illuminate\Mail\Mailables\Content
*/
public function content()
{
return new Content(
markdown: 'emails.orders.shipped',
);
}

/**
* Get the attachments for the message.
*
* @return array
*/
public function attachments()
{
return [];
}
}
59 changes: 59 additions & 0 deletions app/Mail/PostPublished.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;

class PostPublished extends Mailable
{
use Queueable, SerializesModels;

/**
* Create a new message instance.
*
* @return void
*/
public function __construct()
{
//
}

/**
* Get the message envelope.
*
* @return \Illuminate\Mail\Mailables\Envelope
*/
public function envelope()
{
return new Envelope(
subject: 'Post Published',
);
}

/**
* Get the message content definition.
*
* @return \Illuminate\Mail\Mailables\Content
*/
public function content()
{
return new Content(
markdown: 'emails.posts.published',
);
}

/**
* Get the attachments for the message.
*
* @return array
*/
public function attachments()
{
return [];
}
}
12 changes: 12 additions & 0 deletions resources/views/emails/orders/shipped.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<x-mail::message>
# Introduction

The body of your message.

<x-mail::button :url="''">
Button Text
</x-mail::button>

Thanks,<br>
{{ config('app.name') }}
</x-mail::message>
12 changes: 12 additions & 0 deletions resources/views/emails/posts/published.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<x-mail::message>
# Introduction

The body of your message.

<x-mail::button :url="''">
Button Text
</x-mail::button>

Thanks,<br>
{{ config('app.name') }}
</x-mail::message>
23 changes: 23 additions & 0 deletions tests/Feature/MailTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

namespace Tests\Feature;

use App\Mail\OrderShipped;
use App\Mail\PostPublished;
use Illuminate\Contracts\Mail\Mailable;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;

class MailTest extends TestCase
{
/** @test */
public function mailables_are_available()
{
$postPublished = new PostPublished();
$orderShipped = new OrderShipped();

$this->assertInstanceOf(Mailable::class, $postPublished);
$this->assertInstanceOf(Mailable::class, $orderShipped);
}
}

0 comments on commit fecdf9d

Please sign in to comment.