@@ -20,8 +20,6 @@ final class PushServiceTest extends PHPUnit\Framework\TestCase
20
20
private static $ portNumber = 9012 ;
21
21
private static $ testSuiteId ;
22
22
private static $ testServiceUrl ;
23
- private static $ gcmSenderId = '759071690750 ' ;
24
- private static $ gcmApiKey = 'AIzaSyBAU0VfXoskxUSg81K5VgLgwblHbZWe6tA ' ;
25
23
private static $ vapidKeys = [
26
24
'subject ' => 'http://test.com ' ,
27
25
'publicKey ' => 'BA6jvk34k6YjElHQ6S0oZwmrsqHdCNajxcod6KJnI77Dagikfb--O_kYXcR2eflRz6l3PcI2r8fPCH3BElLQHDk ' ,
@@ -63,30 +61,10 @@ protected function setUp()
63
61
public function browserProvider ()
64
62
{
65
63
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
-
81
64
['firefox ' , 'stable ' , ['VAPID ' => self ::$ vapidKeys ]],
82
65
['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 ]],
90
68
];
91
69
}
92
70
@@ -131,10 +109,6 @@ protected function createClosureTest($browserId, $browserVersion, $options)
131
109
'browserVersion ' => $ browserVersion ,
132
110
];
133
111
134
- if (array_key_exists ('GCM ' , $ options )) {
135
- $ subscriptionParameters ['gcmSenderId ' ] = self ::$ gcmSenderId ;
136
- }
137
-
138
112
if (array_key_exists ('VAPID ' , $ options )) {
139
113
$ subscriptionParameters ['vapidPublicKey ' ] = self ::$ vapidKeys ['publicKey ' ];
140
114
}
@@ -175,49 +149,37 @@ protected function createClosureTest($browserId, $browserVersion, $options)
175
149
}
176
150
177
151
$ 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 ));
220
178
}
179
+
180
+ $ messages = $ parsedResp ->{'data ' }->{'messages ' };
181
+ $ this ->assertEquals (1 , count ($ messages ));
182
+ $ this ->assertEquals ($ payload , $ messages [0 ]);
221
183
}
222
184
};
223
185
}
0 commit comments