Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🐛 Mock Swift_Mailer instead of Mail\Mailer #23

Merged
merged 1 commit into from
Jun 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 6 additions & 21 deletions tests/Feature/InitializingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

namespace Mpyw\LaravelCachedDatabaseStickiness\Tests\Feature;

use Illuminate\Contracts\Mail\Factory as MailerFactory;
use Illuminate\Contracts\Mail\Mailer;
use Illuminate\Http\Request;
use Illuminate\Notifications\AnonymousNotifiable;
use Illuminate\Support\Facades\Bus;
Expand Down Expand Up @@ -31,6 +29,7 @@
use Mpyw\LaravelCachedDatabaseStickiness\Tests\Stubs\Notifications\ModifiedNotification;
use Orchestra\Testbench\TestCase;
use ReflectionProperty;
use Swift_Mailer;

class InitializingTest extends TestCase
{
Expand Down Expand Up @@ -177,16 +176,6 @@ public function testInitializationForListeners(): void

public function testInitializationForNotifications(): void
{
$this->mock(Mailer::class)->shouldReceive('send');

// [7.x] Multiple Mailers Per App
// https://github.com/laravel/framework/pull/31073
if (interface_exists(MailerFactory::class)) {
$this->mock(MailerFactory::class)
->shouldReceive('mailer')
->andReturn($this->app->make(Mailer::class));
}

DB::connection();

$this->assertFalse($this->getRecordsModifiedViaReflection());
Expand All @@ -209,15 +198,11 @@ public function testInitializationForNotifications(): void

public function testInitializationForMailables(): void
{
$this->mock(Mailer::class)->shouldReceive('send');

// [7.x] Multiple Mailers Per App
// https://github.com/laravel/framework/pull/31073
if (interface_exists(MailerFactory::class)) {
$this->mock(MailerFactory::class)
->shouldReceive('mailer')
->andReturn($this->app->make(Mailer::class));
}
$swift = $this->mock(Swift_Mailer::class)->makePartial();
$swift->shouldReceive('send')->times(3)->andReturn(1);
$swift->shouldReceive('getTransport->stop')->times(3);

Mail::setSwiftMailer($swift);

DB::connection();

Expand Down