示例#1
0
 public function __construct(array $options)
 {
     if (!isset($options['application_id'])) {
         throw new \InvalidArgumentException('Argumento \'application_id\' é requerido.');
     }
     if (!isset($options['access_token'])) {
         throw new \InvalidArgumentException('Argumento \'access_token\' é requerido.');
     }
     $this->wrapper = ClientPush::create()->setApplication($options['application_id'])->setAuth($options['access_token']);
 }
示例#2
0
 /**
  * Test method for the <tt>unregisterDevice($unregisterDeviceRequest)</tt> function.
  *
  * @group PushwooshTest.testUnregisterDevice
  */
 public function testUnregisterDevice()
 {
     // Create a fake CURL client
     $cURLClient = $this->getMock('Gomoob\\Pushwoosh\\ICURLClient');
     $cURLClient->expects($this->any())->method('pushwooshCall')->will($this->returnValue(array('status_code' => 200, 'status_message' => 'OK')));
     $pushwoosh = new Pushwoosh();
     $pushwoosh->setCURLClient($cURLClient);
     $unregisterDeviceRequest = UnregisterDeviceRequest::create()->setHwid('hwid');
     // Test with the 'application' parameter not defined
     try {
         $pushwoosh->unregisterDevice($unregisterDeviceRequest);
         $this->fail('Must have thrown a PushwooshException !');
     } catch (PushwooshException $pe) {
         // Expected
     }
     // Test with the 'application' parameter defined in the Pushwoosh client
     $pushwoosh->setApplication('APPLICATION');
     $unregisterDeviceRequest->setApplication(null);
     $pushwoosh->unregisterDevice($unregisterDeviceRequest);
     // Test with the 'application' parameter definied in the request
     $pushwoosh->setApplication(null);
     $unregisterDeviceRequest->setApplication('APPLICATION');
     $unregisterDeviceResponse = $pushwoosh->unregisterDevice($unregisterDeviceRequest);
     $this->assertTrue($unregisterDeviceResponse->isOk());
     $this->assertEquals(200, $unregisterDeviceResponse->getStatusCode());
     $this->assertEquals('OK', $unregisterDeviceResponse->getStatusMessage());
     // Test a call with an error response
     $cURLClient = $this->getMock('Gomoob\\Pushwoosh\\ICURLClient');
     $cURLClient->expects($this->any())->method('pushwooshCall')->will($this->returnValue(array('status_code' => 400, 'status_message' => 'KO')));
     $pushwoosh->setCURLClient($cURLClient);
     $unregisterDeviceResponse = $pushwoosh->unregisterDevice($unregisterDeviceRequest);
     $this->assertFalse($unregisterDeviceResponse->isOk());
     $this->assertEquals(400, $unregisterDeviceResponse->getStatusCode());
     $this->assertEquals('KO', $unregisterDeviceResponse->getStatusMessage());
 }
示例#3
0
 /**
  * Get the Pushwoosh client.
  *
  * @param string[] $auth
  *
  * @return \Gomoob\Pushwoosh\Client\Pushwoosh
  */
 protected function getClient(array $auth)
 {
     return Pushwoosh::create()->setApplication($auth['app'])->setAuth($auth['token']);
 }