Skip to content

Commit

Permalink
New UT: Ensure history does not get polluted for unknown folder types
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasjfox authored and mrubinsk committed Jun 5, 2015
1 parent 0ebed7f commit 2c1c09b
Showing 1 changed file with 60 additions and 14 deletions.
Expand Up @@ -190,6 +190,47 @@ public function testStaleHistoryCleanup()
);
}

public function testEmptyHistoryForUnknownPrefix()
{
// Right now we don't have a backend id mapping
// for the horde prefs, so we don't pollute the history database.
// Ensure it stays like this for unknown id mappings.
$prefs_folder = $this->_getFolderBase(
array(
'user/test/HistoryPrefs' => array(
'a' => array(
'/shared/vendor/kolab/folder-type' => 'h-prefs.default',
'/shared/vendor/horde/share-params' => base64_encode(serialize(array('share_name' => 'internal_id')))
),
'm' => array(
1 => array('file' => __DIR__ . '/../../../../fixtures/preferences.1'),
2 => array('file' => __DIR__ . '/../../../../fixtures/preferences.2'),
),
)
)
);

$data = $prefs_folder->getData('INBOX/HistoryPrefs');
$data_query = $data->getQuery(Horde_Kolab_Storage_Data::QUERY_HISTORY);

// Sync history and check for empty history
$data_query->synchronize();

// ensure loading of the prefs worked
$prefs = $data->getQuery(Horde_Kolab_Storage_Data::QUERY_PREFS)->getApplicationPreferences('horde');
$this->assertEquals(
'20080626155721.771268tms63o0rs4@devmail.example.com',
$prefs['uid']
);

// Check that the history is empty
$this->assertEquals(
0,
count($this->history->getByTimestamp('>', 0)
)
);
}

private function _getData()
{
return $this->_getFolder()->getData('INBOX/History');
Expand All @@ -202,23 +243,28 @@ private function _getDataQuery()
}

private function _getFolder()
{
return $this->_getFolderBase(
array(
'user/test/History' => array(
'a' => array(
'/shared/vendor/kolab/folder-type' => 'note.default',
'/shared/vendor/horde/share-params' => base64_encode(serialize(array('share_name' => 'internal_id')))
),
'm' => array(
1 => array('file' => __DIR__ . '/../../../../fixtures/note.eml'),
2 => array('file' => __DIR__ . '/../../../../fixtures/note2.eml'),
),
)
)
);
}

private function _getFolderBase($additional_folders)
{
$this->history = new Horde_History_Mock('test');
return $this->getDataStorage(
$this->getDataAccount(
array(
'user/test/History' => array(
'a' => array(
'/shared/vendor/kolab/folder-type' => 'note.default',
'/shared/vendor/horde/share-params' => base64_encode(serialize(array('share_name' => 'internal_id')))
),
'm' => array(
1 => array('file' => __DIR__ . '/../../../../fixtures/note.eml'),
2 => array('file' => __DIR__ . '/../../../../fixtures/note2.eml'),
),
)
)
),
$this->getDataAccount($additional_folders),
array(
'queryset' => array('data' => array('queryset' => 'horde')),
'queries' => array(
Expand Down

0 comments on commit 2c1c09b

Please sign in to comment.