From 0b2073fd21118258a29e0e2fe1a514ef3c5c3d47 Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Wed, 5 Jan 2011 19:09:28 +0100 Subject: [PATCH] Test guest shares, non-existant shares, callbacks, and add stubs for additional methods in hierarchical driver. --- framework/Share/test/Horde/Share/Base.php | 26 ++++++++++++++++ framework/Share/test/Horde/Share/Sql/Base.php | 5 ++++ .../test/Horde/Share/SqlHierarchical/Base.php | 35 ++++++++++++++++++++++ 3 files changed, 66 insertions(+) diff --git a/framework/Share/test/Horde/Share/Base.php b/framework/Share/test/Horde/Share/Base.php index 434eefeae..77a029d5c 100644 --- a/framework/Share/test/Horde/Share/Base.php +++ b/framework/Share/test/Horde/Share/Base.php @@ -38,6 +38,7 @@ class Horde_Share_Test_Base extends Horde_Test_Case $perm = $share->getPermission(); $this->assertInstanceOf('Horde_Perms_Permission', $perm); $perm->addDefaultPermission(Horde_Perms::SHOW | Horde_Perms::READ); + $perm->addGuestPermission(Horde_Perms::SHOW); $share->setPermission($perm); $share->save(); $this->assertTrue($share->hasPermission('john', Horde_Perms::SHOW)); @@ -103,6 +104,11 @@ class Horde_Share_Test_Base extends Horde_Test_Case // Getting shares from cache. $share = self::$share->getShare('myshare'); $this->assertInstanceOf('Horde_Share_Object', $share); + try { + self::$share->getShare('nonexistant'); + $this->fail('Share "nonexistant" was expected to not exist.'); + } catch (Horde_Exception_NotFound $e) { + } // Reset cache. self::$share->resetCache(); @@ -118,6 +124,11 @@ class Horde_Share_Test_Base extends Horde_Test_Case { // Getting shares from cache. $this->_getShareById($shares); + try { + self::$share->getShareById(99999); + $this->fail('Share 99999 was expected to not exist.'); + } catch (Horde_Exception_NotFound $e) { + } // Reset cache. self::$share->resetCache(); @@ -139,6 +150,8 @@ class Horde_Share_Test_Base extends Horde_Test_Case $this->assertEquals(array('john', 'jane'), $janeshare->listUsers(Horde_Perms::EDIT)); $this->assertEquals(array('jane'), $janeshare->listUsers(Horde_Perms::DELETE)); $this->assertEquals('Jane\'s Share', $janeshare->get('name')); + $this->assertTrue($janeshare->hasPermission('john', Horde_Perms::EDIT)); + $this->assertTrue($janeshare->hasPermission('jane', 99999)); $groupshare = self::$share->getShareById($shares[2]->getId()); $this->assertInstanceOf('Horde_Share_Object', $groupshare); @@ -236,6 +249,13 @@ class Horde_Share_Test_Base extends Horde_Test_Case $this->assertEquals($shareids[1], $shares[0]->getId()); $this->assertEquals($shareids[2], $shares[1]->getId()); + // Guest shares. + $share = self::$share->getShareById(2); + $shares = array_values(self::$share->listShares(false, array('perm' => Horde_Perms::SHOW, 'sort_by' => 'id'))); + $this->assertType('array', $shares); + $this->assertEquals(1, count($shares)); + $this->assertEquals('System Share', $shares[0]->get('name')); + // Shares with certain permissions. $this->assertEquals(4, count(self::$share->listShares('john', array('perm' => Horde_Perms::READ)))); $shares = array_values(self::$share->listShares('john', array('perm' => Horde_Perms::EDIT, 'sort_by' => 'id'))); @@ -379,6 +399,12 @@ class Horde_Share_Test_Base extends Horde_Test_Case } catch (Horde_Exception_NotFound $e) { } } + + public function callback($share) + { + $share->setShareOb(new Horde_Support_Stub()); + $this->assertEquals($share, unserialize(serialize($share))); + } } class Horde_Group_Test extends Horde_Group { diff --git a/framework/Share/test/Horde/Share/Sql/Base.php b/framework/Share/test/Horde/Share/Sql/Base.php index 31d19af8c..bb2c09664 100644 --- a/framework/Share/test/Horde/Share/Sql/Base.php +++ b/framework/Share/test/Horde/Share/Sql/Base.php @@ -137,6 +137,11 @@ class Horde_Share_Test_Sql_Base extends Horde_Share_Test_Base parent::removeShare($share); } + public function testCallback() + { + parent::callback(new Horde_Share_Object_Sql(array())); + } + public static function setUpBeforeClass() { $migration = new Horde_Db_Migration_Base(self::$db); diff --git a/framework/Share/test/Horde/Share/SqlHierarchical/Base.php b/framework/Share/test/Horde/Share/SqlHierarchical/Base.php index 5a4c1b1db..2bfc19f08 100644 --- a/framework/Share/test/Horde/Share/SqlHierarchical/Base.php +++ b/framework/Share/test/Horde/Share/SqlHierarchical/Base.php @@ -159,6 +159,41 @@ class Horde_Share_Test_SqlHierarchical_Base extends Horde_Share_Test_Base parent::removeShare($share); } + public function testCallback() + { + parent::callback(new Horde_Share_Object_Sql_Hierarchical(array())); + } + + public function testListOwners() + { + $this->markTestIncomplete(); + } + + public function testCountOwners() + { + $this->markTestIncomplete(); + } + + public function testCountChildren() + { + $this->markTestIncomplete(); + } + + public function testGetParent() + { + $this->markTestIncomplete(); + } + + public function testGetParents() + { + $this->markTestIncomplete(); + } + + public function testSetParent() + { + $this->markTestIncomplete(); + } + public static function setUpBeforeClass() { $migration = new Horde_Db_Migration_Base(self::$db); -- 2.11.0