コード例 #1
0
 /**
  * @param LoggerInterface $logger
  * @param Notification $notification
  * @param bool $success
  * @param array $context
  * @return bool
  */
 public function logToFile(LoggerInterface $logger, Notification $notification, $success = true, array $context = [])
 {
     $data = ['receivers' => $notification->getDevices(), 'content' => $notification->getContent(), 'data' => $notification->getData()];
     $data = array_merge($data, $context);
     if ($success) {
         $logger->info('Pushmessage sent', $data);
     } else {
         $logger->error('Error sending pushmessage', $data);
     }
     return true;
 }
コード例 #2
0
 /**
  * Test method for the <tt>addDevice($device)</tt>, <tt>getDevices()</tt> and <tt>setDevices($devices)</tt>
  * functions.
  */
 public function testAddGetSetDevices()
 {
     // Test for 'addDevice'
     $notification = new Notification();
     $this->assertNull($notification->getDevices());
     $this->assertSame($notification, $notification->addDevice('device0'));
     $this->assertSame($notification, $notification->addDevice('device1'));
     $this->assertSame($notification, $notification->addDevice('device2'));
     $devices = $notification->getDevices();
     $this->assertCount(3, $devices);
     $this->assertTrue(in_array('device0', $devices));
     $this->assertTrue(in_array('device1', $devices));
     $this->assertTrue(in_array('device2', $devices));
     // Test for 'setDevices'
     $notification = new Notification();
     $this->assertNull($notification->getDevices());
     $devices = array('device0', 'device1', 'device2');
     $this->assertSame($notification, $notification->setDevices($devices));
     $devices = $notification->getDevices();
     $this->assertCount(3, $devices);
     $this->assertTrue(in_array('device0', $devices));
     $this->assertTrue(in_array('device1', $devices));
     $this->assertTrue(in_array('device2', $devices));
 }