@@ -88,6 +88,116 @@ public function test_it_does_not_set_mutable_content_by_default()
8888 $ this ->assertNull ($ notification ->getPayload ()->hasMutableContent ());
8989 }
9090
91+ public function test_it_adapts_content_state ()
92+ {
93+ $ contentState = ['status ' => 'active ' , 'count ' => 5 ];
94+ $ message = (new ApnMessage )->contentState ($ contentState );
95+
96+ $ notification = $ this ->adapter ->adapt ($ message , 'token ' );
97+
98+ $ this ->assertEquals ($ contentState , $ notification ->getPayload ()->getContentState ());
99+ }
100+
101+ public function test_it_does_not_set_content_state_by_default ()
102+ {
103+ $ message = (new ApnMessage );
104+
105+ $ notification = $ this ->adapter ->adapt ($ message , 'token ' );
106+
107+ $ this ->assertNull ($ notification ->getPayload ()->getContentState ());
108+ }
109+
110+ public function test_it_adapts_event ()
111+ {
112+ $ message = (new ApnMessage )->event ('update ' );
113+
114+ $ notification = $ this ->adapter ->adapt ($ message , 'token ' );
115+
116+ $ this ->assertEquals ('update ' , $ notification ->getPayload ()->getEvent ());
117+ }
118+
119+ public function test_it_does_not_set_event_by_default ()
120+ {
121+ $ message = (new ApnMessage );
122+
123+ $ notification = $ this ->adapter ->adapt ($ message , 'token ' );
124+
125+ $ this ->assertNull ($ notification ->getPayload ()->getEvent ());
126+ }
127+
128+ public function test_it_adapts_timestamp ()
129+ {
130+ $ message = (new ApnMessage )->timestamp (1234567890 );
131+
132+ $ notification = $ this ->adapter ->adapt ($ message , 'token ' );
133+
134+ $ this ->assertEquals (1234567890 , $ notification ->getPayload ()->getTimestamp ());
135+ }
136+
137+ public function test_it_does_not_set_timestamp_by_default ()
138+ {
139+ $ message = (new ApnMessage );
140+
141+ $ notification = $ this ->adapter ->adapt ($ message , 'token ' );
142+
143+ $ this ->assertNull ($ notification ->getPayload ()->getTimestamp ());
144+ }
145+
146+ public function test_it_adapts_attributes_type ()
147+ {
148+ $ message = (new ApnMessage )->attributesType ('dateTime ' );
149+
150+ $ notification = $ this ->adapter ->adapt ($ message , 'token ' );
151+
152+ $ this ->assertEquals ('dateTime ' , $ notification ->getPayload ()->getAttributesType ());
153+ }
154+
155+ public function test_it_does_not_set_attributes_type_by_default ()
156+ {
157+ $ message = (new ApnMessage );
158+
159+ $ notification = $ this ->adapter ->adapt ($ message , 'token ' );
160+
161+ $ this ->assertNull ($ notification ->getPayload ()->getAttributesType ());
162+ }
163+
164+ public function test_it_adapts_attributes ()
165+ {
166+ $ attributes = ['status ' => 'active ' , 'count ' => 5 ];
167+ $ message = (new ApnMessage )->setAttributes ($ attributes );
168+
169+ $ notification = $ this ->adapter ->adapt ($ message , 'token ' );
170+
171+ $ this ->assertEquals ($ attributes , $ notification ->getPayload ()->getAttributes ());
172+ }
173+
174+ public function test_it_does_not_set_attributes_by_default ()
175+ {
176+ $ message = (new ApnMessage );
177+
178+ $ notification = $ this ->adapter ->adapt ($ message , 'token ' );
179+
180+ $ this ->assertEquals ([], $ notification ->getPayload ()->getAttributes ());
181+ }
182+
183+ public function test_it_adapts_dismissal_date ()
184+ {
185+ $ message = (new ApnMessage )->dismissalDate (1700000000 );
186+
187+ $ notification = $ this ->adapter ->adapt ($ message , 'token ' );
188+
189+ $ this ->assertEquals (1700000000 , $ notification ->getPayload ()->getDismissalDate ());
190+ }
191+
192+ public function test_it_does_not_set_dismissal_date_by_default ()
193+ {
194+ $ message = (new ApnMessage );
195+
196+ $ notification = $ this ->adapter ->adapt ($ message , 'token ' );
197+
198+ $ this ->assertNull ($ notification ->getPayload ()->getDismissalDate ());
199+ }
200+
91201 public function test_it_adapts_badge ()
92202 {
93203 $ message = new ApnMessage ()->badge (1 );
@@ -226,4 +336,13 @@ public function test_it_adapts_background_without_alert(): void
226336
227337 $ this ->assertNull ($ notification ->getPayload ()->getAlert ());
228338 }
339+
340+ public function test_it_adapts_live_activity_without_alert (): void
341+ {
342+ $ message = (new ApnMessage )->pushType ('liveactivity ' );
343+
344+ $ notification = $ this ->adapter ->adapt ($ message , 'token ' );
345+
346+ $ this ->assertNull ($ notification ->getPayload ()->getAlert ());
347+ }
229348}
0 commit comments