mirror of
https://github.com/nothingworksinc/ticketbeast.git
synced 2026-01-26 11:14:06 +00:00
96 - Testing Mailable Contents
This commit is contained in:
@@ -30,6 +30,7 @@ class OrderConfirmationEmail extends Mailable
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
return $this->view('view.name');
|
||||
return $this->view('emails.order-confirmation-email')
|
||||
->subject("Your TicketBeast Order");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<p>Thanks for your order!</p>
|
||||
|
||||
<p>You can view your tickets at any time by visiting this URL:</p>
|
||||
|
||||
<p>
|
||||
<a href="{{ url("/orders/{$order->confirmation_number}") }}">{{ url("/orders/{$order->confirmation_number}") }}</a>
|
||||
</p>
|
||||
39
tests/unit/Mail/OrderConfirmationEmailTest.php
Normal file
39
tests/unit/Mail/OrderConfirmationEmailTest.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use App\Order;
|
||||
use App\Mail\OrderConfirmationEmail;
|
||||
use Illuminate\Foundation\Testing\WithoutMiddleware;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
|
||||
class OrderConfirmationEmailTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
function email_contains_a_link_to_the_order_confirmation_page()
|
||||
{
|
||||
$order = factory(Order::class)->make([
|
||||
'confirmation_number' => 'ORDERCONFIRMATION1234'
|
||||
]);
|
||||
$email = new OrderConfirmationEmail($order);
|
||||
$rendered = $this->render($email);
|
||||
|
||||
// In Laravel 5.5...
|
||||
// $rendered = $email->render();
|
||||
|
||||
$this->assertContains(url('/orders/ORDERCONFIRMATION1234'), $rendered);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
function email_has_a_subject()
|
||||
{
|
||||
$order = factory(Order::class)->make();
|
||||
$email = new OrderConfirmationEmail($order);
|
||||
$this->assertEquals("Your TicketBeast Order", $email->build()->subject);
|
||||
}
|
||||
|
||||
private function render($mailable)
|
||||
{
|
||||
$mailable->build();
|
||||
return view($mailable->view, $mailable->buildViewData())->render();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user