Test guest shares, non-existant shares, callbacks, and add stubs for additional metho...
authorJan Schneider <jan@horde.org>
Wed, 5 Jan 2011 18:09:28 +0000 (19:09 +0100)
committerJan Schneider <jan@horde.org>
Wed, 5 Jan 2011 18:09:28 +0000 (19:09 +0100)
framework/Share/test/Horde/Share/Base.php
framework/Share/test/Horde/Share/Sql/Base.php
framework/Share/test/Horde/Share/SqlHierarchical/Base.php

index 434eefe..77a029d 100644 (file)
@@ -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 {
index 31d19af..bb2c096 100644 (file)
@@ -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);
index 5a4c1b1..2bfc19f 100644 (file)
@@ -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);