New test for the namespace handler.
authorGunnar Wrobel <p@rdus.de>
Thu, 11 Mar 2010 20:48:56 +0000 (21:48 +0100)
committerGunnar Wrobel <wrobel@temple.(none)>
Thu, 11 Mar 2010 21:35:05 +0000 (22:35 +0100)
framework/Kolab_Storage/test/Horde/Kolab/Storage/NamespaceTest.php [new file with mode: 0644]

diff --git a/framework/Kolab_Storage/test/Horde/Kolab/Storage/NamespaceTest.php b/framework/Kolab_Storage/test/Horde/Kolab/Storage/NamespaceTest.php
new file mode 100644 (file)
index 0000000..600d1c8
--- /dev/null
@@ -0,0 +1,84 @@
+<?php
+/**
+ * Test the handling of namespaces.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Storage
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Storage
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once 'Autoload.php';
+
+/**
+ * Test the handling of namespaces.
+ *
+ * Copyright 2010 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @category Kolab
+ * @package  Kolab_Storage
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Storage
+ */
+class Horde_Kolab_Storage_NamespaceTest extends PHPUnit_Framework_TestCase
+{
+    public function testFolderTitleIsEmptyForInbox()
+    {
+        $this->markTestIncomplete('This expectation currently does not hold as we are not using the namespace handler yet.');
+        $folder = new Horde_Kolab_Storage_Folder(
+            'INBOX',
+            new Horde_Kolab_Storage_Namespace()
+        );
+        $this->assertEquals('', $folder->getTitle());
+    }
+
+    public function testFolderTitleDoesNotContainInbox()
+    {
+        $folder = new Horde_Kolab_Storage_Folder(
+            'INBOX/test',
+            new Horde_Kolab_Storage_Namespace()
+        );
+        $this->assertEquals('test', $folder->getTitle());
+    }
+
+    public function testFolderTitleOfOtherUserDoesNotContainUserPrefixAndOtherUserName()
+    {
+        $this->markTestIncomplete('This expectation currently does not hold as we are not using the namespace handler yet.');
+        $folder = new Horde_Kolab_Storage_Folder(
+            'user/test/his_folder',
+            new Horde_Kolab_Storage_Namespace()
+        );
+        $this->assertEquals('his_folder', $folder->getTitle());
+    }
+
+    public function testFolderTitleReplacesSeparatorWithDoubleColon()
+    {
+        $folder = new Horde_Kolab_Storage_Folder(
+            'INBOX/test/sub',
+            new Horde_Kolab_Storage_Namespace()
+        );
+        $this->assertEquals('test:sub', $folder->getTitle());
+    }
+
+    public function testFolderTitleConvertsUtf7()
+    {
+        Horde_String::setDefaultCharset('UTF8');
+        $name = Horde_String::convertCharset('äöü', 'UTF8', 'UTF7-IMAP');
+        $folder = new Horde_Kolab_Storage_Folder(
+            'INBOX/' . $name,
+            new Horde_Kolab_Storage_Namespace()
+        );
+        $this->assertEquals('äöü', $folder->getTitle());
+    }
+
+}
\ No newline at end of file