示例#1
0
 /**
  * @dataProvider dataSetMessage
  * @param string $message
  * @param array $parameters
  */
 public function testSetMessage($message, $parameters)
 {
     $this->assertSame('', $this->notification->getMessage());
     $this->assertSame([], $this->notification->getMessageParameters());
     $this->assertSame($this->notification, $this->notification->setMessage($message, $parameters));
     $this->assertSame($message, $this->notification->getMessage());
     $this->assertSame($parameters, $this->notification->getMessageParameters());
 }
示例#2
0
 /**
  * Turn a notification into an input statement
  *
  * @param IQueryBuilder $sql
  * @param INotification $notification
  */
 protected function sqlInsert(IQueryBuilder $sql, INotification $notification)
 {
     $sql->setValue('app', $sql->createParameter('app'))->setParameter('app', $notification->getApp());
     $sql->setValue('user', $sql->createParameter('user'))->setParameter('user', $notification->getUser());
     $sql->setValue('timestamp', $sql->createParameter('timestamp'))->setParameter('timestamp', $notification->getDateTime()->getTimestamp());
     $sql->setValue('object_type', $sql->createParameter('objectType'))->setParameter('objectType', $notification->getObjectType());
     $sql->setValue('object_id', $sql->createParameter('objectId'))->setParameter('objectId', $notification->getObjectId());
     $sql->setValue('subject', $sql->createParameter('subject'))->setParameter('subject', $notification->getSubject());
     $sql->setValue('subject_parameters', $sql->createParameter('subject_parameters'))->setParameter('subject_parameters', json_encode($notification->getSubjectParameters()));
     $sql->setValue('message', $sql->createParameter('message'))->setParameter('message', $notification->getMessage());
     $sql->setValue('message_parameters', $sql->createParameter('message_parameters'))->setParameter('message_parameters', json_encode($notification->getMessageParameters()));
     $sql->setValue('link', $sql->createParameter('link'))->setParameter('link', $notification->getLink());
     $actions = [];
     foreach ($notification->getActions() as $action) {
         /** @var IAction $action */
         $actions[] = ['label' => $action->getLabel(), 'link' => $action->getLink(), 'type' => $action->getRequestType(), 'primary' => $action->isPrimary()];
     }
     $sql->setValue('actions', $sql->createParameter('actions'))->setParameter('actions', json_encode($actions));
 }