/** * Sets up the fixture. * This method is called before a test is executed. * * @access protected */ protected function setUp() { $this->_backend = Tinebase_User::getInstance(); if (!array_key_exists('Tinebase_EmailUser_Smtp_Postfix', $this->_backend->getPlugins())) { $this->markTestSkipped('Postfix SQL plugin not enabled'); } $this->objects['users'] = array(); $this->_mailDomain = TestServer::getPrimaryMailDomain(); }
/** * Sets up the fixture. * This method is called before a test is executed. * * @access protected */ protected function setUp() { $this->_backend = Tinebase_User::getInstance(); if (!array_key_exists('Tinebase_EmailUser_Smtp_Postfix', $this->_backend->getPlugins())) { $this->markTestSkipped('Postfix SQL plugin not enabled'); } if (Tinebase_User::getConfiguredBackend() === Tinebase_User::ACTIVEDIRECTORY) { // error: Zend_Ldap_Exception: 0x44 (Already exists; 00002071: samldb: Account name (sAMAccountName) // 'tine20phpunituser' already in use!): adding: cn=PHPUnit User Tine 2.0,cn=Users,dc=example,dc=org $this->markTestSkipped('skipped for ad backends as it does not allow duplicate CNs'); } $this->objects['users'] = array(); $this->_mailDomain = TestServer::getPrimaryMailDomain(); }
/** * get test mail domain * * @return string */ protected function _getMailDomain() { return TestServer::getPrimaryMailDomain(); }
/** * @return Tinebase_Model_FullUser */ public static function getTestRecord() { $emailDomain = TestServer::getPrimaryMailDomain(); $user = new Tinebase_Model_FullUser(array('accountLoginName' => 'tine20phpunituser', 'accountStatus' => 'enabled', 'accountExpires' => NULL, 'accountPrimaryGroup' => Tinebase_Group::getInstance()->getDefaultGroup()->id, 'accountLastName' => 'Tine 2.0', 'accountFirstName' => 'PHPUnit User', 'accountEmailAddress' => 'phpunit@' . $emailDomain)); return $user; }
/** * import file * * @param string $_filename * @param Tinebase_Model_ImportExportDefinition $_definition * @param boolean $_useJsonImportFn * @param boolean $removeGroupList * @return array course data */ protected function _importHelper($_filename, Tinebase_Model_ImportExportDefinition $_definition = NULL, $_useJsonImportFn = FALSE, $removeGroupList = FALSE) { $definition = $_definition !== NULL ? $_definition : $this->_getCourseImportDefinition(); $course = $this->_getCourseData(); $courseData = $this->_json->saveCourse($course); $this->_groupsToDelete->addRecord(Tinebase_Group::getInstance()->getGroupById($courseData['group_id'])); if ($removeGroupList) { $group = Admin_Controller_Group::getInstance()->get($courseData['group_id']); Addressbook_Controller_List::getInstance()->delete($group->list_id); } if ($_useJsonImportFn) { $tempFileBackend = new Tinebase_TempFile(); $tempFile = $tempFileBackend->createTempFile($_filename); Courses_Config::getInstance()->set(Courses_Config::STUDENTS_IMPORT_DEFINITION, $definition->name); $result = $this->_json->importMembers($tempFile->getId(), $courseData['group_id'], $courseData['id']); $this->assertGreaterThan(0, $result['results']); } else { $maildomain = TestServer::getPrimaryMailDomain(); $importer = call_user_func($definition->plugin . '::createFromDefinition', $definition, array('group_id' => $courseData['group_id'], 'accountHomeDirectoryPrefix' => '//base/school/' . $courseData['name'] . '/', 'accountEmailDomain' => $maildomain, 'password' => $courseData['name'], 'samba' => array('homePath' => '//basehome/', 'homeDrive' => 'H:', 'logonScript' => 'logon.bat', 'profilePath' => '\\\\profile\\'))); $tempFilename = TestServer::replaceEmailDomainInFile($_filename); $importer->importFile($tempFilename); } $courseData = $this->_json->getCourse($courseData['id']); return $courseData; }
/** * Sets up the fixture. * This method is called before a test is executed. * * @access protected */ protected function setUp() { Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb()); // get (or create) test accout $this->_account = Felamimail_Controller_Account::getInstance()->search()->getFirstRecord(); $this->_oldSieveVacationActiveState = $this->_account->sieve_vacation_active; try { $this->_oldSieveData = new Felamimail_Sieve_Backend_Sql($this->_account); } catch (Tinebase_Exception_NotFound $tenf) { // do nothing } $this->_json = new Felamimail_Frontend_Json(); $this->_imap = Felamimail_Backend_ImapFactory::factory($this->_account); foreach (array($this->_testFolderName, $this->_account->sent_folder, $this->_account->trash_folder) as $folderToCreate) { // create folder if it does not exist $this->_getFolder($folderToCreate); } $this->_mailDomain = TestServer::getPrimaryMailDomain(); $this->_frontend = new Tinebase_Frontend_Json(); }
/** * testDuplicateUserId * * @see 0007218: Duplicate userid in dovecot_users */ public function testDuplicateUserId() { $emailDomain = TestServer::getPrimaryMailDomain(); $user = $this->_addUser('testuser@' . $emailDomain); // update user loginname $user->accountLoginName = 'testuser'; $user = Tinebase_User::getInstance()->updateUser($user); $queryResult = $this->_fetchUserFromDovecotUsersTable($user->getId()); $this->assertEquals('testuser@' . $emailDomain, $queryResult[0]['username'], 'username has not been updated in dovecot user table'); }
/** * test line end encoding of Zend_Mime_Part / Smtp Protocol */ public function testSendWithWrongLineEnd() { $mailDomain = TestServer::getPrimaryMailDomain(); // build message with wrong line end rfc822 part $mail = new Tinebase_Mail('utf-8'); $mail->setBodyText('testmail' . "\r\n" . "\r\n"); $mail->setFrom($this->_getEmailAddress(), 'unittest'); $mail->setSubject('line end test'); $mail->addTo($this->_getEmailAddress()); $mail->addHeader('X-Tine20TestMessage', 'lineend'); // replace EOLs $content = file_get_contents(dirname(dirname(__FILE__)) . '/files/text_plain.eml'); $content = preg_replace("/\\x0a/", "\r\n", $content); $stream = fopen("php://temp", 'r+'); fputs($stream, $content); rewind($stream); $attachment = new Zend_Mime_Part($stream); $attachment->type = Felamimail_Model_Message::CONTENT_TYPE_MESSAGE_RFC822; $attachment->encoding = null; $attachment->charset = 'ISO-8859-1'; $attachment->filename = 'attach.eml'; $attachment->disposition = Zend_Mime::DISPOSITION_ATTACHMENT; $mail->addAttachment($attachment); $smtpConfig = $this->_account->getSmtpConfig(); $transport = new Felamimail_Transport($smtpConfig['hostname'], $smtpConfig); Zend_Mail_Protocol_Abstract::$loggingEnabled = true; $mail->send($transport); Zend_Mail_Protocol_Abstract::$loggingEnabled = false; $smtpLog = $transport->getConnection()->getLog(); $badLineEndCount = preg_match_all("/\\x0d\\x0d\\x0a/", $smtpLog, $matches); $this->assertEquals(0, $badLineEndCount); $badLineEndCount = preg_match_all("/\\x0d/", $smtpLog, $matches); $this->assertTrue($badLineEndCount > 70, 'unix line ends are missing'); }
/** * testImportUsersWithEmailUser */ public function testImportUsersWithEmailUser() { $userBackend = Tinebase_User::getInstance(); $maildomain = TestServer::getPrimaryMailDomain(); $readFile = fopen(dirname(__FILE__) . '/files/tine_user5.csv', 'r'); $writeFile = fopen('test.csv', 'w'); $delimiter = ','; $enclosure = '"'; while (($row = fgetcsv($readFile)) !== false) { foreach ($row as $colIndex => &$field) { $field = str_replace('DOMAIN', $maildomain, $field); } fputcsv($writeFile, $row, $delimiter, $enclosure); } fclose($readFile); fclose($writeFile); if (!array_key_exists('Tinebase_EmailUser_Smtp_Postfix', $userBackend->getPlugins())) { $this->markTestSkipped('Postfix SQL plugin not enabled'); } $this->_importUsers($this->objects['configEmailuser'], 'test.csv', 'admin_user_import_csv_test_emailuser'); $newUser = $userBackend->getFullUserByLoginName('testuser'); $this->assertEquals(array('contact@' . $maildomain, 'kontakt@' . $maildomain), $newUser->smtpUser->emailAliases); $this->assertEquals(array('test@' . $maildomain), $newUser->smtpUser->emailForwards); $this->assertTrue($newUser->smtpUser->emailForwardOnly); unlink("test.csv"); }