@@ -74,6 +74,51 @@ public function it_can_send_a_status_update_notification_with_images()
7474 $ this ->channel ->send (new TestNotifiable (), new TestNotificationWithImage ());
7575 }
7676
77+ /** @test */
78+ public function it_can_send_a_status_update_notification_with_videos ()
79+ {
80+ $ media = new stdClass ;
81+ $ media ->media_id_string = '2 ' ;
82+
83+ $ status = new stdClass ;
84+ $ status ->media_id_string = '2 ' ;
85+ $ status ->processing_info = new stdClass ;
86+ $ status ->processing_info ->state = 'completed ' ;
87+
88+ $ this ->twitter ->shouldReceive ('setTimeouts ' )
89+ ->once ()
90+ ->with (10 , 15 );
91+
92+ $ this ->twitter ->shouldReceive ('post ' )
93+ ->once ()
94+ ->with (
95+ 'statuses/update ' ,
96+ ['status ' => 'Laravel Notification Channels are awesome! ' , 'media_ids ' => '2 ' ],
97+ false
98+ )
99+ ->andReturn ([]);
100+
101+ $ this ->twitter ->shouldReceive ('upload ' )
102+ ->once ()
103+ ->with ('media/upload ' , [
104+ 'media ' => public_path ('video.mp4 ' ),
105+ 'media_category ' => 'tweet_video ' ,
106+ 'media_type ' => 'video/mp4 ' ,
107+ ], true )
108+ ->andReturn ($ media );
109+
110+ $ this ->twitter ->shouldReceive ('mediaStatus ' )
111+ ->once ()
112+ ->with ($ media ->media_id_string )
113+ ->andReturn ($ status );
114+
115+ $ this ->twitter ->shouldReceive ('getLastHttpCode ' )
116+ ->once ()
117+ ->andReturn (200 );
118+
119+ $ this ->channel ->send (new TestNotifiable (), new TestNotificationWithVideo ());
120+ }
121+
77122 /** @test */
78123 public function it_can_send_a_status_update_notification_with_reply_to_status_id (): void
79124 {
@@ -118,6 +163,42 @@ public function it_throws_an_exception_when_it_could_not_send_the_notification()
118163
119164 $ this ->channel ->send (new TestNotifiable (), new TestNotification ());
120165 }
166+
167+ /** @test */
168+ public function it_throws_an_exception_when_it_could_not_send_the_notification_with_videos ()
169+ {
170+ $ media = new stdClass ;
171+ $ media ->media_id_string = '2 ' ;
172+
173+ $ status = new stdClass ;
174+ $ status ->media_id_string = '2 ' ;
175+ $ status ->processing_info = new stdClass ;
176+ $ status ->processing_info ->state = 'failed ' ;
177+ $ status ->processing_info ->error = new stdClass ;
178+ $ status ->processing_info ->error ->message = 'invalid media ' ;
179+
180+ $ this ->twitter ->shouldReceive ('setTimeouts ' )
181+ ->once ()
182+ ->with (10 , 15 );
183+
184+ $ this ->twitter ->shouldReceive ('upload ' )
185+ ->once ()
186+ ->with ('media/upload ' , [
187+ 'media ' => public_path ('video.mp4 ' ),
188+ 'media_category ' => 'tweet_video ' ,
189+ 'media_type ' => 'video/mp4 ' ,
190+ ], true )
191+ ->andReturn ($ media );
192+
193+ $ this ->twitter ->shouldReceive ('mediaStatus ' )
194+ ->once ()
195+ ->with ($ media ->media_id_string )
196+ ->andReturn ($ status );
197+
198+ $ this ->expectException (CouldNotSendNotification::class);
199+
200+ $ this ->channel ->send (new TestNotifiable (), new TestNotificationWithVideo ());
201+ }
121202}
122203
123204class TestNotifiable
@@ -168,6 +249,17 @@ public function toTwitter(mixed $notifiable): TwitterMessage
168249 }
169250}
170251
252+ class TestNotificationWithVideo extends Notification
253+ {
254+ /**
255+ * @throws CouldNotSendNotification
256+ */
257+ public function toTwitter (mixed $ notifiable ): TwitterMessage
258+ {
259+ return (new TwitterStatusUpdate ('Laravel Notification Channels are awesome! ' ))->withVideo (public_path ('video.mp4 ' ));
260+ }
261+ }
262+
171263class TestNotificationWithReplyToStatusId extends Notification
172264{
173265 private int $ replyToStatusId ;
0 commit comments