@@ -60,6 +60,46 @@ public function it_uses_the_configured_send_email_job()
6060 $ this ->assertContainsOnlyInstancesOf (CustomSendEmail::class, $ jobs );
6161 }
6262
63+ #[Test]
64+ #[DataProvider('sendEmailJobProvider ' )]
65+ public function it_passes_addresses_to_the_job_as_comma_separated_strings (string $ class )
66+ {
67+ config (['statamic.forms.send_email_job ' => $ class ]);
68+
69+ $ form = tap (Form ::make ('test ' )->connections (['email ' => [
70+ [
71+ 'id ' => 'one ' ,
72+ 'to ' => ['field:email ' , 'first@example.com ' ],
73+ 'cc ' => ['cc@example.com ' ],
74+ 'bcc ' => ['{{ x ?? "a@example.com, b@example.com" }} ' , 'bcc@example.com ' ],
75+ 'reply_to ' => ['field:email ' ],
76+ 'from ' => 'sender@example.com ' ,
77+ ],
78+ ['id ' => 'two ' , 'to ' => 'legacy@example.com, other@example.com ' ],
79+ ]]))->save ();
80+
81+ $ jobs = (new Email )->forForm ($ form )->finalized ($ form ->makeSubmission ());
82+
83+ $ this ->assertContainsOnlyInstancesOf ($ class , $ jobs );
84+ $ this ->assertSame ([
85+ 'id ' => 'one ' ,
86+ 'to ' => 'field:email, first@example.com ' ,
87+ 'cc ' => 'cc@example.com ' ,
88+ 'bcc ' => '{{ x ?? "a@example.com, b@example.com" }}, bcc@example.com ' ,
89+ 'reply_to ' => 'field:email ' ,
90+ 'from ' => 'sender@example.com ' ,
91+ ], $ jobs [0 ]->config );
92+ $ this ->assertSame (['id ' => 'two ' , 'to ' => 'legacy@example.com, other@example.com ' ], $ jobs [1 ]->config );
93+ }
94+
95+ public static function sendEmailJobProvider (): array
96+ {
97+ return [
98+ 'core job ' => [SendEmail::class],
99+ 'custom job ' => [CustomSendEmail::class],
100+ ];
101+ }
102+
63103 #[Test]
64104 public function it_filters_emails_using_conditions_when_finalized ()
65105 {
@@ -573,6 +613,22 @@ public function it_converts_legacy_address_strings_into_arrays(string $handle)
573613 $ this ->assertEquals (['first@example.com ' , 'second@example.com ' ], $ configs [0 ][$ handle ]);
574614 }
575615
616+ #[Test]
617+ public function it_doesnt_split_legacy_address_strings_inside_antlers ()
618+ {
619+ $ form = tap (Form ::make ('test ' )->connections (['email ' => [
620+ ['id ' => 'one ' , 'to ' => '{{ x ?? "a@example.com, b@example.com" }}, {{ partial:foo a= \'1,2 \' }}, c@example.com ' ],
621+ ]]))->save ();
622+
623+ $ configs = (new Email )->setForm ($ form )->preProcess ($ form ->connections ()->get ('email ' ));
624+
625+ $ this ->assertEquals ([
626+ '{{ x ?? "a@example.com, b@example.com" }} ' ,
627+ "{{ partial:foo a='1,2' }} " ,
628+ 'c@example.com ' ,
629+ ], $ configs [0 ]['to ' ]);
630+ }
631+
576632 #[Test]
577633 public function legacy_address_strings_are_converted_before_meta_is_built ()
578634 {
0 commit comments