Ejemplo n.º 1
0
 /**
  * testUpdateFolderCache
  */
 public function testUpdateFolderCache()
 {
     $result = $this->_json->updateFolderCache($this->_account->getId(), '');
     // create folders directly on imap server
     $this->_imap->createFolder('test', $this->_testFolderName, $this->_account->delimiter);
     $this->_imap->createFolder('testsub', $this->_testFolderName . $this->_account->delimiter . 'test', $this->_account->delimiter);
     // if something goes wrong, we need to delete these folders in tearDown
     $this->_createdFolders[] = $this->_testFolderName . $this->_account->delimiter . 'test' . $this->_account->delimiter . 'testsub';
     $this->_createdFolders[] = $this->_testFolderName . $this->_account->delimiter . 'test';
     // update cache and check if folder is found
     $result = $this->_json->updateFolderCache($this->_account->getId(), $this->_testFolderName);
     $testfolder = $result[0];
     //print_r($testfolder);
     $this->assertGreaterThan(0, count($result));
     $this->assertEquals($this->_testFolderName . $this->_account->delimiter . 'test', $testfolder['globalname']);
     $this->assertEquals(TRUE, (bool) $testfolder['has_children'], 'should have children');
     // delete subfolder directly on imap server
     $this->_imap->removeFolder($this->_testFolderName . $this->_account->delimiter . 'test' . $this->_account->delimiter . 'testsub');
     array_shift($this->_createdFolders);
     // check if has_children got updated and folder is removed from cache
     $this->_json->updateFolderCache($this->_account->getId(), '');
     $testfolder = $this->_getFolder($this->_testFolderName . $this->_account->delimiter . 'test');
     $this->assertEquals(FALSE, (bool) $testfolder['has_children'], 'should have no children');
     $this->setExpectedException('Tinebase_Exception_NotFound');
     $testfoldersub = $this->_getFolder($this->_testFolderName . $this->_account->delimiter . 'test' . $this->_account->delimiter . 'testsub');
     $this->_imap->removeFolder($this->_testFolderName . $this->_account->delimiter . 'test');
     array_shift($this->_createdFolders);
     // try to update message cache of nonexistant folder
     $this->setExpectedException('Felamimail_Exception_IMAPFolderNotFound');
     $removedTestfolder = $this->_json->updateMessageCache($testfolder['id'], 1);
     // update cache and check if folder is deleted
     $result = $this->_json->updateFolderCache($this->_account->getId(), $this->_testFolderName);
     $this->assertEquals(0, count($result));
 }
 /**
  * try search for a message with path filter
  */
 public function testEmptyFolderWithSubfolder()
 {
     $folderName = $this->_testFolderName;
     $folder = $this->_getFolder($this->_testFolderName);
     $this->testCreateFolders();
     //  Faltava parametro para excluir subpastas
     $folderArray = $this->_json->emptyFolder($folder->getId(), 1);
     $this->assertEquals(1, $folderArray['has_children']);
     //  Eliminada as chamadas para update no cache
     $result = $this->_json->updateFolderCache($this->_account->getId(), $this->_testFolderName);
     $this->assertEquals(0, count($result));
 }
 /**
  * testUpdateFolderCacheOfNonexistantFolder
  *
  * @see 0009800: unselectable folder with subfolders disappears
  */
 public function testUpdateFolderCacheOfNonexistantFolder()
 {
     $testfolder = $this->testUpdateFolderCache();
     try {
         $folderName = $this->_testFolderName . $this->_account->delimiter . 'test' . $this->_account->delimiter . 'testsub';
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Trying to fetch deleted folder ' . $folderName);
         }
         $testfoldersub = Felamimail_Controller_Folder::getInstance()->getByBackendAndGlobalName($this->_account->getId(), $folderName);
         $this->fail('Tinebase_Exception_NotFound expected when looking for folder ' . $folderName);
     } catch (Tinebase_Exception_NotFound $tenf) {
     }
     $this->_imap->removeFolder($this->_testFolderName . $this->_account->delimiter . 'test');
     array_shift($this->_createdFolders);
     // try to update message cache of nonexistant folder
     $removedTestfolder = $this->_json->updateMessageCache($testfolder['id'], 1);
     $this->assertEquals(0, $removedTestfolder['is_selectable'], 'Folder should not be selectable');
     // update cache and check if folder is deleted
     $result = $this->_json->updateFolderCache($this->_account->getId(), $this->_testFolderName);
     $this->assertEquals(0, count($result));
 }