@@ -20,8 +20,6 @@ final class PushServiceTest extends PHPUnit\Framework\TestCase
2020 private static $ portNumber = 9012 ;
2121 private static $ testSuiteId ;
2222 private static $ testServiceUrl ;
23- private static $ gcmSenderId = '759071690750 ' ;
24- private static $ gcmApiKey = 'AIzaSyBAU0VfXoskxUSg81K5VgLgwblHbZWe6tA ' ;
2523 private static $ vapidKeys = [
2624 'subject ' => 'http://test.com ' ,
2725 'publicKey ' => 'BA6jvk34k6YjElHQ6S0oZwmrsqHdCNajxcod6KJnI77Dagikfb--O_kYXcR2eflRz6l3PcI2r8fPCH3BElLQHDk ' ,
@@ -63,30 +61,10 @@ protected function setUp()
6361 public function browserProvider ()
6462 {
6563 return [
66- // Web Push
67- ['firefox ' , 'stable ' , []],
68- ['firefox ' , 'beta ' , []],
69-
70- // Web Push + GCM
71- ['chrome ' , 'stable ' , ['GCM ' => self ::$ gcmApiKey ]],
72- ['chrome ' , 'beta ' , ['GCM ' => self ::$ gcmApiKey ]],
73-
74- ['firefox ' , 'stable ' , ['GCM ' => self ::$ gcmApiKey ]],
75- ['firefox ' , 'beta ' , ['GCM ' => self ::$ gcmApiKey ]],
76-
77- // Web Push + VAPID
78- ['chrome ' , 'stable ' , ['VAPID ' => self ::$ vapidKeys ]],
79- ['chrome ' , 'beta ' , ['VAPID ' => self ::$ vapidKeys ]],
80-
8164 ['firefox ' , 'stable ' , ['VAPID ' => self ::$ vapidKeys ]],
8265 ['firefox ' , 'beta ' , ['VAPID ' => self ::$ vapidKeys ]],
83-
84- // Web Push + GCM + VAPID
85- ['chrome ' , 'stable ' , ['GCM ' => self ::$ gcmApiKey , 'VAPID ' => self ::$ vapidKeys ]],
86- ['chrome ' , 'beta ' , ['GCM ' => self ::$ gcmApiKey , 'VAPID ' => self ::$ vapidKeys ]],
87-
88- ['firefox ' , 'stable ' , ['GCM ' => self ::$ gcmApiKey , 'VAPID ' => self ::$ vapidKeys ]],
89- ['firefox ' , 'beta ' , ['GCM ' => self ::$ gcmApiKey , 'VAPID ' => self ::$ vapidKeys ]],
66+ ['chrome ' , 'stable ' , ['VAPID ' => self ::$ vapidKeys ]],
67+ ['chrome ' , 'beta ' , ['VAPID ' => self ::$ vapidKeys ]],
9068 ];
9169 }
9270
@@ -131,10 +109,6 @@ protected function createClosureTest($browserId, $browserVersion, $options)
131109 'browserVersion ' => $ browserVersion ,
132110 ];
133111
134- if (array_key_exists ('GCM ' , $ options )) {
135- $ subscriptionParameters ['gcmSenderId ' ] = self ::$ gcmSenderId ;
136- }
137-
138112 if (array_key_exists ('VAPID ' , $ options )) {
139113 $ subscriptionParameters ['vapidPublicKey ' ] = self ::$ vapidKeys ['publicKey ' ];
140114 }
@@ -175,49 +149,37 @@ protected function createClosureTest($browserId, $browserVersion, $options)
175149 }
176150
177151 $ subscription = new Subscription ($ endpoint , $ p256dh , $ auth , $ contentEncoding );
178-
179- try {
180- $ report = $ this ->webPush ->sendOneNotification ($ subscription , $ payload );
181- $ this ->assertInstanceOf (\Minishlink \WebPush \MessageSentReport::class, $ report );
182- $ this ->assertTrue ($ report ->isSuccess ());
183-
184- $ dataString = json_encode ([
185- 'testSuiteId ' => self ::$ testSuiteId ,
186- 'testId ' => $ testId ,
187- ]);
188-
189- $ getNotificationCurl = curl_init (self ::$ testServiceUrl .'/api/get-notification-status/ ' );
190- curl_setopt_array ($ getNotificationCurl , [
191- CURLOPT_POST => true ,
192- CURLOPT_POSTFIELDS => $ dataString ,
193- CURLOPT_RETURNTRANSFER => true ,
194- CURLOPT_HTTPHEADER => [
195- 'Content-Type: application/json ' ,
196- 'Content-Length: ' .strlen ($ dataString ),
197- ],
198- CURLOPT_TIMEOUT => self ::$ timeout ,
199- ]);
200-
201- $ parsedResp = $ this ->getResponse ($ getNotificationCurl );
202-
203- if (!property_exists ($ parsedResp ->{'data ' }, 'messages ' )) {
204- throw new Exception ('web-push-testing-service error, no messages: ' .json_encode ($ parsedResp ));
205- }
206-
207- $ messages = $ parsedResp ->{'data ' }->{'messages ' };
208- $ this ->assertEquals (1 , count ($ messages ));
209- $ this ->assertEquals ($ payload , $ messages [0 ]);
210- } catch (Exception $ e ) {
211- if (strpos ($ endpoint , 'https://android.googleapis.com/gcm/send ' ) === 0
212- && !array_key_exists ('GCM ' , $ options )) {
213- if ($ e ->getMessage () !== 'No GCM API Key specified. ' ) {
214- echo $ e ;
215- }
216- $ this ->assertEquals ($ e ->getMessage (), 'No GCM API Key specified. ' );
217- } else {
218- throw $ e ;
219- }
152+ $ report = $ this ->webPush ->sendOneNotification ($ subscription , $ payload );
153+ $ this ->assertInstanceOf (\Generator::class, $ report );
154+ $ this ->assertInstanceOf (\Minishlink \WebPush \MessageSentReport::class, $ report );
155+ $ this ->assertTrue ($ report ->isSuccess ());
156+
157+ $ dataString = json_encode ([
158+ 'testSuiteId ' => self ::$ testSuiteId ,
159+ 'testId ' => $ testId ,
160+ ]);
161+
162+ $ getNotificationCurl = curl_init (self ::$ testServiceUrl .'/api/get-notification-status/ ' );
163+ curl_setopt_array ($ getNotificationCurl , [
164+ CURLOPT_POST => true ,
165+ CURLOPT_POSTFIELDS => $ dataString ,
166+ CURLOPT_RETURNTRANSFER => true ,
167+ CURLOPT_HTTPHEADER => [
168+ 'Content-Type: application/json ' ,
169+ 'Content-Length: ' .strlen ($ dataString ),
170+ ],
171+ CURLOPT_TIMEOUT => self ::$ timeout ,
172+ ]);
173+
174+ $ parsedResp = $ this ->getResponse ($ getNotificationCurl );
175+
176+ if (!property_exists ($ parsedResp ->{'data ' }, 'messages ' )) {
177+ throw new Exception ('web-push-testing-service error, no messages: ' .json_encode ($ parsedResp ));
220178 }
179+
180+ $ messages = $ parsedResp ->{'data ' }->{'messages ' };
181+ $ this ->assertEquals (1 , count ($ messages ));
182+ $ this ->assertEquals ($ payload , $ messages [0 ]);
221183 }
222184 };
223185 }
0 commit comments