/**
  * sieve test helper
  *
  * @param array $_sieveData
  * @return array
  */
 protected function _sieveTestHelper($_sieveData, $_isMime = FALSE)
 {
     $this->_setTestScriptname();
     // check which save fn to use
     if (isset($_sieveData['reason']) || array_key_exists('reason', $_sieveData)) {
         $resultSet = $this->_json->saveVacation($_sieveData);
         $this->assertEquals($this->_account->email, $resultSet['addresses'][0]);
         $_sieveBackend = Felamimail_Backend_SieveFactory::factory($this->_account->getId());
         if (preg_match('/dbmail/i', $_sieveBackend->getImplementation())) {
             $translate = Tinebase_Translation::getTranslation('Felamimail');
             $this->assertEquals(sprintf($translate->_('Out of Office reply from %1$s'), Tinebase_Core::getUser()->accountFullName), $resultSet['subject']);
         } else {
             $this->assertEquals($_sieveData['subject'], $resultSet['subject']);
         }
         if ($_isMime) {
             $this->assertEquals(html_entity_decode('unittest vacation message', ENT_NOQUOTES, 'UTF-8'), $resultSet['reason']);
         } else {
             $this->assertEquals($_sieveData['reason'], $resultSet['reason']);
         }
     } else {
         if (isset($_sieveData[0]['action_type']) || array_key_exists('action_type', $_sieveData[0])) {
             $resultSet = $this->_json->saveRules($this->_account->getId(), $_sieveData);
             $this->assertEquals($_sieveData, $resultSet);
         }
     }
     return $resultSet;
 }
예제 #2
0
 /**
  * init and connect to sieve backend + authenticate with imap user of account
  * 
  * @param string|Felamimail_Model_Account $_accountId
  * @throws Felamimail_Exception
  */
 protected function _setSieveBackendAndAuthenticate($_accountId)
 {
     if (empty($_accountId)) {
         throw new Felamimail_Exception('No account id given.');
     }
     $this->_backend = Felamimail_Backend_SieveFactory::factory($_accountId);
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' sieve server capabilities: ' . print_r($this->_backend->capability(), TRUE));
     }
 }