/** * Test method for the <tt>toJSON()</tt> function. */ public function testToJSON() { $unregisterDeviceRequest = new UnregisterDeviceRequest(); // Test without the 'application' parameter set try { $unregisterDeviceRequest->toJSON(); $this->fail('Must have thrown a PushwooshException !'); } catch (PushwooshException $pe) { // Expected } // Test without the 'hwid' parameter set $unregisterDeviceRequest->setApplication('APPLICATION'); try { $unregisterDeviceRequest->toJSON(); $this->fail('Must have thrown a PushwooshException !'); } catch (PushwooshException $pe) { // Expected } $unregisterDeviceRequest->setHwid('HWID'); // Test with valid values $array = $unregisterDeviceRequest->toJSON(); $this->assertEquals('APPLICATION', $unregisterDeviceRequest->getApplication()); $this->assertEquals('HWID', $unregisterDeviceRequest->getHwid()); }
/** * {@inheritDoc} */ public function unregisterDevice(UnregisterDeviceRequest $unregisterDeviceRequest) { // If the 'application' attribute is not set in the request we try to get a default one from the Pushwoosh // client if ($unregisterDeviceRequest->getApplication() === null) { // The 'application' must be set if (!isset($this->application)) { throw new PushwooshException('The \'application\' property is not set !'); } $unregisterDeviceRequest->setApplication($this->application); } $response = $this->cURLClient->pushwooshCall('unregisterDevice', $unregisterDeviceRequest->toJSON()); return UnregisterDeviceResponse::create($response); }