/** * @expectedException \RuntimeException */ public function testScrapeRegistrationResponseWithInvalidDescription() { $registration = new GcmRegistration(); $registration->setToken('abcdefghijklmnopqrstuvwxyz')->setTags(array('android', 'male', 'japanese')); $response = <<<RESPONSE <entry xmlns="http://www.w3.org/2005/Atom"> <content type="application/xml"> <GcmTemplateRegistrationDescription xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect"> <ETag>3</ETag> <ExpirationTime>2014-09-01T15:57:46.778Z</ExpirationTime> <RegistrationId>2372532420827572008-85883004107185159-4</RegistrationId> <Tags>android, male, japanese</Tags> <GcmRegistrationId>abcdefghijklmnopqrstuvwxyz</GcmRegistrationId> </GcmTemplateRegistrationDescription> </content> </entry> RESPONSE; $registration->scrapeResponse($response); }
/** * Create Registration ID * * @return string Registration ID */ public function createRegistrationId() { $registration = new GcmRegistration(); // build uri $uri = $this->endpoint . $this->hubPath . "/registrationIDs/"; $token = $this->generateSasToken($uri); $headers = array_merge(array('Authorization: ' . $token), $registration->getHeaders()); $headers = array_merge(array('Content-length: 0'), $headers); $response = $this->request(self::METHOD_POST, $uri . self::API_VERSION, $headers, null, true); preg_match('#' . $uri . '([^?]+)' . preg_quote(self::API_VERSION) . '#', $response, $matches); return $matches[1]; }
/** * @expectedException \RuntimeException */ public function testDeleteRegistrationWithEtag() { $registration = new GcmRegistration(); $registration->setToken('abcdefghijklmnopqrstuvwxyz')->setRegistrationId('2372532420827572008-85883004107185159-4'); $this->mock->deleteRegistration($registration); }