|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Symfony package. |
| 5 | + * |
| 6 | + * (c) Fabien Potencier <[email protected]> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Symfony\Component\Mailer\Tests\EventListener; |
| 13 | + |
| 14 | +use PHPUnit\Framework\TestCase; |
| 15 | +use Symfony\Component\Mailer\Envelope; |
| 16 | +use Symfony\Component\Mailer\Event\MessageEvent; |
| 17 | +use Symfony\Component\Mailer\EventListener\EnvelopeListener; |
| 18 | +use Symfony\Component\Mime\Address; |
| 19 | +use Symfony\Component\Mime\RawMessage; |
| 20 | + |
| 21 | +class EnvelopeListenerTest extends TestCase |
| 22 | +{ |
| 23 | + /** |
| 24 | + * @dataProvider provideRecipientsTests |
| 25 | + */ |
| 26 | + public function testRecipients(array $expected, ?array $recipients = null, array $allowedRecipients = []) |
| 27 | + { |
| 28 | + $listener = new EnvelopeListener(null, $recipients, $allowedRecipients); |
| 29 | + $message = new RawMessage('message'); |
| 30 | + $envelope = new Envelope( new Address( '[email protected]'), [ new Address( '[email protected]'), new Address( '[email protected]')]); |
| 31 | + $event = new MessageEvent($message, $envelope, 'default'); |
| 32 | + |
| 33 | + $listener->onMessage($event); |
| 34 | + |
| 35 | + $recipients = array_map(fn (Address $a): string => $a->getAddress(), $event->getEnvelope()->getRecipients()); |
| 36 | + $this->assertSame($expected, $recipients); |
| 37 | + } |
| 38 | + |
| 39 | + public static function provideRecipientsTests(): iterable |
| 40 | + { |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | + } |
| 46 | +} |
0 commit comments