1515use  phpFCMv1 \Client ;
1616use  phpFCMv1 \Notification ;
1717use  phpFCMv1 \Recipient ;
18+ use  phpFCMv1 \Config ;
1819use  \PHPUnit \Framework \TestCase ;
1920
2021class  FCMTest extends  TestCase {
@@ -24,6 +25,7 @@ class FCMTest extends TestCase {
2425
2526    const  TEST_TITLE  = 'Testing from Code ' ;
2627    const  TEST_BODY  = 'Using phpFCMv1! ' ;
28+     const  TEST_IMAGE  = 'https://fastly.picsum.photos/id/982/300/200.jpg?hmac=rd0sm-A6tmsIiavEE2p9ynoCVr9RDUCjJMjqOH7_pvA ' ;
2729
2830    public  function  testBuild () {
2931        $ fcm$ this buildNotification (self ::TEST_TITLE , self ::TEST_BODY );
@@ -49,6 +51,35 @@ public function testFire() {
4951        $ this assertTrue ($ result
5052    }
5153
54+     public  function  testBuildWithImage () {
55+         $ fcm$ this buildNotificationImage (self ::TEST_TITLE , self ::TEST_BODY );
56+         $ payload$ fcmgetPayload ();
57+ 
58+         $ expectedarray (
59+             'token '  => self ::DEVICE_TOKEN ,
60+             'notification '  => array (
61+                 'title '  => self ::TEST_TITLE ,
62+                 'body '  => self ::TEST_BODY 
63+             ),
64+             'android '  => array (
65+                 'notification '  => array (
66+                     'image '  => self ::TEST_IMAGE 
67+                 )
68+             )
69+         );
70+         $ this assertArrayHasKey ('message ' , $ payload
71+         $ this assertEquals ($ expected$ payload'message ' ]);
72+     }
73+ 
74+     public  function  testFireImage () {
75+         
76+         $ fcm$ this buildNotificationImage (self ::TEST_TITLE , self ::TEST_BODY );
77+         $ result$ fcmfire ();
78+         echo  $ result
79+ 
80+         $ this assertTrue ($ result
81+     }
82+ 
5283    public  function  testFireWithIncorrectPayload () {
5384        // $this -> markTestSkipped(__METHOD__ . ' already passed'); 
5485        $ fcm$ this buildNotification (self ::TEST_TITLE , self ::TEST_BODY );
@@ -82,6 +113,29 @@ public function buildNotification($TEST_TITLE, $TEST_BODY, CommonConfig $config
82113        return  $ fcm
83114    }
84115
116+     /** 
117+      * @param $TEST_TITLE 
118+      * @param $TEST_BODY 
119+      * @param CommonConfig|null $config 
120+      * @return Client 
121+      */ 
122+     public  function  buildNotificationImage ($ TEST_TITLE $ TEST_BODY CommonConfig $ confignull ) {
123+         $ recipientnew  Recipient ();
124+         $ recipientsetSingleRecipient (self ::DEVICE_TOKEN );
125+ 
126+         $ notificationnew  Notification ();
127+         $ notificationsetNotification ($ TEST_TITLE $ TEST_BODY 
128+ 
129+         $ confignew  Config ();
130+         $ configsetImage (self ::TEST_IMAGE );
131+ 
132+         $ fcmnew  Client (self ::KEY_FILE );
133+         $ fcmsetValidateOnly (true );
134+         $ fcmbuild ($ recipient$ notificationnull , $ config
135+ 
136+         return  $ fcm
137+     }
138+ 
85139    /** 
86140     * @param $config 
87141     * @return bool 
0 commit comments