/** * Sets up the fixture. * This method is called before a test is executed. * * @access protected */ protected function setUp() { $this->_account = Expressomail_Controller_Account::getInstance()->search()->getFirstRecord(); $this->_controller = Expressomail_Controller_Message::getInstance(); $this->_imap = Expressomail_Backend_ImapFactory::factory($this->_account); $this->_folder = $this->getFolder($this->_testFolderName); $this->_imap->selectFolder($this->_testFolderName); $this->_createdMessages = new Tinebase_Record_RecordSet('Expressomail_Model_Message'); }
/** * route all function calls to the imap backend (try noop first and relogin if fail) * * @param string $_name * @param array $_arguments * @return mixed */ public function __call($_name, $_arguments) { try { $this->_backend->noop(); } catch (Zend_Mail_Protocol_Exception $zmpe) { Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Lost IMAP connection ... trying relogin. (' . $zmpe->getMessage() . ')'); $this->_backend->connectAndLogin($this->_params); } return call_user_func_array(array($this->_backend, $_name), $_arguments); }
/** * rename mail folder directly on the server (i.e. another client) and try to rename it with tine */ public function testRenameFolderByAnotherClient() { $testFolderName = 'INBOX' . $this->_account->delimiter . 'test'; $this->_controller->create($this->_account->getId(), 'test', 'INBOX'); $this->_imap->renameFolder($testFolderName, $testFolderName . '_renamed'); $this->_createdFolders = array($testFolderName . '_renamed'); $this->setExpectedException('Expressomail_Exception_IMAPFolderNotFound'); $renamedFolder = $this->_controller->rename($this->_account->getId(), $testFolderName, $testFolderName); }
/** * test update folder quota */ public function testUpdateFolderQuota() { $folderToTest = $this->_getFolder('INBOX'); $folderToTest = $this->_controller->updateCache($folderToTest); $quota = $this->_imap->getQuota('INBOX'); if (empty($quota)) { $this->assertEquals(0, $folderToTest->quota_usage); $this->assertEquals(0, $folderToTest->quota_limit); } else { $this->assertEquals($quota['STORAGE']['usage'], $folderToTest->quota_usage); $this->assertEquals($quota['STORAGE']['limit'], $folderToTest->quota_limit); } }
/*********** IMAP config ***********/ $imapConfig = array('host' => 'xxx', 'user' => 'xxx', 'password' => 'xxx', 'port' => 143, 'ssl' => 'tls'); $subfoldersOf = 'INBOX'; /*********** environment ***********/ set_include_path('.' . PATH_SEPARATOR . dirname(__FILE__) . '/library' . PATH_SEPARATOR . get_include_path()); require_once 'Zend/Loader/Autoloader.php'; $autoloader = Zend_Loader_Autoloader::getInstance(); $autoloader->setFallbackAutoloader(true); /*********** start ***********/ $startTime = microtime(true); print "<pre>"; print "<h1><span style='color:red;'>ATTENTION: THIS OUTPUT CONTAINS YOUR USERNAME AND PASSWORD!!!</span></h1>"; /*********** login and select INBOX ***********/ $elapsedTime = microtime(true) - $startTime; print "<h1> {$elapsedTime} :: Login with config: </h1>" . print_r($imapConfig, TRUE); $imapBackend = new Felamimail_Backend_Imap($imapConfig); /*********** show capabilities and namespace **/ $capabilities = $imapBackend->getCapabilityAndNamespace(); $elapsedTime = microtime(true) - $startTime; print "<h1> {$elapsedTime} :: get capabilities + namespace: </h1>" . print_r($capabilities, TRUE); /*********** get all folders *****************/ $folders = $imapBackend->getFolders(); $elapsedTime = microtime(true) - $startTime; print "<h1> {$elapsedTime} :: get folders: </h1>" . print_r($folders, TRUE); /*********** get subfolders *****************/ $delimiter = $folders[$subfoldersOf]['delimiter']; $subfolders = $imapBackend->getFolders($subfoldersOf . $delimiter, '%'); $elapsedTime = microtime(true) - $startTime; print "<h1> {$elapsedTime} :: get subfolders of {$subfoldersOf} : </h1>" . print_r($subfolders, TRUE); /*********** logout ************/ $elapsedTime = microtime(true) - $startTime;