public function testSendGCMNotificationWithWrongGCMApiKey() { $webPush = new WebPush(array('GCM' => 'bar')); $res = $webPush->sendNotification($this->endpoints['GCM'], null, null, true); $this->assertTrue(is_array($res)); // there has been an error $this->assertArrayHasKey('success', $res); $this->assertEquals(false, $res['success']); $this->assertArrayHasKey('statusCode', $res); $this->assertEquals(401, $res['statusCode']); $this->assertArrayHasKey('headers', $res); }
$webPush = new WebPush(array('GCM' => $push_api)); $endpoints = get_endpoints("Voting_End30"); // send multiple notifications foreach ($endpoints as $endpoint) { $webPush->sendNotification($endpoint['Endpoint']); } $webPush->flush(); } if (in_array("Voting_End", get_event(3600))) { $to = get_emails("Voting_End60"); $message = ' <html> <body> <p>Dear HiveMember,</p> <p>You are yet to vote for this weeks film night. Voting closes in an hour. <p>Please <a href="https://films.jakestockwin.co.uk/voting.php">click here</a> to vote</p> <br> <p>Best wishes,<br>The HiveBot™</p> </body> </html> '; mail($to, "Film Night Voting", $message, "Content-type:text/html"); $webPush = new WebPush(array('GCM' => $push_api)); $endpoints = get_endpoints("Voting_End60"); // send multiple notifications foreach ($endpoints as $endpoint) { $webPush->sendNotification($endpoint['Endpoint']); } $webPush->flush(); } }
public function testSendGCMNotificationWithWrongGCMApiKey() { if (substr(self::$endpoints['GCM'], 0, strlen(WebPush::GCM_URL)) !== WebPush::GCM_URL) { $this->markTestSkipped('The provided GCM URL is not a GCM URL, but probably a FCM URL.'); } $webPush = new WebPush(array('GCM' => 'bar')); $res = $webPush->sendNotification(self::$endpoints['GCM'], null, null, null, true); $this->assertTrue(is_array($res)); // there has been an error $this->assertArrayHasKey('success', $res); $this->assertFalse($res['success']); $this->assertArrayHasKey('statusCode', $res); $this->assertEquals(400, $res['statusCode']); $this->assertArrayHasKey('headers', $res); $this->assertArrayHasKey('endpoint', $res); $this->assertEquals(self::$endpoints['GCM'], $res['endpoint']); }