public function testResponse()
 {
     $responseArr = array('results' => array(array('message_id' => '1:234')), 'success' => 1, 'failure' => 0, 'canonical_ids' => 0, 'multicast_id' => '123');
     $response = new Response();
     $response->setResponse($responseArr);
     $this->assertEquals($responseArr, $response->getResponse());
     $this->assertEquals(1, $response->getSuccessCount());
     $this->assertEquals(0, $response->getFailureCount());
     $this->assertEquals(0, $response->getCanonicalCount());
     // test results non correlated
     $expected = array(array('message_id' => '1:234'));
     $this->assertEquals($expected, $response->getResults());
     $expected = array(0 => '1:234');
     $this->assertEquals($expected, $response->getResult(Response::RESULT_MESSAGE_ID));
     $message = new Message();
     $message->setRegistrationIds(array('ABCDEF'));
     $response->setMessage($message);
     $expected = array('ABCDEF' => '1:234');
     $this->assertEquals($expected, $response->getResult(Response::RESULT_MESSAGE_ID));
 }
Пример #2
0
 /**
  * Get service message from origin.
  *
  * @param array                                          $tokens  Tokens
  * @param \Sly\NotificationPusher\Model\MessageInterface $message Message
  *
  * @return \ZendService\Google\Gcm\Message
  */
 public function getServiceMessageFromOrigin(array $tokens, MessageInterface $message)
 {
     $data = $message->getOptions();
     $data['message'] = $message->getText();
     $serviceMessage = new ServiceMessage();
     $serviceMessage->setRegistrationIds($tokens);
     $serviceMessage->setData($data);
     $serviceMessage->setCollapseKey($this->getParameter('collapseKey'));
     $serviceMessage->setRestrictedPackageName($this->getParameter('restrictedPackageName'));
     $serviceMessage->setDelayWhileIdle($this->getParameter('delayWhileIdle', false));
     $serviceMessage->setTimeToLive($this->getParameter('ttl', 600));
     $serviceMessage->setDryRun($this->getParameter('dryRun', false));
     return $serviceMessage;
 }