2 commits - plugins/libkolab
Thomas Brüderli
bruederli at kolabsys.com
Wed Feb 4 10:25:47 CET 2015
plugins/libkolab/lib/kolab_storage.php | 4 -
plugins/libkolab/tests/kolab_storage_folder.php | 96 ++++++++++++++++++++----
2 files changed, 83 insertions(+), 17 deletions(-)
New commits:
commit e97b087f794e1230c46e6e63bd8aeff67565f85c
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date: Wed Feb 4 10:25:39 2015 +0100
Add more functional tests for kolab_storage_folder
diff --git a/plugins/libkolab/tests/kolab_storage_folder.php b/plugins/libkolab/tests/kolab_storage_folder.php
index 835e9c8..c2f9175 100644
--- a/plugins/libkolab/tests/kolab_storage_folder.php
+++ b/plugins/libkolab/tests/kolab_storage_folder.php
@@ -40,6 +40,21 @@ class kolab_storage_folder_test extends PHPUnit_Framework_TestCase
if (!$authenticated) {
throw new Exception('IMAP login failed for user ' . $rcmail->config->get('tests_username'));
}
+
+ // check for defult groupware folders and clear them
+ $imap = $rcmail->get_storage();
+ $folders = $imap->list_folders('', '*');
+
+ foreach (array('Calendar','Contacts','Files','Tasks','Notes') as $folder) {
+ if (in_array($folder, $folders)) {
+ if (!$imap->clear_folder($folder)) {
+ throw new Exception("Failed to clear folder '$folder'");
+ }
+ }
+ else {
+ throw new Exception("Default folder '$folder' doesn't exits in test user account");
+ }
+ }
}
else {
throw new Exception('Missing test account username/password in config-test.inc.php');
@@ -48,7 +63,7 @@ class kolab_storage_folder_test extends PHPUnit_Framework_TestCase
kolab_storage::setup();
}
- function test_folder_type_check()
+ function test_001_folder_type_check()
{
$folder = new kolab_storage_folder('Calendar', 'event', 'event.default');
$this->assertTrue($folder->valid);
@@ -57,22 +72,13 @@ class kolab_storage_folder_test extends PHPUnit_Framework_TestCase
$folder = new kolab_storage_folder('Calendar', 'event', 'mail');
$this->assertFalse($folder->valid);
$this->assertEquals($folder->get_error(), kolab_storage::ERROR_INVALID_FOLDER);
- }
- function test_get_resource_uri()
- {
- $rcmail = rcmail::get_instance();
- $foldername = 'Calendar';
-
- $folder = new kolab_storage_folder($foldername, 'event', 'event.default');
- $this->assertEquals($folder->get_resource_uri(), sprintf('imap://%s@%s/%s',
- urlencode($rcmail->config->get('tests_username')),
- $rcmail->config->get('default_host'),
- $foldername
- ));
+ $folder = new kolab_storage_folder('INBOX');
+ $this->assertFalse($folder->valid);
+ $this->assertEquals($folder->get_error(), kolab_storage::ERROR_INVALID_FOLDER);
}
- function test_get_owner()
+ function test_002_get_owner()
{
$rcmail = rcmail::get_instance();
$folder = new kolab_storage_folder('Calendar', 'event', 'event');
@@ -89,7 +95,20 @@ class kolab_storage_folder_test extends PHPUnit_Framework_TestCase
$this->assertEquals($folder->get_owner(true), 'major.tom' . $domain);
}
- function test_get_uid()
+ function test_003_get_resource_uri()
+ {
+ $rcmail = rcmail::get_instance();
+ $foldername = 'Calendar';
+
+ $folder = new kolab_storage_folder($foldername, 'event', 'event.default');
+ $this->assertEquals($folder->get_resource_uri(), sprintf('imap://%s@%s/%s',
+ urlencode($rcmail->config->get('tests_username')),
+ $rcmail->config->get('default_host'),
+ $foldername
+ ));
+ }
+
+ function test_004_get_uid()
{
$rcmail = rcmail::get_instance();
$folder = new kolab_storage_folder('Doesnt-Exist', 'event', 'event');
@@ -99,4 +118,51 @@ class kolab_storage_folder_test extends PHPUnit_Framework_TestCase
$this->assertEquals($folder->get_uid(), $uid1);
$this->assertEquals($folder->get_error(), kolab_storage::ERROR_IMAP_CONN);
}
+
+ function test_005_subscribe()
+ {
+ $folder = new kolab_storage_folder('Contacts', 'contact');
+ $this->assertTrue($folder->subscribe(true));
+ $this->assertTrue($folder->is_subscribed());
+
+ $this->assertTrue($folder->subscribe(false));
+ $this->assertFalse($folder->is_subscribed());
+
+ $folder->subscribe(true);
+ }
+
+ function test_006_activate()
+ {
+ $folder = new kolab_storage_folder('Calendar', 'contact');
+ $this->assertTrue($folder->activate(true));
+ $this->assertTrue($folder->is_active());
+
+ $this->assertTrue($folder->activate(false));
+ $this->assertFalse($folder->is_active());
+ }
+
+ function test_010_write_contacts()
+ {
+ $contacts = array(
+ 'name' => 'FN',
+ 'surname' => 'Last',
+ 'firstname' => 'First',
+ 'email' => array(
+ array('type' => 'home', 'address' => 'first.last at example.org'),
+ ),
+ );
+
+ $folder = new kolab_storage_folder('Contacts', 'contact');
+ $saved = $folder->save($contact, 'contact');
+ $this->assertTrue((bool)$saved);
+ }
+
+ /**
+ * @depends test_010_write_contacts
+ */
+ function test_011_list_contacts()
+ {
+ $folder = new kolab_storage_folder('Contacts', 'contact');
+ $this->assertEquals($folder->count(), 1);
+ }
}
commit b32c36f58f26b3e8c926aa83932d1689ac29fc7f
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date: Wed Feb 4 10:25:16 2015 +0100
Fix subscription cache clearing after subscription changes
diff --git a/plugins/libkolab/lib/kolab_storage.php b/plugins/libkolab/lib/kolab_storage.php
index a4868ac..1570b0d 100644
--- a/plugins/libkolab/lib/kolab_storage.php
+++ b/plugins/libkolab/lib/kolab_storage.php
@@ -1198,7 +1198,7 @@ class kolab_storage
}
}
else if (self::$imap->subscribe($folder)) {
- self::$subscriptions === null;
+ self::$subscriptions = null;
return true;
}
@@ -1226,7 +1226,7 @@ class kolab_storage
return true;
}
else if (self::$imap->unsubscribe($folder)) {
- self::$subscriptions === null;
+ self::$subscriptions = null;
return true;
}
More information about the commits
mailing list