Ejemplo n.º 1
0
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     Yii::app()->user->userModel = User::getByUsername('super');
     ReadPermissionsOptimizationUtil::rebuild();
     SecurityTestHelper::createUsers();
     $billy = User::getByUsername('billy');
     EmailMessageTestHelper::createEmailAccount($billy);
     $billy->setRight('ContactsModule', ContactsModule::RIGHT_ACCESS_CONTACTS);
     $billy->setRight('ContactsModule', ContactsModule::RIGHT_CREATE_CONTACTS);
     $billy->setRight('ContactsModule', ContactsModule::RIGHT_DELETE_CONTACTS);
     assert($billy->save());
     // Not Coding Standard
     $contact = ContactTestHelper::createContactByNameForOwner('sally', Yii::app()->user->userModel);
     $contact->primaryEmail = new Email();
     $contact->primaryEmail->emailAddress = '*****@*****.**';
     $contact->secondaryEmail->emailAddress = '*****@*****.**';
     $contact->addPermissions($billy, Permission::READ);
     $contact->addPermissions($billy, Permission::WRITE);
     $contact->save();
     $molly = ContactTestHelper::createContactByNameForOwner('molly', User::getByUsername('bobby'));
     $molly->primaryEmail = new Email();
     $molly->primaryEmail->emailAddress = '*****@*****.**';
     $molly->secondaryEmail->emailAddress = '*****@*****.**';
     $contact->save();
     ReadPermissionsOptimizationUtil::securableItemGivenPermissionsForUser($contact, $billy);
 }
Ejemplo n.º 2
0
 public function testSendMessagePopulatesEmailAccountSettings()
 {
     $jane = User::getByUsername('jane');
     Yii::app()->user->userModel = $jane;
     $emailHelper = new EmailHelper();
     EmailMessageTestHelper::createEmailAccount($jane);
     $emailAccount = EmailAccount::getByUserAndName($jane);
     $emailAccount->useCustomOutboundSettings = EmailMessageUtil::OUTBOUND_PERSONAL_SMTP_SETTINGS;
     $emailAccount->outboundType = 'abc';
     $emailAccount->outboundPort = 11;
     $emailAccount->outboundHost = 'dumb.domain';
     $emailAccount->outboundUsername = '******';
     $emailAccount->outboundPassword = '******';
     $emailAccount->outboundSecurity = 'ssl';
     $emailAccount->save();
     $emailMessage = EmailMessageTestHelper::createOutboxEmail($jane, 'Test email', 'Raw content', 'Html content', 'Zurmo', Yii::app()->emailHelper->outboundUsername, 'John Doe', Yii::app()->params['emailTestAccounts']['userImapSettings']['imapUsername']);
     $emailMessage->account = $emailAccount;
     $emailMessage->save();
     $this->assertEquals(1, Yii::app()->emailHelper->getQueuedCount());
     $this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
     Yii::app()->emailHelper->sendQueued();
     $job = new ProcessOutboundEmailJob();
     $this->assertTrue($job->run());
     //Since user email account has invalid settings message is not sent
     $this->assertContains('Connection could not be established with host dumb.domain', strval($emailMessage->error));
     $this->assertEquals(1, Yii::app()->emailHelper->getQueuedCount());
     $this->assertEquals(0, Yii::app()->emailHelper->getSentCount());
 }
Ejemplo n.º 3
0
 /**
  * @depends testSend
  */
 public function testSendRealEmail()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     Yii::app()->emailHelper->sendEmailThroughTransport = true;
     Yii::app()->imap->imapHost = Yii::app()->params['emailTestAccounts']['userImapSettings']['imapHost'];
     Yii::app()->imap->imapUsername = Yii::app()->params['emailTestAccounts']['userImapSettings']['imapUsername'];
     Yii::app()->imap->imapPassword = Yii::app()->params['emailTestAccounts']['userImapSettings']['imapPassword'];
     Yii::app()->imap->imapPort = Yii::app()->params['emailTestAccounts']['userImapSettings']['imapPort'];
     Yii::app()->imap->imapSSL = Yii::app()->params['emailTestAccounts']['userImapSettings']['imapSSL'];
     Yii::app()->imap->imapFolder = Yii::app()->params['emailTestAccounts']['userImapSettings']['imapFolder'];
     Yii::app()->imap->setInboundSettings();
     Yii::app()->imap->init();
     Yii::app()->emailHelper->outboundHost = Yii::app()->params['emailTestAccounts']['smtpSettings']['outboundHost'];
     Yii::app()->emailHelper->outboundPort = Yii::app()->params['emailTestAccounts']['smtpSettings']['outboundPort'];
     Yii::app()->emailHelper->outboundUsername = Yii::app()->params['emailTestAccounts']['smtpSettings']['outboundUsername'];
     Yii::app()->emailHelper->outboundPassword = Yii::app()->params['emailTestAccounts']['smtpSettings']['outboundPassword'];
     Yii::app()->emailHelper->outboundSecurity = Yii::app()->params['emailTestAccounts']['smtpSettings']['outboundSecurity'];
     Yii::app()->emailHelper->sendEmailThroughTransport = true;
     Yii::app()->emailHelper->setOutboundSettings();
     Yii::app()->emailHelper->init();
     $steve = UserTestHelper::createBasicUser('steve');
     EmailMessageTestHelper::createEmailAccount($steve);
     if (EmailMessageTestHelper::isSetEmailAccountsTestConfiguration()) {
         $user = User::getByUsername('steve');
         $user->primaryEmail->emailAddress = Yii::app()->params['emailTestAccounts']['userImapSettings']['imapUsername'];
         $this->assertTrue($user->save());
         Yii::app()->imap->connect();
         Yii::app()->imap->deleteMessages(true);
         $imapStats = Yii::app()->imap->getMessageBoxStatsDetailed();
         $this->assertEquals(0, $imapStats->Nmsgs);
         $emailMessage = EmailMessageTestHelper::createOutboxEmail($super, 'Test email', 'Raw content', ',b>html content</b>end.', 'Zurmo', Yii::app()->emailHelper->outboundUsername, 'Ivica', Yii::app()->params['emailTestAccounts']['userImapSettings']['imapUsername']);
         Yii::app()->imap->connect();
         $imapStats = Yii::app()->imap->getMessageBoxStatsDetailed();
         $this->assertEquals(0, $imapStats->Nmsgs);
         $this->assertEquals(1, Yii::app()->emailHelper->getQueuedCount());
         $this->assertEquals(3, Yii::app()->emailHelper->getSentCount());
         Yii::app()->emailHelper->sendQueued($emailMessage);
         $job = new ProcessOutboundEmailJob();
         $this->assertTrue($job->run());
         $this->assertEquals(0, Yii::app()->emailHelper->getQueuedCount());
         $this->assertEquals(4, Yii::app()->emailHelper->getSentCount());
         sleep(30);
         Yii::app()->imap->connect();
         $imapStats = Yii::app()->imap->getMessageBoxStatsDetailed();
         $this->assertEquals(1, $imapStats->Nmsgs);
     }
     Yii::app()->emailHelper->sendEmailThroughTransport = false;
 }