Skip to content

Commit 85f9fd9

Browse files
committed
Merge branch 'pull/2169'
2 parents b66917a + 5cf554d commit 85f9fd9

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

src/Forms/Email.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ protected function addViews()
6868
$this->text($text);
6969
}
7070

71-
return $this->view($html);
71+
if ($html) {
72+
$this->view($html);
73+
}
74+
75+
return $this;
7276
}
7377

7478
protected function addData()
@@ -124,7 +128,7 @@ protected function parseConfig(array $config)
124128
$data = $this->submission->toArray();
125129

126130
return collect($config)->map(function ($value) use ($data) {
127-
return Parse::template(Parse::env($value), $data);
131+
return (string) Parse::template(Parse::env($value), $data);
128132
});
129133
}
130134
}

tests/Forms/EmailTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace Tests\Forms;
4+
5+
use Mockery as m;
6+
use Statamic\Facades\Antlers;
7+
use Statamic\Forms\Email;
8+
use Statamic\Forms\Submission;
9+
use Tests\TestCase;
10+
11+
class EmailTest extends TestCase
12+
{
13+
/** @test */
14+
public function it_sets_html_view_as_string()
15+
{
16+
/** @var Submission */
17+
$submission = m::mock(Submission::class);
18+
$submission->shouldReceive('toArray')->andReturn([]);
19+
20+
$email = new Email($submission, [
21+
'to' => Antlers::parse('test@example.com'),
22+
'html' => Antlers::parse('emails/test'),
23+
]);
24+
25+
$email->build();
26+
27+
$this->assertTrue(is_string($email->view), 'View is not a string.');
28+
$this->assertEquals('emails/test', $email->view);
29+
}
30+
}

0 commit comments

Comments
 (0)