|
12 | 12 | namespace Symfony\Component\Mime\Tests;
|
13 | 13 |
|
14 | 14 | use PHPUnit\Framework\TestCase;
|
| 15 | +use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait; |
15 | 16 | use Symfony\Component\Mime\RawMessage;
|
16 | 17 |
|
17 | 18 | class RawMessageTest extends TestCase
|
18 | 19 | {
|
| 20 | + use ExpectDeprecationTrait; |
| 21 | + |
19 | 22 | /**
|
20 | 23 | * @dataProvider provideMessages
|
21 | 24 | */
|
@@ -46,6 +49,37 @@ public function testSerialization(mixed $messageParameter, bool $supportReuse)
|
46 | 49 | }
|
47 | 50 | }
|
48 | 51 |
|
| 52 | + /** |
| 53 | + * @dataProvider provideMessages |
| 54 | + */ |
| 55 | + public function testToIterable(mixed $messageParameter, bool $supportReuse) |
| 56 | + { |
| 57 | + $message = new RawMessage($messageParameter); |
| 58 | + $this->assertEquals('some string', implode('', iterator_to_array($message->toIterable()))); |
| 59 | + |
| 60 | + if ($supportReuse) { |
| 61 | + // calling methods more than once work |
| 62 | + $this->assertEquals('some string', implode('', iterator_to_array($message->toIterable()))); |
| 63 | + } |
| 64 | + } |
| 65 | + |
| 66 | + /** |
| 67 | + * @dataProvider provideMessages |
| 68 | + * |
| 69 | + * @group legacy |
| 70 | + */ |
| 71 | + public function testToIterableLegacy(mixed $messageParameter, bool $supportReuse) |
| 72 | + { |
| 73 | + $message = new RawMessage($messageParameter); |
| 74 | + $this->assertEquals('some string', implode('', iterator_to_array($message->toIterable()))); |
| 75 | + |
| 76 | + if (!$supportReuse) { |
| 77 | + // in 7.0, the test with a generator will throw an exception |
| 78 | + $this->expectDeprecation('Since symfony/mime 6.4: Sending an email with a closed generator is deprecated and will throw in 7.0.'); |
| 79 | + $this->assertEquals('some string', implode('', iterator_to_array($message->toIterable()))); |
| 80 | + } |
| 81 | + } |
| 82 | + |
49 | 83 | public static function provideMessages(): array
|
50 | 84 | {
|
51 | 85 | return [
|
|
0 commit comments