/** * Tears down the fixture * This method is called after a test is executed. * * @access protected */ public function tearDown() { parent::tearDown(); if ($this->_emailTestClass instanceof Felamimail_Controller_MessageTest) { $this->_emailTestClass->tearDown(); } Calendar_Config::getInstance()->set(Calendar_Config::MAX_NOTIFICATION_PERIOD_FROM, 1); }
/** * Tears down the fixture * This method is called after a test is executed. * * @access protected */ protected function tearDown() { if (!empty($this->_eventIdsToDelete)) { Calendar_Controller_Event::getInstance()->delete($this->_eventIdsToDelete); } if ($this->_emailTestClass instanceof Felamimail_Controller_MessageTest) { $this->_emailTestClass->tearDown(); } }
/** * Tears down the fixture * This method is called after a test is executed. * * @access protected */ protected function tearDown() { Calendar_Controller_Event::getInstance()->sendNotifications(false); if (!empty($this->_eventIdsToDelete)) { $this->_deleteEvents(TRUE); } if ($this->_emailTestClass instanceof Felamimail_Controller_MessageTest) { $this->_emailTestClass->tearDown(); } }
/** * Tears down the fixture * This method is called after a test is executed. * * @access protected */ protected function tearDown() { if ($this->_emailTestClass instanceof Felamimail_Controller_MessageTest) { $this->_emailTestClass->tearDown(); } foreach ($this->objects['devices'] as $device) { ActiveSync_Controller_Device::getInstance()->delete($device); } }
/** * Tears down the fixture * This method is called after a test is executed. * * @access protected */ protected function tearDown() { if ($this->_emailTestClass instanceof Felamimail_Controller_MessageTest) { $this->_emailTestClass->tearDown(); } Felamimail_Controller_Message_Flags::getInstance()->addFlags($this->_createdMessages, array(Zend_Mail_Storage::FLAG_DELETED)); Felamimail_Controller_Message::getInstance()->delete($this->_createdMessages->getArrayOfIds()); parent::tearDown(); }
/** * Tears down the fixture * This method is called after a test is executed. * * @access protected */ protected function tearDown() { if ($this->_emailTestClass instanceof Expressomail_Controller_MessageTest) { $this->_emailTestClass->tearDown(); } if ($this->_headerValueToDelete !== NULL) { $result = $this->_imap->search(array($this->_headerValueToDelete)); foreach ($result as $messageUid) { $this->_imap->removeMessage($messageUid); } } }
/** * Tears down the fixture * This method is called after a test is executed. * * @access protected */ protected function tearDown() { if ($this->_emailTestClass instanceof Felamimail_Controller_MessageTest) { $this->_emailTestClass->tearDown(); } if ($this->_headerValueToDelete !== NULL) { $result = $this->_imap->search(array($this->_headerValueToDelete)); foreach ($result as $messageUid) { $this->_imap->removeMessage($messageUid); } } // reset user if changed if (is_object($this->_testUser) && Tinebase_Core::getUser()->getId() !== $this->_testUser->getId()) { Tinebase_Core::set(Tinebase_Core::USER, $this->_testUser); } }
/** * 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 Felamimail_Frontend_ActiveSync($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->serverId); // 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 Syncroton_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->serverId . '</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 Syncroton_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->serverId . '</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 Syncroton_Command_Sync($doc, $this->_device, $this->_device->policykey); $sync->handle(); $syncDoc = $sync->getResponse(); #$syncDoc->formatOutput = true; echo $syncDoc->saveXML(); sleep(1); // 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->serverId . '</Id><Class>Email</Class></Folder></Folders></Ping>'); // add test email message to folder $emailTest = new Felamimail_Controller_MessageTest(); $emailTest->setUp(); $inbox = $emailTest->getFolder('INBOX'); $emailTest->messageTestHelper('multipart_alternative.eml', 'multipart/alternative', $inbox); $ping = new Syncroton_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(Syncroton_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->serverId, $nodes->item(0)->nodeValue, $responseDoc->saveXML()); // message needs to be deleted after the test because other tests follow that search for 'text/plain', too $emailTest->tearDown(); Felamimail_Controller_Cache_Message::getInstance()->clear($inbox); }
/** * test sync of existing imap folder */ public function testSyncOfEmails() { $imapConfig = Tinebase_Config::getInstance()->get(Tinebase_Config::IMAP); if (!$imapConfig || !isset($imapConfig->useSystemAccount) || $imapConfig->useSystemAccount != TRUE) { $this->markTestSkipped('IMAP backend not configured'); } // this test needs at least one email in the INBOX $emailTest = new Felamimail_Controller_MessageTest(); $emailTest->setUp(); $inbox = $emailTest->getFolder('INBOX'); $emailTest->messageTestHelper('multipart_mixed.eml', 'multipart/mixed', $inbox); $emailController = new ActiveSync_Controller_Email($this->_device, new Tinebase_DateTime(null, null, 'de_DE')); $folders = $emailController->getAllFolders(); foreach ($folders as $folder) { if (strtoupper($folder['displayName']) == 'INBOX') { break; } } // 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(); $xpath = new DomXPath($syncDoc); $xpath->registerNamespace('AirSync', 'uri:AirSync'); $nodes = $xpath->query('//AirSync:Sync/AirSync:Collections/AirSync:Collection/AirSync:Class'); $this->assertEquals(1, $nodes->length, $syncDoc->saveXML()); $this->assertEquals('Email', $nodes->item(0)->nodeValue, $syncDoc->saveXML()); $nodes = $xpath->query('//AirSync:Sync/AirSync:Collections/AirSync:Collection/AirSync:SyncKey'); $this->assertEquals(1, $nodes->length, $syncDoc->saveXML()); $this->assertEquals(1, $nodes->item(0)->nodeValue, $syncDoc->saveXML()); $nodes = $xpath->query('//AirSync:Sync/AirSync:Collections/AirSync:Collection/AirSync:Status'); $this->assertEquals(1, $nodes->length, $syncDoc->saveXML()); $this->assertEquals(Syncope_Command_Sync::STATUS_SUCCESS, $nodes->item(0)->nodeValue, $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>Calendar</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(); $xpath = new DomXPath($syncDoc); $xpath->registerNamespace('AirSync', 'uri:AirSync'); $nodes = $xpath->query('//AirSync:Sync/AirSync:Collections/AirSync:Collection/AirSync:Class'); $this->assertEquals(1, $nodes->length, $syncDoc->saveXML()); $this->assertEquals('Email', $nodes->item(0)->nodeValue, $syncDoc->saveXML()); $nodes = $xpath->query('//AirSync:Sync/AirSync:Collections/AirSync:Collection/AirSync:SyncKey'); $this->assertEquals(1, $nodes->length, $syncDoc->saveXML()); $this->assertEquals(2, $nodes->item(0)->nodeValue, $syncDoc->saveXML()); $nodes = $xpath->query('//AirSync:Sync/AirSync:Collections/AirSync:Collection/AirSync:Status'); $this->assertEquals(1, $nodes->length, $syncDoc->saveXML()); $this->assertEquals(Syncope_Command_Sync::STATUS_SUCCESS, $nodes->item(0)->nodeValue, $syncDoc->saveXML()); $nodes = $xpath->query('//AirSync:Sync/AirSync:Collections/AirSync:Collection/AirSync:Commands'); $this->assertEquals(1, $nodes->length, $syncDoc->saveXML()); $this->assertEquals("uri:Email", $syncDoc->lookupNamespaceURI('Email'), $syncDoc->saveXML()); $emailTest->tearDown(); }