コード例 #1
0
 public function testSubmitNonCritical()
 {
     $super = User::getByUsername('super');
     $emailAddress = new Email();
     $emailAddress->emailAddress = '*****@*****.**';
     $super->primaryEmail = $emailAddress;
     $saved = $super->save();
     $this->assertTrue($saved);
     $billy = User::getByUsername('billy');
     $emailAddress = new Email();
     $emailAddress->emailAddress = '*****@*****.**';
     $billy->primaryEmail = $emailAddress;
     $saved = $billy->save();
     $this->assertTrue($saved);
     $notifications = Notification::getAll();
     $this->assertEquals(0, count($notifications));
     $message = new NotificationMessage();
     $message->textContent = 'text content';
     $message->htmlContent = 'html content';
     $rules = new SimpleNotificationRules();
     $rules->addUser($super);
     $rules->addUser($billy);
     NotificationsUtil::submit($message, $rules);
     //It should not send an email because it is non-critical
     $this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount());
     $this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
     $notifications = Notification::getAll();
     $this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount());
     $this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
 }
コード例 #2
0
 public function addAndGetUsers()
 {
     $rules = new SimpleNotificationRules();
     $this->assertEquals(0, $rules->getUsers());
     $rules->addUser(User::getByUsername('billy'));
     $this->assertEquals(1, $rules->getUsers());
     //Try to add same user again.
     $rules->addUser(User::getByUsername('billy'));
     $this->assertEquals(1, $rules->getUsers());
     $rules->addUser(User::getByUsername('super'));
     $this->assertEquals(2, $rules->getUsers());
 }
コード例 #3
0
 public function testSubmitWithInboxNotificationSettingDisabledAndEmailNotificationSettingDisabled()
 {
     $initialNotificationCount = Notification::getCount();
     $initialEmailMessageCount = EmailMessage::getCount();
     $rules = new SimpleNotificationRules();
     $rules->setAllowDuplicates(true);
     $rules->addUser($this->user);
     $inboxAndEmailNotificationSettings = UserTestHelper::getDefaultNotificationSettingsValuesForTestUser();
     $inboxAndEmailNotificationSettings['enableSimpleNotification']['email'] = false;
     $inboxAndEmailNotificationSettings['enableSimpleNotification']['inbox'] = false;
     UserNotificationUtil::setValue($this->user, $inboxAndEmailNotificationSettings, 'inboxAndEmailNotificationSettings', false);
     $this->assertFalse(UserNotificationUtil::isEnabledByUserAndNotificationNameAndType($this->user, 'enableSimpleNotification', 'email'));
     $this->assertFalse(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, Notification::getCount());
     $this->assertEquals($initialEmailMessageCount, EmailMessage::getCount());
 }