public function testFolderTitleIsEmptyForPersonalNamespace()
{
foreach ($this->_getNamespaces() as $namespace) {
- $folder = new Horde_Kolab_Storage_Folder('INBOX');
- $folder->restore($this->_storage, $this->_connection, $namespace);
+ $folder = $this->_getFolder('INBOX', $namespace);
$this->assertEquals('', $folder->getTitle());
}
}
public function testFolderTitleDoesNotContainPersonalNamespace()
{
foreach ($this->_getNamespaces() as $namespace) {
- $folder = new Horde_Kolab_Storage_Folder('INBOX/test');
- $folder->restore($this->_storage, $this->_connection, $namespace);
+ $folder = $this->_getFolder('INBOX/test', $namespace);
$this->assertEquals('test', $folder->getTitle());
}
}
public function testFolderTitleOfOtherUserDoesNotContainUserPrefixAndOtherUserName()
{
foreach ($this->_getNamespaces() as $namespace) {
- $folder = new Horde_Kolab_Storage_Folder('user/test/his_folder');
- $folder->restore($this->_storage, $this->_connection, $namespace);
+ $folder = $this->_getFolder('user/test/his_folder', $namespace);
$this->assertEquals('his_folder', $folder->getTitle());
}
}
public function testFolderTitleReplacesSeparatorWithDoubleColon()
{
foreach ($this->_getNamespaces() as $namespace) {
- $folder = new Horde_Kolab_Storage_Folder('INBOX/test/sub');
- $folder->restore($this->_storage, $this->_connection, $namespace);
+ $folder = $this->_getFolder('INBOX/test/sub', $namespace);
$this->assertEquals('test:sub', $folder->getTitle());
}
}
Horde_Nls::setCharset('UTF8');
foreach ($this->_getNamespaces() as $namespace) {
$name = Horde_String::convertCharset('äöü', 'UTF8', 'UTF7-IMAP');
- $folder = new Horde_Kolab_Storage_Folder('INBOX/' . $name);
- $folder->restore($this->_storage, $this->_connection, $namespace);
+ $folder = $this->_getFolder('INBOX/' . $name, $namespace);
$this->assertEquals('äöü', $folder->getTitle());
}
}
{
foreach ($this->_getNamespaces() as $namespace) {
$_SESSION['horde_auth']['userId'] = 'test';
- $folder = new Horde_Kolab_Storage_Folder(null);
- $folder->restore($this->_storage, $this->_connection, $namespace);
+ $folder = $this->_getFolder(null, $namespace);
$folder->setName('test');
$this->assertEquals('test', $folder->getTitle());
}
{
foreach ($this->_getNamespaces() as $namespace) {
$_SESSION['horde_auth']['userId'] = 'test';
- $folder = new Horde_Kolab_Storage_Folder('INBOX');
- $folder->restore($this->_storage, $this->_connection, $namespace);
+ $folder = $this->_getFolder('INBOX', $namespace);
$this->assertEquals('test', $folder->getOwner());
}
}
{
foreach ($this->_getNamespaces() as $namespace) {
$_SESSION['horde_auth']['userId'] = 'test';
- $folder = new Horde_Kolab_Storage_Folder('INBOX/mine');
- $folder->restore($this->_storage, $this->_connection, $namespace);
+ $folder = $this->_getFolder('INBOX/mine', $namespace);
$this->assertEquals('test', $folder->getOwner());
}
}
public function testFolderOwnerIsOtherUserIfPrefixMatchesOtherNamespace()
{
foreach ($this->_getNamespaces() as $namespace) {
- $folder = new Horde_Kolab_Storage_Folder('user/test');
- $folder->restore($this->_storage, $this->_connection, $namespace);
+ $folder = $this->_getFolder('user/test', $namespace);
$this->assertEquals('test', $folder->getOwner());
}
}
public function testFolderOwnerIsOtherUserIfPrefixContainsOtherNamespace()
{
foreach ($this->_getNamespaces() as $namespace) {
- $folder = new Horde_Kolab_Storage_Folder('user/test/mine');
- $folder->restore($this->_storage, $this->_connection, $namespace);
+ $folder = $this->_getFolder('user/test/mine', $namespace);
$this->assertEquals('test', $folder->getOwner());
}
}
public function testFolderOwnerIsAnonymousIfPrefixContainsSharedNamespace()
{
foreach ($this->_getNamespaces() as $namespace) {
- $folder = new Horde_Kolab_Storage_Folder('shared.test');
- $folder->restore($this->_storage, $this->_connection, $namespace);
+ $folder = $this->_getFolder('shared.test', $namespace);
$this->assertEquals('anonymous', $folder->getOwner());
}
}
{
foreach ($this->_getNamespaces() as $namespace) {
$_SESSION['horde_auth']['userId'] = 'test';
- $folder = new Horde_Kolab_Storage_Folder(null);
- $folder->restore($this->_storage, $this->_connection, $namespace);
+ $folder = $this->_getFolder(null, $namespace);
$folder->setName('test');
$this->assertEquals('test', $folder->getOwner());
}
{
foreach ($this->_getNamespaces() as $namespace) {
$_SESSION['horde_auth']['userId'] = 'test@example.com';
- $folder = new Horde_Kolab_Storage_Folder('user/test/mine');
- $folder->restore($this->_storage, $this->_connection, $namespace);
+ $folder = $this->_getFolder('user/test/mine', $namespace);
$this->assertEquals('test@example.com', $folder->getOwner());
}
}
public function testFolderOwnerHasDomainFromCurrentUserIfNoFolderDomain()
{
foreach ($this->_getNamespaces() as $namespace) {
- $folder = new Horde_Kolab_Storage_Folder('user/test/mine@example.com');
- $folder->restore($this->_storage, $this->_connection, $namespace);
+ $folder = $this->_getFolder('user/test/mine@example.com', $namespace);
$this->assertEquals('test@example.com', $folder->getOwner());
}
}
public function testSetnameDoesAddDefaultPersonalNamespace()
{
foreach ($this->_getNamespaces() as $namespace) {
- $folder = new Horde_Kolab_Storage_Folder(null);
- $folder->restore($this->_storage, $this->_connection, $namespace);
+ $folder = $this->_getFolder(null, $namespace);
$folder->setName('test:this');
$this->assertEquals('INBOX/test/this', $folder->getName());
}
public function testSetnameReplacesDoubleColonWithSeparator()
{
foreach ($this->_getNamespaces() as $namespace) {
- $folder = new Horde_Kolab_Storage_Folder(null);
- $folder->restore($this->_storage, $this->_connection, $namespace);
+ $folder = $this->_getFolder(null, $namespace);
+ $folder->restore($this->_storage, $this->_connection);
$folder->setName('a:b:c');
$this->assertEquals('INBOX/a/b/c', $folder->getName());
}
{
Horde_Nls::setCharset('UTF8');
foreach ($this->_getNamespaces() as $namespace) {
- $folder = new Horde_Kolab_Storage_Folder(null);
- $folder->restore($this->_storage, $this->_connection, $namespace);
+ $folder = $this->_getFolder(null, $namespace);
+ $folder->restore($this->_storage, $this->_connection);
$folder->setName('äöü');
$this->assertEquals(
'INBOX/äöü',
public function testSetnameAllowsCreatingFoldersInSharedNamespace()
{
foreach ($this->_getNamespaces() as $namespace) {
- $folder = new Horde_Kolab_Storage_Folder(null);
- $folder->restore($this->_storage, $this->_connection, $namespace);
+ $folder = $this->_getFolder(null, $namespace);
$folder->setName('shared.test');
$this->assertEquals('shared.test', $folder->getName());
}
public function testSetnameAllowsCreatingFoldersInOthersNamespace()
{
foreach ($this->_getNamespaces() as $namespace) {
- $folder = new Horde_Kolab_Storage_Folder(null);
- $folder->restore($this->_storage, $this->_connection, $namespace);
+ $folder = $this->_getFolder(null, $namespace);
$folder->setName('user:test:test');
$this->assertEquals('user/test/test', $folder->getName());
}
public function testFolderSubpathIsAccessibleForNewFolders()
{
foreach ($this->_getNamespaces() as $namespace) {
- $folder = new Horde_Kolab_Storage_Folder(null);
- $folder->restore($this->_storage, $this->_connection, $namespace);
+ $folder = $this->_getFolder(null, $namespace);
$folder->setName('test');
$this->assertEquals('test', $folder->getSubpath());
}
public function testFolderSubpathDoesNotContainUsernameIfPrefixContainsOtherNamespace()
{
foreach ($this->_getNamespaces() as $namespace) {
- $folder = new Horde_Kolab_Storage_Folder('user/test/mine');
- $folder->restore($this->_storage, $this->_connection, $namespace);
+ $folder = $this->_getFolder('user/test/mine', $namespace);
$this->assertEquals('mine', $folder->getSubpath());
}
}
public function testFolderSubpathReturnsSubpathWithoutNamespacePrefix()
{
foreach ($this->_getNamespaces() as $namespace) {
- $folder = new Horde_Kolab_Storage_Folder('INBOX/a/b');
- $folder->restore($this->_storage, $this->_connection, $namespace);
+ $folder = $this->_getFolder('INBOX/a/b', $namespace);
$this->assertEquals('a/b', $folder->getSubpath());
}
}
public function testFolderSubpathReturnsSubpathWithoutSharedPrefix()
{
foreach ($this->_getNamespaces() as $namespace) {
- $folder = new Horde_Kolab_Storage_Folder('shared.a/b');
- $folder->restore($this->_storage, $this->_connection, $namespace);
+ $folder = $this->_getFolder('shared.a/b', $namespace);
$this->assertEquals('a/b', $folder->getSubpath());
}
}
+ private function _getFolder($name, $namespace)
+ {
+ $this->_connection->expects($this->any())
+ ->method('getNamespace')
+ ->will($this->returnValue($namespace));
+ $folder = new Horde_Kolab_Storage_Folder($name);
+ $folder->restore($this->_storage, $this->_connection);
+ return $folder;
+ }
+
private function _getNamespaces()
{
return array(