/**
  * test flag update
  */
 public function testUpdateFlags()
 {
     $message = $this->_emailTestClass->messageTestHelper('multipart_mixed.eml', 'multipart/mixed');
     // appended messages already have the SEEN flag
     $this->assertTrue(in_array(Zend_Mail_Storage::FLAG_SEEN, $message->flags), 'SEEN flag not found: ' . print_r($message->flags, TRUE));
     // add another flag
     Expressomail_Controller_Message_Flags::getInstance()->addFlags($message, Zend_Mail_Storage::FLAG_ANSWERED);
     while (!isset($updatedFolder) || $updatedFolder->cache_status === Expressomail_Model_Folder::CACHE_STATUS_INCOMPLETE) {
         $updatedFolder = $this->_controller->updateCache($this->_folder, 30, 1);
     }
     // clear/add flag on imap
     $this->_imap->clearFlags($message->messageuid, array(Zend_Mail_Storage::FLAG_SEEN));
     $flagsToAdd = array(Zend_Mail_Storage::FLAG_FLAGGED, Zend_Mail_Storage::FLAG_DRAFT, Zend_Mail_Storage::FLAG_PASSED);
     try {
         $this->_imap->addFlags($message->messageuid, $flagsToAdd);
     } catch (Zend_Mail_Storage_Exception $zmse) {
         // some imap servers (dbmail, ...) do not support PASSED flag
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . $zmse->getMessage());
         }
         $this->_imap->addFlags($message->messageuid, array(Zend_Mail_Storage::FLAG_FLAGGED, Zend_Mail_Storage::FLAG_DRAFT));
     }
     $this->_controller->updateFlags($updatedFolder);
     $cachedMessage = Expressomail_Controller_Message::getInstance()->get($message->getId());
     $this->assertTrue(!in_array(Zend_Mail_Storage::FLAG_SEEN, $cachedMessage->flags), 'SEEN flag found: ' . print_r($cachedMessage->flags, TRUE));
     $expectedFlags = array(Zend_Mail_Storage::FLAG_FLAGGED, Zend_Mail_Storage::FLAG_DRAFT, Zend_Mail_Storage::FLAG_ANSWERED);
     $this->assertEquals(3, count($cachedMessage->flags), 'found too many flags: ' . print_r($cachedMessage->flags, TRUE));
     foreach ($expectedFlags as $expectedFlag) {
         $this->assertTrue(in_array($expectedFlag, $cachedMessage->flags), $expectedFlag . ' flag not found: ' . print_r($cachedMessage->flags, TRUE));
     }
     $this->_controller->updateFlags($updatedFolder);
     $cachedMessageAgain = Expressomail_Controller_Message::getInstance()->get($message->getId());
     // cached message should not have been updated again
     $this->assertEquals($cachedMessage->timestamp->__toString(), $cachedMessageAgain->timestamp->__toString());
 }
 /**
  * testExternalPublishProcess
  * - uses felamimail to cache external publish message
  * 
  * NOTE: meetup sends REQUEST w.o. attendee. We might think of autoconvert this to PUBLISH
  */
 public function testExternalPublishProcess()
 {
     $this->_checkIMAPConfig();
     // handle message with fmail (add to cache)
     $message = $this->_emailTestClass->messageTestHelper('meetup.eml');
     $complete = Felamimail_Controller_Message::getInstance()->getCompleteMessage($message);
     $iMIP = $complete->preparedParts->getFirstRecord()->preparedData;
     $this->setExpectedException('Calendar_Exception_iMIP', 'iMIP preconditions failed: ATTENDEE');
     $result = $this->_iMIPFrontend->process($iMIP);
 }
 /**
  * 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']));
 }
 /**
  * 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));
 }
示例#5
0
 /**
  * validate fetching email by filereference(hashid-partid)
  */
 public function testAppendXML()
 {
     $controller = $this->_getController($this->_getDevice(Syncope_Model_Device::TYPE_WEBOS));
     $message = $this->_emailTestClass->messageTestHelper('multipart_mixed.eml', 'multipart/mixed');
     $options = array('collectionId' => $message->folder_id);
     $properties = $this->_domDocument->createElementNS('uri:ItemOperations', 'Properties');
     $controller->appendXML($properties, $options, $message->getId());
     $this->_domDocument->documentElement->appendChild($properties);
     $this->_domDocument->formatOutput = true;
     #echo $this->_domDocument->saveXML();
     $this->assertEquals('[gentoo-dev] Automated Package Removal and Addition Tracker, for the week ending 2009-04-12 23h59 UTC', @$this->_domDocument->getElementsByTagNameNS('uri:Email', 'Subject')->item(0)->nodeValue, $this->_domDocument->saveXML());
     // size of the attachment
     $this->assertEquals(2787, @$this->_domDocument->getElementsByTagNameNS('uri:AirSyncBase', 'EstimatedDataSize')->item(0)->nodeValue, $this->_domDocument->saveXML());
     // size of the body
     $this->assertEquals(9606, @$this->_domDocument->getElementsByTagNameNS('uri:AirSyncBase', 'EstimatedDataSize')->item(1)->nodeValue, $this->_domDocument->saveXML());
 }
 /**
  * get test alarm emails
  * 
  * @param boolean $deleteThem
  * @return Tinebase_Record_RecordSet
  */
 protected function _getAlarmMails($deleteThem = FALSE)
 {
     // search and assert alarm mail
     $folder = $this->_emailTestClass->getFolder('INBOX');
     $folder = Felamimail_Controller_Cache_Message::getInstance()->updateCache($folder, 10, 1);
     $i = 0;
     while ($folder->cache_status != Felamimail_Model_Folder::CACHE_STATUS_COMPLETE && $i < 10) {
         $folder = Felamimail_Controller_Cache_Message::getInstance()->updateCache($folder, 10);
         $i++;
     }
     $account = Felamimail_Controller_Account::getInstance()->search()->getFirstRecord();
     $filter = new Felamimail_Model_MessageFilter(array(array('field' => 'folder_id', 'operator' => 'equals', 'value' => $folder->getId()), array('field' => 'account_id', 'operator' => 'equals', 'value' => $account->getId()), array('field' => 'subject', 'operator' => 'startswith', 'value' => 'Alarm for event "Wakeup" at')));
     $result = Felamimail_Controller_Message::getInstance()->search($filter);
     if ($deleteThem) {
         Felamimail_Controller_Message_Move::getInstance()->moveMessages($filter, Felamimail_Model_Folder::FOLDER_TRASH);
     }
     return $result;
 }
 /**
  * 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);
 }
示例#8
0
 /**
  * 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));
 }
示例#9
0
 /**
  * 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();
 }