/** * Test method for the <tt>toJSON()</tt> function. */ public function testToJSON() { $getNearestZoneRequest = new GetNearestZoneRequest(); // Test without the 'application' parameter set try { $getNearestZoneRequest->toJSON(); $this->fail('Must have thrown a PushwooshException !'); } catch (PushwooshException $pe) { // Expected } // Test without the 'hwid' parameter set $getNearestZoneRequest->setApplication('APPLICATION'); try { $getNearestZoneRequest->toJSON(); $this->fail('Must have thrown a PushwooshException !'); } catch (PushwooshException $pe) { // Expected } // Test without the 'lat' parameter set $getNearestZoneRequest->setHwid('HWID'); try { $getNearestZoneRequest->toJSON(); $this->fail('Must have thrown a PushwooshException !'); } catch (PushwooshException $pe) { // Expected } // Test without the 'lng' parameter set $getNearestZoneRequest->setLat(10.12345); try { $getNearestZoneRequest->toJSON(); $this->fail('Must have thrown a PushwooshException !'); } catch (PushwooshException $pe) { // Expected } // Test with valid values $getNearestZoneRequest->setLng(28.12345); $array = $getNearestZoneRequest->toJSON(); $this->assertEquals('APPLICATION', $array['application']); $this->assertEquals('HWID', $array['hwid']); $this->assertEquals(10.12345, $array['lat']); $this->assertEquals(28.12345, $array['lng']); }