File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -185,7 +185,7 @@ public function toArray()
185185 {
186186 $ message = [
187187 'contents ' => ['en ' => $ this ->body ],
188- 'headings ' => [ ' en ' => $ this ->subject ] ,
188+ 'headings ' => $ this ->subjectToArray () ,
189189 'url ' => $ this ->url ,
190190 'buttons ' => $ this ->buttons ,
191191 'web_buttons ' => $ this ->webButtons ,
@@ -205,4 +205,13 @@ public function toArray()
205205
206206 return $ message ;
207207 }
208+
209+ protected function subjectToArray ()
210+ {
211+ if ($ this ->subject === null ) {
212+ return [];
213+ }
214+
215+ return ['en ' => $ this ->subject ];
216+ }
208217}
Original file line number Diff line number Diff line change @@ -50,6 +50,12 @@ public function it_can_set_the_subject()
5050 $ this ->assertEquals ('mySubject ' , Arr::get ($ this ->message ->toArray (), 'headings.en ' ));
5151 }
5252
53+ /** @test */
54+ public function it_does_not_append_empty_subject_value_when_subject_is_null ()
55+ {
56+ $ this ->assertEquals ([], Arr::get ($ this ->message ->toArray (), 'headings ' ));
57+ }
58+
5359 /** @test */
5460 public function it_can_set_the_url ()
5561 {
You can’t perform that action at this time.
0 commit comments