-
-
Save acepsaepudin/2dd236a9678f6b14ee67 to your computer and use it in GitHub Desktop.
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
<?php | |
use Phake as p; | |
class MockingMailTest extends \TestCase | |
{ | |
function test_it_should_send_mail() | |
{ | |
// Mocking Laravel Mail | |
$mockedMail = p::mock('Illuminate\Mail\Mailer'); | |
$this->app->instance('mailer', $mockedMail); | |
// Lakukan proses tertentu | |
// Di dalam proses ini, aplikasi seharusnya mengirim email menggunakan Mail | |
// Memastikan bahwa email dikirim menggunakan: | |
// Template email.suatuTemplate | |
// Dengan template konent berupa ['content'=>'Suatu Konten'] | |
p::verify($mockedMail, p::times(1))->send('email.suatuTemplate', ['content'=>'Suatu Konten'], $this->isInstanceOf('Closure')); | |
} | |
} |
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
<?php | |
namespace Suatu\Namespace; | |
class SuatuProsesYangMengirimMail | |
{ | |
public function send($receiverEmail, $receiverName, $content, $template) | |
{ | |
\Mail::send($template, $content, function($message) use ($receiverEmail, $receiverName) { | |
// proses mengirimm mail | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment