/**
  * Test method for the <tt>toJSON()</tt> function.
  */
 public function testToJSON()
 {
     $getTagsRequest = new GetTagsRequest();
     // Test without the 'application' parameter set
     try {
         $getTagsRequest->toJSON();
         $this->fail('Must have thrown a PushwooshException !');
     } catch (PushwooshException $pe) {
         // Expected
     }
     // Test without the 'auth' parameter set
     $getTagsRequest->setApplication('APPLICATION');
     try {
         $getTagsRequest->toJSON();
         $this->fail('Must have thrown a PushwooshException !');
     } catch (PushwooshException $pe) {
         // Expected
     }
     // Test without the 'hwid' parameter set
     $getTagsRequest->setAuth('XXXXXXXX');
     try {
         $getTagsRequest->toJSON();
         $this->fail('Must have thrown a PushwooshException !');
     } catch (PushwooshException $pe) {
         // Expected
     }
     $getTagsRequest->setHwid('HWID');
     // Test with valid values
     $array = $getTagsRequest->toJSON();
     $this->assertEquals('APPLICATION', $array['application']);
     $this->assertEquals('XXXXXXXX', $array['auth']);
     $this->assertEquals('HWID', $array['hwid']);
 }
Example #2
0
 /**
  * {@inheritDoc}
  */
 public function getTags(GetTagsRequest $getTagsRequest)
 {
     // If the 'application' attribute is not set in the request we try to get a default one from the Pushwoosh
     // client
     if ($getTagsRequest->getApplication() === null) {
         // The 'application' must be set
         if (!isset($this->application)) {
             throw new PushwooshException('The  \'application\' property is not set !');
         }
         $getTagsRequest->setApplication($this->application);
     }
     // If the 'auth' parameter is not set in the request we try to get it from the Pushwoosh client
     if ($getTagsRequest->getAuth() === null) {
         // The 'auth' parameter is expected here
         if (!isset($this->auth)) {
             throw new PushwooshException('The \'auth\' parameter is not set !');
             // Use the 'auth' parameter defined in the Pushwoosh client
         } else {
             $getTagsRequest->setAuth($this->auth);
         }
     }
     $response = $this->cURLClient->pushwooshCall('getTags', $getTagsRequest->jsonSerialize());
     return GetTagsResponse::create($response);
 }