/**
  */
 public function testFileReference()
 {
     // do initial sync first
     $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:ItemOperations"><SyncKey>0</SyncKey></FolderSync>');
     $folderSync = new Syncope_Command_FolderSync($doc, $this->_device, null);
     $folderSync->handle();
     $responseDoc = $folderSync->getResponse();
     $doc = new DOMDocument();
     $doc->loadXML('<?xml version="1.0" encoding="utf-8"?>
         <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
         <ItemOperations xmlns="uri:ItemOperations" xmlns:AirSync="uri:AirSync" xmlns:AirSyncBase="uri:AirSyncBase">
         <Fetch><Store>Mailbox</Store><AirSyncBase:FileReference>email1-10</AirSyncBase:FileReference></Fetch>
 		</ItemOperations>');
     $itemOperations = new Syncope_Command_ItemOperations($doc, $this->_device, null);
     $itemOperations->handle();
     $responseDoc = $itemOperations->getResponse();
     #$responseDoc->formatOutput = true; echo $responseDoc->saveXML();
     $xpath = new DomXPath($responseDoc);
     $xpath->registerNamespace('ItemOperations', 'uri:ItemOperations');
     $xpath->registerNamespace('Email', 'uri:Email');
     $nodes = $xpath->query('//ItemOperations:ItemOperations/ItemOperations:Status');
     $this->assertEquals(1, $nodes->length, $responseDoc->saveXML());
     $this->assertEquals(Syncope_Command_ItemOperations::STATUS_SUCCESS, $nodes->item(0)->nodeValue, $responseDoc->saveXML());
     $nodes = $xpath->query('//ItemOperations:ItemOperations/ItemOperations:Response/ItemOperations:Fetch/ItemOperations:Status');
     $this->assertEquals(1, $nodes->length, $responseDoc->saveXML());
     $this->assertEquals(Syncope_Command_ItemOperations::STATUS_SUCCESS, $nodes->item(0)->nodeValue, $responseDoc->saveXML());
     $nodes = $xpath->query('//ItemOperations:ItemOperations/ItemOperations:Response/ItemOperations:Fetch/ItemOperations:Properties/AirSyncBase:ContentType');
     $this->assertEquals(1, $nodes->length, $responseDoc->saveXML());
     $this->assertEquals('text/plain', $nodes->item(0)->nodeValue, $responseDoc->saveXML());
 }
示例#2
0
 /**
  * 
  */
 public function testPingContacts()
 {
     // 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();
     $folderSync->getResponse();
     // 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>Contacts</Class><SyncKey>0</SyncKey><CollectionId>addressbookFolderId</CollectionId><DeletesAsMoves/><GetChanges/><WindowSize>100</WindowSize><Options><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>Contacts</Class><SyncKey>1</SyncKey><CollectionId>addressbookFolderId</CollectionId><DeletesAsMoves/><GetChanges/><WindowSize>100</WindowSize><Options><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();
     // sleep one second; otherwise we are to fast
     sleep(1);
     Syncope_Data_Contacts::$changedEntries['Syncope_Data_Contacts'][] = 'contact1';
     // 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>addressbookFolderId</Id><Class>Contacts</Class></Folder></Folders></Ping>');
     $search = new Syncope_Command_Ping($doc, $this->_device, null);
     $search->handle();
     $responseDoc = $search->getResponse();
     #$responseDoc->formatOutput = true; echo $responseDoc->saveXML();
     Syncope_Data_Contacts::$changedEntries['Syncope_Data_Contacts'] = array();
     $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('addressbookFolderId', $nodes->item(0)->nodeValue, $responseDoc->saveXML());
 }
 /**
  * test xml generation for IPhone
  */
 public function testDeleteFolder()
 {
     // do initial sync first
     $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, null);
     $folderSync->handle();
     $responseDoc = $folderSync->getResponse();
     $doc = new DOMDocument();
     $doc->loadXML('<?xml version="1.0" encoding="utf-8"?>
                 <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
                 <FolderCreate xmlns="uri:FolderHierarchy"><SyncKey>1</SyncKey><ParentId/><DisplayName>Test Folder</DisplayName><Type>14</Type></FolderCreate>');
     $folderCreate = new Syncope_Command_FolderCreate($doc, $this->_device, null);
     $folderCreate->handle();
     $responseDoc = $folderCreate->getResponse();
     #$responseDoc->formatOutput = true; echo $responseDoc->saveXML();
     $xpath = new DomXPath($responseDoc);
     $xpath->registerNamespace('FolderHierarchy', 'uri:FolderHierarchy');
     $nodes = $xpath->query('//FolderHierarchy:FolderCreate/FolderHierarchy:ServerId');
     $newFolderId = $nodes->item(0)->nodeValue;
     // delete folder created above
     $doc = new DOMDocument();
     $doc->loadXML('<?xml version="1.0" encoding="utf-8"?>
         <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
         <FolderDelete xmlns="uri:FolderHierarchy"><SyncKey>2</SyncKey><ServerId>' . $newFolderId . '</ServerId></FolderDelete>');
     $folderDelete = new Syncope_Command_FolderDelete($doc, $this->_device, null);
     $folderDelete->handle();
     $responseDoc = $folderDelete->getResponse();
     #$responseDoc->formatOutput = true; echo $responseDoc->saveXML();
     $xpath = new DomXPath($responseDoc);
     $xpath->registerNamespace('FolderHierarchy', 'uri:FolderHierarchy');
     $nodes = $xpath->query('//FolderHierarchy:FolderDelete/FolderHierarchy:Status');
     $this->assertEquals(1, $nodes->length, $responseDoc->saveXML());
     $this->assertEquals(Syncope_Command_FolderSync::STATUS_SUCCESS, $nodes->item(0)->nodeValue, $responseDoc->saveXML());
     $nodes = $xpath->query('//FolderHierarchy:FolderDelete/FolderHierarchy:SyncKey');
     $this->assertEquals(1, $nodes->length, $responseDoc->saveXML());
     $this->assertEquals(3, $nodes->item(0)->nodeValue, $responseDoc->saveXML());
     $this->assertArrayNotHasKey($newFolderId, Syncope_Data_Contacts::$folders);
 }
示例#4
0
 /**
  * test sync of existing contacts folder
  */
 public function testSyncOfContacts()
 {
     // 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();
     $folderSync->getResponse();
     // 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>Contacts</Class><SyncKey>0</SyncKey><CollectionId>addressbookFolderId</CollectionId><DeletesAsMoves/><GetChanges/><WindowSize>2</WindowSize><Options><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('Contacts', $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>Contacts</Class><SyncKey>1</SyncKey><CollectionId>addressbookFolderId</CollectionId><DeletesAsMoves/><GetChanges/><WindowSize>2</WindowSize><Options><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('Contacts', $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:MoreAvailable');
     $this->assertEquals(1, $nodes->length, $syncDoc->saveXML());
     $nodes = $xpath->query('//AirSync:Sync/AirSync:Collections/AirSync:Collection/AirSync:Commands');
     $this->assertEquals(1, $nodes->length, $syncDoc->saveXML());
     #$this->assertEquals(Syncope_Command_Sync::STATUS_SUCCESS, $nodes->item(0)->nodeValue, $syncDoc->saveXML());
     // there should be no responses element
     $nodes = $xpath->query('//AirSync:Sync/AirSync:Collections/AirSync:Collection/AirSync:Responses');
     $this->assertEquals(0, $nodes->length, $syncDoc->saveXML());
     $this->assertEquals("uri:Contacts", $syncDoc->lookupNamespaceURI('Contacts'), $syncDoc->saveXML());
     // try with previous synckey again
     $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>Contacts</Class><SyncKey>1</SyncKey><CollectionId>addressbookFolderId</CollectionId><DeletesAsMoves/><GetChanges/><WindowSize>2</WindowSize><Options><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 fetch the rest
     $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>Contacts</Class><SyncKey>2</SyncKey><CollectionId>addressbookFolderId</CollectionId><DeletesAsMoves/><GetChanges/><WindowSize>20</WindowSize><Options><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:MoreAvailable');
     $this->assertEquals(0, $nodes->length, $syncDoc->saveXML());
 }
 /**
  * test xml generation for IPhone
  */
 public function testGetFoldersSyncKey0()
 {
     $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();
     $responseDoc = $folderSync->getResponse();
     #$responseDoc->formatOutput = true; echo $responseDoc->saveXML();
     $xpath = new DomXPath($responseDoc);
     $xpath->registerNamespace('FolderHierarchy', 'uri:FolderHierarchy');
     $nodes = $xpath->query('//FolderHierarchy:FolderSync/FolderHierarchy:Status');
     $this->assertEquals(1, $nodes->length, $responseDoc->saveXML());
     $this->assertEquals(Syncope_Command_FolderSync::STATUS_SUCCESS, $nodes->item(0)->nodeValue, $responseDoc->saveXML());
     $nodes = $xpath->query('//FolderHierarchy:FolderSync/FolderHierarchy:SyncKey');
     $this->assertEquals(1, $nodes->length, $responseDoc->saveXML());
     $this->assertEquals(1, $nodes->item(0)->nodeValue, $responseDoc->saveXML());
     $nodes = $xpath->query('//FolderHierarchy:FolderSync/FolderHierarchy:Changes/FolderHierarchy:Add');
     $this->assertGreaterThanOrEqual(1, $nodes->length, $responseDoc->saveXML());
 }
 /**
  */
 public function testMove()
 {
     // do initial sync first
     $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:ItemOperations"><SyncKey>0</SyncKey></FolderSync>');
     $folderSync = new Syncope_Command_FolderSync($doc, $this->_device, null);
     $folderSync->handle();
     $responseDoc = $folderSync->getResponse();
     #$responseDoc->formatOutput = true; echo $responseDoc->saveXML();
     $doc = new DOMDocument();
     $doc->loadXML('<?xml version="1.0" encoding="utf-8"?>
         <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
         <Moves xmlns="uri:Move"><Move><SrcMsgId>moveItem</SrcMsgId><SrcFldId>addressbookFolderId</SrcFldId><DstFldId>anotherAddressbookFolderId</DstFldId></Move></Moves>');
     $moveItems = new Syncope_Command_MoveItems($doc, $this->_device, null);
     $moveItems->handle();
     $responseDoc = $moveItems->getResponse();
     #$responseDoc->formatOutput = true; echo $responseDoc->saveXML();
     $xpath = new DomXPath($responseDoc);
     $xpath->registerNamespace('Move', 'uri:Move');
     $nodes = $xpath->query('//Move:Moves/Move:Response/Move:Status');
     $this->assertEquals(1, $nodes->length, $responseDoc->saveXML());
     $this->assertEquals(Syncope_Command_MoveItems::STATUS_SUCCESS, $nodes->item(0)->nodeValue, $responseDoc->saveXML());
     $nodes = $xpath->query('//Move:Moves/Move:Response/Move:SrcMsgId');
     $this->assertEquals(1, $nodes->length, $responseDoc->saveXML());
     $this->assertEquals('moveItem', $nodes->item(0)->nodeValue, $responseDoc->saveXML());
     $nodes = $xpath->query('//Move:Moves/Move:Response/Move:DstMsgId');
     $this->assertEquals(1, $nodes->length, $responseDoc->saveXML());
     $this->assertEquals('moveItem', $nodes->item(0)->nodeValue, $responseDoc->saveXML());
 }
示例#7
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));
 }
 /**
  * test handling of invalid SyncKey
  */
 public function testInvalidSyncKey()
 {
     // do initial sync first
     $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, null);
     $folderSync->handle();
     $responseDoc = $folderSync->getResponse();
     $doc = new DOMDocument();
     $doc->loadXML('<?xml version="1.0" encoding="utf-8"?>
         <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
         <FolderCreate xmlns="uri:FolderHierarchy"><SyncKey>11</SyncKey><ParentId/><DisplayName>Test Folder</DisplayName><Type>15</Type></FolderCreate>');
     $folderCreate = new Syncope_Command_FolderCreate($doc, $this->_device, null);
     $folderCreate->handle();
     $responseDoc = $folderCreate->getResponse();
     #$responseDoc->formatOutput = true; echo $responseDoc->saveXML();
     $xpath = new DomXPath($responseDoc);
     $xpath->registerNamespace('FolderHierarchy', 'uri:FolderHierarchy');
     $nodes = $xpath->query('//FolderHierarchy:FolderCreate/FolderHierarchy:Status');
     $this->assertEquals(1, $nodes->length, $responseDoc->saveXML());
     $this->assertEquals(Syncope_Command_FolderSync::STATUS_INVALID_SYNC_KEY, $nodes->item(0)->nodeValue, $responseDoc->saveXML());
 }
示例#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();
 }
 /**
  * 
  */
 public function testGetItemEstimateWithSynckey2()
 {
     // 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();
     $folderSync->getResponse();
     // 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>Contacts</Class><SyncKey>0</SyncKey><CollectionId>addressbookFolderId</CollectionId><DeletesAsMoves/><GetChanges/><WindowSize>2</WindowSize><Options><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();
     $sync->getResponse();
     // 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>Contacts</Class><SyncKey>1</SyncKey><CollectionId>addressbookFolderId</CollectionId><DeletesAsMoves/><GetChanges/><WindowSize>2</WindowSize><Options><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();
     $sync->getResponse();
     // and now we can send the GetItemEstimate command
     $doc = new DOMDocument();
     $doc->loadXML('<?xml version="1.0" encoding="utf-8"?>
         <!DOCTYPE AirSync PUBLIC "-//AIRSYNC//DTD AirSync//EN" "http://www.microsoft.com/">
         <GetItemEstimate xmlns="uri:ItemEstimate" xmlns:AirSync="uri:AirSync"><Collections><Collection><AirSync:FilterType>0</AirSync:FilterType><AirSync:SyncKey>2</AirSync:SyncKey><Class>Contacts</Class><CollectionId>addressbookFolderId</CollectionId></Collection></Collections></GetItemEstimate>');
     $search = new Syncope_Command_GetItemEstimate($doc, $this->_device, null);
     $search->handle();
     $responseDoc = $search->getResponse();
     #$responseDoc->formatOutput = true; echo $responseDoc->saveXML();
     $xpath = new DomXPath($responseDoc);
     $xpath->registerNamespace('ItemEstimate', 'uri:ItemEstimate');
     $nodes = $xpath->query('//ItemEstimate:GetItemEstimate/ItemEstimate:Response/ItemEstimate:Status');
     $this->assertEquals(1, $nodes->length, $responseDoc->saveXML());
     $this->assertEquals(Syncope_Command_GetItemEstimate::STATUS_SUCCESS, $nodes->item(0)->nodeValue, $responseDoc->saveXML());
     $nodes = $xpath->query('//ItemEstimate:GetItemEstimate/ItemEstimate:Response/ItemEstimate:Collection/ItemEstimate:Estimate');
     $this->assertEquals(1, $nodes->length, $responseDoc->saveXML());
     $this->assertEquals(8, $nodes->item(0)->nodeValue, $responseDoc->saveXML());
 }