Exemplo n.º 1
0
 public function testSetGetIsCritical()
 {
     $rules = new SimpleNotificationRules();
     $this->assertFalse($rules->isCritical());
     $rules->setCritical(true);
     $this->assertTrue($rules->isCritical());
     $rules->setCritical(false);
     $this->assertFalse($rules->isCritical());
 }
 public function testSubmitCriticalNotificationWithInboxNotificationSettingEnabledAndEmailNotificationSettingDisabled()
 {
     $initialNotificationCount = Notification::getCount();
     $initialEmailMessageCount = EmailMessage::getCount();
     $rules = new SimpleNotificationRules();
     $rules->setAllowDuplicates(true);
     $rules->addUser($this->user);
     $rules->setCritical(true);
     $inboxAndEmailNotificationSettings = UserTestHelper::getDefaultNotificationSettingsValuesForTestUser();
     $inboxAndEmailNotificationSettings['enableSimpleNotification']['email'] = false;
     $inboxAndEmailNotificationSettings['enableSimpleNotification']['inbox'] = true;
     UserNotificationUtil::setValue($this->user, $inboxAndEmailNotificationSettings, 'inboxAndEmailNotificationSettings', false);
     $this->assertFalse(UserNotificationUtil::isEnabledByUserAndNotificationNameAndType($this->user, 'enableSimpleNotification', 'email'));
     $this->assertTrue(UserNotificationUtil::isEnabledByUserAndNotificationNameAndType($this->user, 'enableSimpleNotification', 'inbox'));
     $message = new NotificationMessage();
     $message->textContent = 'text content for' . __FUNCTION__;
     $message->htmlContent = 'html content for' . __FUNCTION__;
     NotificationsUtil::submit($message, $rules);
     $this->assertEquals($initialNotificationCount + 1, Notification::getCount());
     $this->assertEquals($initialEmailMessageCount, EmailMessage::getCount());
 }