Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 10effd7

Browse filesBrowse files
derrabusnicolas-grekas
authored andcommitted
[Mime] Allow array as input for RawMessage
Signed-off-by: Alexander M. Turek <me@derrabus.de>
1 parent 4f1e0dd commit 10effd7
Copy full SHA for 10effd7

File tree

2 files changed

+18
-10
lines changed
Filter options

2 files changed

+18
-10
lines changed

‎src/Symfony/Component/Mime/RawMessage.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mime/RawMessage.php
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ public function toString(): string
3333
if (\is_string($this->message)) {
3434
return $this->message;
3535
}
36+
if ($this->message instanceof \Traversable) {
37+
$this->message = iterator_to_array($this->message, false);
38+
}
3639

37-
return $this->message = implode('', iterator_to_array($this->message, false));
40+
return $this->message = implode('', $this->message);
3841
}
3942

4043
public function toIterable(): iterable

‎src/Symfony/Component/Mime/Tests/RawMessageTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mime/Tests/RawMessageTest.php
+14-9Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,28 @@
1616

1717
class RawMessageTest extends TestCase
1818
{
19-
public function testToString()
19+
/**
20+
* @dataProvider provideMessages
21+
*/
22+
public function testToString($messageParameter)
2023
{
21-
$message = new RawMessage('string');
22-
$this->assertEquals('string', $message->toString());
23-
$this->assertEquals('string', implode('', iterator_to_array($message->toIterable())));
24-
// calling methods more than once work
25-
$this->assertEquals('string', $message->toString());
26-
$this->assertEquals('string', implode('', iterator_to_array($message->toIterable())));
27-
28-
$message = new RawMessage(new \ArrayObject(['some', ' ', 'string']));
24+
$message = new RawMessage($messageParameter);
2925
$this->assertEquals('some string', $message->toString());
3026
$this->assertEquals('some string', implode('', iterator_to_array($message->toIterable())));
3127
// calling methods more than once work
3228
$this->assertEquals('some string', $message->toString());
3329
$this->assertEquals('some string', implode('', iterator_to_array($message->toIterable())));
3430
}
3531

32+
public function provideMessages(): array
33+
{
34+
return [
35+
'string' => ['some string'],
36+
'traversable' => [new \ArrayObject(['some', ' ', 'string'])],
37+
'array' => [['some', ' ', 'string']],
38+
];
39+
}
40+
3641
public function testSerialization()
3742
{
3843
$message = new RawMessage('string');

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.