File tree Expand file tree Collapse file tree 2 files changed +36
-2
lines changed
Expand file tree Collapse file tree 2 files changed +36
-2
lines changed Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments