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