public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     SecurityTestHelper::createSuperAdmin();
     SecurityTestHelper::createUsers();
     $imap = new ZurmoImap();
     $imap->imapHost = Yii::app()->params['emailTestAccounts']['userImapSettings']['imapHost'];
     $imap->imapUsername = Yii::app()->params['emailTestAccounts']['userImapSettings']['imapUsername'];
     $imap->imapPassword = Yii::app()->params['emailTestAccounts']['userImapSettings']['imapPassword'];
     $imap->imapPort = Yii::app()->params['emailTestAccounts']['userImapSettings']['imapPort'];
     $imap->imapSSL = Yii::app()->params['emailTestAccounts']['userImapSettings']['imapSSL'];
     $imap->imapFolder = Yii::app()->params['emailTestAccounts']['userImapSettings']['imapFolder'];
     $imap->init();
     $imap->connect();
     self::$emailHelperSendEmailThroughTransport = Yii::app()->emailHelper->sendEmailThroughTransport;
     self::$userImap = $imap;
 }
 public static function tearDownAfterClass()
 {
     $imap = new ZurmoImap();
     $imap->imapHost = Yii::app()->params['emailTestAccounts']['userImapSettings']['imapHost'];
     $imap->imapUsername = Yii::app()->params['emailTestAccounts']['userImapSettings']['imapUsername'];
     $imap->imapPassword = Yii::app()->params['emailTestAccounts']['userImapSettings']['imapPassword'];
     $imap->imapPort = Yii::app()->params['emailTestAccounts']['userImapSettings']['imapPort'];
     $imap->imapSSL = Yii::app()->params['emailTestAccounts']['userImapSettings']['imapSSL'];
     $imap->imapFolder = Yii::app()->params['emailTestAccounts']['userImapSettings']['imapFolder'];
     $imap->init();
     $imap->connect();
     $imap->deleteMessages(true);
     Yii::app()->emailHelper->sendEmailThroughTransport = self::$emailHelperSendEmailThroughTransport;
     parent::tearDownAfterClass();
 }
Esempio n. 3
0
 /**
  * @depends testInit
  */
 public function testConnect()
 {
     $this->skipTestIfMissingSettings();
     $imap = new ZurmoImap();
     $imap->imapHost = Yii::app()->params['emailTestAccounts']['dropboxImapSettings']['imapHost'];
     $imap->imapUsername = Yii::app()->params['emailTestAccounts']['dropboxImapSettings']['imapUsername'];
     $imap->imapPassword = '******';
     $imap->imapPort = Yii::app()->params['emailTestAccounts']['dropboxImapSettings']['imapPort'];
     $imap->imapSSL = Yii::app()->params['emailTestAccounts']['dropboxImapSettings']['imapSSL'];
     $imap->imapFolder = Yii::app()->params['emailTestAccounts']['dropboxImapSettings']['imapFolder'];
     $imap->setInboundSettings();
     $imap->init();
     $this->assertFalse($imap->connect());
     $imap->imapPassword = Yii::app()->params['emailTestAccounts']['dropboxImapSettings']['imapPassword'];
     $imap->imapPort = "20";
     $imap->setInboundSettings();
     $imap->init();
     $this->assertFalse($imap->connect());
     $imap->imapPort = Yii::app()->params['emailTestAccounts']['dropboxImapSettings']['imapPort'];
     $imap->imapFolder = 'UnexistingFolderName';
     $imap->setInboundSettings();
     $imap->init();
     $this->assertFalse($imap->connect());
     $imap->imapFolder = Yii::app()->params['emailTestAccounts']['dropboxImapSettings']['imapFolder'];
     $imap->setInboundSettings();
     $imap->init();
     $this->assertTrue($imap->connect());
 }
 /**
  * Assumes before calling this, the inbound settings have been validated in the form.
  */
 public function actionTestImapConnection($type = 1)
 {
     $type = intval($type);
     if ($type < 1 || $type > 2) {
         throw new CHttpException(400);
     }
     $adapterClassName = 'EmailArchivingConfigurationFormAdapter';
     if ($type == 2) {
         $adapterClassName = 'BounceConfigurationFormAdapter';
     }
     $configurationForm = $adapterClassName::makeFormFromGlobalConfiguration();
     $postVariableName = get_class($configurationForm);
     if (isset($_POST[$postVariableName])) {
         $configurationForm->setAttributes($_POST[$postVariableName]);
         $imap = new ZurmoImap();
         $imap->imapHost = $configurationForm->imapHost;
         $imap->imapUsername = $configurationForm->imapUsername;
         $imap->imapPassword = $configurationForm->imapPassword;
         $imap->imapPort = $configurationForm->imapPort;
         $imap->imapSSL = $configurationForm->imapSSL;
         $imap->imapFolder = $configurationForm->imapFolder;
         try {
             $connect = $imap->connect();
         } catch (Exception $e) {
             $connect = false;
         }
         if ($connect) {
             $messageContent = Zurmo::t('EmailMessagesModule', 'Successfully connected to IMAP server.') . "\n";
         } else {
             $messageContent = Zurmo::t('EmailMessagesModule', 'Could not connect to IMAP server.') . "\n";
         }
         Yii::app()->getClientScript()->setToAjaxMode();
         $messageView = new TestConnectionView($messageContent);
         $view = new ModalView($this, $messageView, 'modalContainer', Zurmo::t('EmailMessagesModule', 'Test Message Results'));
         echo $view->render();
     } else {
         throw new NotSupportedException();
     }
 }
 public static function resolveImapObject()
 {
     if (static::isSetEmailAccountsTestConfiguration()) {
         $imap = new ZurmoImap();
         $imap->imapHost = Yii::app()->params['emailTestAccounts']['userImapSettings']['imapHost'];
         $imap->imapUsername = Yii::app()->params['emailTestAccounts']['userImapSettings']['imapUsername'];
         $imap->imapPassword = Yii::app()->params['emailTestAccounts']['userImapSettings']['imapPassword'];
         $imap->imapPort = Yii::app()->params['emailTestAccounts']['userImapSettings']['imapPort'];
         $imap->imapSSL = Yii::app()->params['emailTestAccounts']['userImapSettings']['imapSSL'];
         $imap->imapFolder = Yii::app()->params['emailTestAccounts']['userImapSettings']['imapFolder'];
         $imap->init();
         return $imap;
     }
     return false;
 }