|
13 | 13 |
|
14 | 14 | use PHPUnit\Framework\TestCase;
|
15 | 15 | use Symfony\Component\Mailer\Exception\TransportException;
|
| 16 | +use Symfony\Component\Mailer\Exception\TransportExceptionInterface; |
16 | 17 | use Symfony\Component\Mailer\Transport\RoundRobinTransport;
|
17 | 18 | use Symfony\Component\Mailer\Transport\TransportInterface;
|
18 | 19 | use Symfony\Component\Mime\RawMessage;
|
@@ -61,6 +62,7 @@ public function testSendAllDead()
|
61 | 62 | $t2->expects($this->once())->method('send')->will($this->throwException(new TransportException()));
|
62 | 63 | $t = new RoundRobinTransport([$t1, $t2]);
|
63 | 64 | $p = new \ReflectionProperty($t, 'cursor');
|
| 65 | + $p->setAccessible(true); |
64 | 66 | $p->setValue($t, 0);
|
65 | 67 |
|
66 | 68 | try {
|
@@ -137,6 +139,30 @@ public function testSendOneDeadAndRecoveryWithinRetryPeriod()
|
137 | 139 | $this->assertTransports($t, 1, []);
|
138 | 140 | }
|
139 | 141 |
|
| 142 | + public function testFailureDebugInformation() |
| 143 | + { |
| 144 | + $t1 = $this->createMock(TransportInterface::class); |
| 145 | + $e1 = new TransportException(); |
| 146 | + $e1->appendDebug('Debug message 1'); |
| 147 | + $t1->expects($this->once())->method('send')->will($this->throwException($e1)); |
| 148 | + $t2 = $this->createMock(TransportInterface::class); |
| 149 | + $e2 = new TransportException(); |
| 150 | + $e2->appendDebug('Debug message 2'); |
| 151 | + $t2->expects($this->once())->method('send')->will($this->throwException($e2)); |
| 152 | + $t = new RoundRobinTransport([$t1, $t2]); |
| 153 | + |
| 154 | + try { |
| 155 | + $t->send(new RawMessage('')); |
| 156 | + } catch (TransportExceptionInterface $e) { |
| 157 | + $this->assertStringContainsString($e1->getDebug(), $e->getDebug()); |
| 158 | + $this->assertStringContainsString($e2->getDebug(), $e->getDebug()); |
| 159 | + |
| 160 | + return; |
| 161 | + } |
| 162 | + |
| 163 | + $this->fail('Expected exception was not thrown!'); |
| 164 | + } |
| 165 | + |
140 | 166 | private function assertTransports(RoundRobinTransport $transport, int $cursor, array $deadTransports)
|
141 | 167 | {
|
142 | 168 | $p = new \ReflectionProperty($transport, 'cursor');
|
|
0 commit comments