|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Illuminate\Tests\Mail; |
| 4 | + |
| 5 | +use Illuminate\Mail\Transport\ArrayTransport; |
| 6 | +use Orchestra\Testbench\TestCase; |
| 7 | + |
| 8 | +class MailFailoverTransportTest extends TestCase |
| 9 | +{ |
| 10 | + public function testGetFailoverTransportWithConfiguredTransports() |
| 11 | + { |
| 12 | + $this->app['config']->set('mail.default', 'failover'); |
| 13 | + |
| 14 | + $this->app['config']->set('mail.mailers', [ |
| 15 | + 'failover' => [ |
| 16 | + 'transport' => 'failover', |
| 17 | + 'mailers' => [ |
| 18 | + 'sendmail', |
| 19 | + 'array', |
| 20 | + ], |
| 21 | + ], |
| 22 | + |
| 23 | + 'sendmail' => [ |
| 24 | + 'transport' => 'sendmail', |
| 25 | + 'path' => '/usr/sbin/sendmail -bs', |
| 26 | + ], |
| 27 | + |
| 28 | + 'array' => [ |
| 29 | + 'transport' => 'array', |
| 30 | + ], |
| 31 | + ]); |
| 32 | + |
| 33 | + $transport = app('mailer')->getSwiftMailer()->getTransport(); |
| 34 | + $this->assertInstanceOf(\Swift_FailoverTransport::class, $transport); |
| 35 | + |
| 36 | + $transports = $transport->getTransports(); |
| 37 | + $this->assertCount(2, $transports); |
| 38 | + $this->assertInstanceOf(\Swift_SendmailTransport::class, $transports[0]); |
| 39 | + $this->assertEquals('/usr/sbin/sendmail -bs', $transports[0]->getCommand()); |
| 40 | + $this->assertInstanceOf(ArrayTransport::class, $transports[1]); |
| 41 | + } |
| 42 | + |
| 43 | + public function testGetFailoverTransportWithLaravel6StyleMailConfiguration() |
| 44 | + { |
| 45 | + $this->app['config']->set('mail.driver', 'failover'); |
| 46 | + |
| 47 | + $this->app['config']->set('mail.mailers', [ |
| 48 | + 'sendmail', |
| 49 | + 'array', |
| 50 | + ]); |
| 51 | + |
| 52 | + $this->app['config']->set('mail.sendmail', '/usr/sbin/sendmail -bs'); |
| 53 | + |
| 54 | + $transport = app('mailer')->getSwiftMailer()->getTransport(); |
| 55 | + $this->assertInstanceOf(\Swift_FailoverTransport::class, $transport); |
| 56 | + |
| 57 | + $transports = $transport->getTransports(); |
| 58 | + $this->assertCount(2, $transports); |
| 59 | + $this->assertInstanceOf(\Swift_SendmailTransport::class, $transports[0]); |
| 60 | + $this->assertEquals('/usr/sbin/sendmail -bs', $transports[0]->getCommand()); |
| 61 | + $this->assertInstanceOf(ArrayTransport::class, $transports[1]); |
| 62 | + } |
| 63 | +} |
0 commit comments