/** * testSendMailWithoutSubject * * @see 0007870: Can't send mail without subject */ public function testSendMailWithoutSubject() { $controller = $this->_getController($this->_getDevice(Syncroton_Model_Device::TYPE_ANDROID_40)); $email = file_get_contents(dirname(__FILE__) . '/../../Felamimail/files/text_plain.eml'); $email = str_replace('gentoo-dev@lists.gentoo.org, webmaster@changchung.org', $this->_emailTestClass->getEmailAddress(), $email); $email = str_replace('gentoo-dev+bounces-35440-lars=kneschke.de@lists.gentoo.org', $this->_emailTestClass->getEmailAddress(), $email); $email = str_replace("Subject: Re: [gentoo-dev] `paludis --info' is not like `emerge --info'\n", '', $email); $controller->sendEmail($email, true); // check if mail is in INBOX of test account $inbox = $this->_emailTestClass->getFolder('INBOX'); $testHeaderValue = 'text/plain'; $message = $this->_emailTestClass->searchAndCacheMessage($testHeaderValue, $inbox); $this->_createdMessages->addRecord($message); $this->assertTrue(empty($message->subject)); }
/** * test (plain text) mail sending via ActiveSync_Command_SendMail */ public function testSendMail() { $email = file_get_contents(dirname(__FILE__) . '/../../Felamimail/files/text_plain.eml'); $email = str_replace('gentoo-dev@lists.gentoo.org, webmaster@changchung.org', $this->_emailTestClass->getEmailAddress(), $email); $stream = fopen('data://text/plain;base64,' . base64_encode($email), 'r'); $sendMail = new Syncope_Command_SendMail($stream); $sendMail->handle(); $sendMail->getResponse(); // check if mail is in INBOX of test account $inbox = $this->_emailTestClass->getFolder('INBOX'); $testHeaderValue = 'text/plain'; $message = $this->_emailTestClass->searchAndCacheMessage($testHeaderValue, $inbox); $this->_createdMessages->addRecord($message); $this->assertEquals("Re: [gentoo-dev] `paludis --info' is not like `emerge --info'", $message->subject); // check duplicate headers $completeMessage = Felamimail_Controller_Message::getInstance()->getCompleteMessage($message); $this->assertEquals(1, count($completeMessage->headers['mime-version'])); $this->assertEquals(1, count($completeMessage->headers['content-type'])); }
/** * test sync of existing imap folder */ public function testPingForEmails() { $imapConfig = Tinebase_Config::getInstance()->get(Tinebase_Config::IMAP); if (!$imapConfig || !isset($imapConfig->useSystemAccount) || $imapConfig->useSystemAccount != TRUE) { $this->markTestSkipped('IMAP backend not configured'); } $emailController = new ActiveSync_Controller_Email($this->_device, new Tinebase_DateTime(null, null, 'de_DE')); $folders = $emailController->getAllFolders(); $this->assertGreaterThan(0, count($folders)); foreach ($folders as $folder) { if (strtoupper($folder['displayName']) == 'INBOX') { break; } } $emailController->updateCache($folder['folderId']); // first do a foldersync $doc = new DOMDocument(); $doc->loadXML('<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/"> <FolderSync xmlns="uri:FolderHierarchy"><SyncKey>0</SyncKey></FolderSync>'); $folderSync = new Syncope_Command_FolderSync($doc, $this->_device, $this->_device->policykey); $folderSync->handle(); $syncDoc = $folderSync->getResponse(); #$syncDoc->formatOutput = true; echo $syncDoc->saveXML(); // request initial synckey $doc = new DOMDocument(); $doc->loadXML('<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/"> <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase"><Collections><Collection><Class>Email</Class><SyncKey>0</SyncKey><CollectionId>' . $folder['folderId'] . '</CollectionId><DeletesAsMoves/><GetChanges/><WindowSize>100</WindowSize><Options><FilterType>4</FilterType><AirSyncBase:BodyPreference><AirSyncBase:Type>1</AirSyncBase:Type><AirSyncBase:TruncationSize>5120</AirSyncBase:TruncationSize></AirSyncBase:BodyPreference><Conflict>1</Conflict></Options></Collection></Collections></Sync>'); $sync = new Syncope_Command_Sync($doc, $this->_device, $this->_device->policykey); $sync->handle(); $syncDoc = $sync->getResponse(); #$syncDoc->formatOutput = true; echo $syncDoc->saveXML(); // now do the first sync $doc = new DOMDocument(); $doc->loadXML('<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/"> <Sync xmlns="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase"><Collections><Collection><Class>Email</Class><SyncKey>1</SyncKey><CollectionId>' . $folder['folderId'] . '</CollectionId><DeletesAsMoves/><GetChanges/><WindowSize>100</WindowSize><Options><FilterType>4</FilterType><AirSyncBase:BodyPreference><AirSyncBase:Type>1</AirSyncBase:Type><AirSyncBase:TruncationSize>5120</AirSyncBase:TruncationSize></AirSyncBase:BodyPreference><Conflict>1</Conflict></Options></Collection></Collections></Sync>'); $sync = new Syncope_Command_Sync($doc, $this->_device, $this->_device->policykey); $sync->handle(); $syncDoc = $sync->getResponse(); #$syncDoc->formatOutput = true; echo $syncDoc->saveXML(); // and now we can start the ping request $doc = new DOMDocument(); $doc->loadXML('<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/"> <Ping xmlns="uri:Ping"><HeartBeatInterval>10</HeartBeatInterval><Folders><Folder><Id>' . $folder['folderId'] . '</Id><Class>Email</Class></Folder></Folders></Ping>'); // add test email message to folder $emailTest = new Felamimail_Controller_MessageTest(); $emailTest->setUp(); $inbox = $emailTest->getFolder('INBOX'); $email = file_get_contents(dirname(__FILE__) . '/../../Felamimail/files/text_plain.eml'); Felamimail_Controller_Message::getInstance()->appendMessage($inbox, $email); $ping = new Syncope_Command_Ping($doc, $this->_device, null); $ping->handle(); $responseDoc = $ping->getResponse(); $responseDoc->formatOutput = true; //echo $responseDoc->saveXML(); $xpath = new DomXPath($responseDoc); $xpath->registerNamespace('Ping', 'uri:Ping'); $nodes = $xpath->query('//Ping:Ping/Ping:Status'); $this->assertEquals(1, $nodes->length, $responseDoc->saveXML()); $this->assertEquals(Syncope_Command_Ping::STATUS_CHANGES_FOUND, $nodes->item(0)->nodeValue, $responseDoc->saveXML()); $nodes = $xpath->query('//Ping:Ping/Ping:Folders/Ping:Folder'); $this->assertEquals(1, $nodes->length, $responseDoc->saveXML()); $this->assertEquals($folder['folderId'], $nodes->item(0)->nodeValue, $responseDoc->saveXML()); $message = $emailTest->searchAndCacheMessage('text/plain', $inbox); Felamimail_Controller_Message_Flags::getInstance()->addFlags(array($message), array(Zend_Mail_Storage::FLAG_DELETED)); }