Remove getStorage(), getId() from the Kolab_Session interface, consolidate decorators...
authorGunnar Wrobel <p@rdus.de>
Wed, 17 Mar 2010 09:55:36 +0000 (10:55 +0100)
committerGunnar Wrobel <wrobel@temple.(none)>
Wed, 17 Mar 2010 20:23:32 +0000 (21:23 +0100)
14 files changed:
framework/Kolab_Session/lib/Horde/Kolab/Session.php
framework/Kolab_Session/lib/Horde/Kolab/Session/Base.php
framework/Kolab_Session/lib/Horde/Kolab/Session/Decorator/Anonymous.php
framework/Kolab_Session/lib/Horde/Kolab/Session/Decorator/Base.php [new file with mode: 0644]
framework/Kolab_Session/lib/Horde/Kolab/Session/Decorator/Logged.php
framework/Kolab_Session/lib/Horde/Kolab/Session/Decorator/Stored.php
framework/Kolab_Session/lib/Horde/Kolab/Session/Singleton.php [deleted file]
framework/Kolab_Session/package.xml
framework/Kolab_Session/test/Horde/Kolab/Session/Class/BaseTest.php
framework/Kolab_Session/test/Horde/Kolab/Session/Class/Decorator/AnonymousTest.php
framework/Kolab_Session/test/Horde/Kolab/Session/Class/Decorator/BaseTest.php [new file with mode: 0644]
framework/Kolab_Session/test/Horde/Kolab/Session/Class/Decorator/LoggedTest.php
framework/Kolab_Session/test/Horde/Kolab/Session/Class/Decorator/StoredTest.php
framework/Kolab_Session/test/Horde/Kolab/Session/Integration/SessionTest.php [deleted file]

index 9485f7d..4a1e778 100644 (file)
@@ -58,15 +58,6 @@ interface Horde_Kolab_Session
     public function getId();
 
     /**
-     * Set the user id used for connecting the session.
-     *
-     * @param string $id The user id.
-     *
-     * @return NULL
-     */
-    public function setId($id);
-
-    /**
      * Return the users mail address.
      *
      * @return string The users mail address.
@@ -100,11 +91,4 @@ interface Horde_Kolab_Session
      * @return string The freebusy host for the current user.
      */
     public function getFreebusyServer();
-
-    /**
-     * Return a connection to the Kolab storage system.
-     *
-     * @return Horde_Kolab_Storage The storage connection.
-     */
-    public function getStorage();
 }
index ca5e0fc..5d1b5ff 100644 (file)
@@ -73,7 +73,7 @@ class Horde_Kolab_Session_Base implements Horde_Kolab_Session
      *
      * @var string
      */
-    private $_imap_server;
+    private $_imap_server = false;
 
     /**
      * The free/busy server for the current user.
@@ -291,18 +291,6 @@ class Horde_Kolab_Session_Base implements Horde_Kolab_Session
     }
 
     /**
-     * Set the user id used for connecting the session.
-     *
-     * @param string $id The user id.
-     *
-     * @return NULL
-     */
-    public function setId($id)
-    {
-        $this->_user_id = $id;
-    }
-
-    /**
      * Return the users mail address.
      *
      * @return string The users mail address.
@@ -351,30 +339,4 @@ class Horde_Kolab_Session_Base implements Horde_Kolab_Session
     {
         return $this->_freebusy_server;
     }
-
-    /**
-     * Return a connection to the Kolab storage system.
-     *
-     * @return Horde_Kolab_Storage The storage connection.
-     *
-     * @todo Implement
-     */
-    public function getStorage()
-    {
-        if (!$this->_connected) {
-            return false;
-        }
-        if (empty($this->_storage)) {
-            //@todo: factory?
-            $this->_storage = new Horde_Kolab_Storage(
-                'Imap',
-                //@todo: Use Session_Auth
-                array('hostspec' => $this->getImapServer(),
-                      'username' => Horde_Auth::getAuth(),
-                      'password' => Horde_Auth::getCredential('password'),
-                      'secure'   => true)
-            );
-        }
-        return $this->_storage;
-    }
 }
index 06c5d36..a6e39bf 100644 (file)
  * @link     http://pear.horde.org/index.php?package=Kolab_Session
  */
 class Horde_Kolab_Session_Decorator_Anonymous
-implements Horde_Kolab_Session
+extends Horde_Kolab_Session_Decorator_Base
 {
     /**
-     * The session handler this instance provides with anonymous access.
-     *
-     * @var Horde_Kolab_Session
-     */
-    private $_session;
-
-    /**
      * Anonymous user ID.
      *
      * @var string
@@ -70,7 +63,7 @@ implements Horde_Kolab_Session
         $user,
         $pass
     ) {
-        $this->_session        = $session;
+        parent::__construct($session);
         $this->_anonymous_id   = $user;
         $this->_anonymous_pass = $pass;
     }
@@ -108,78 +101,4 @@ implements Horde_Kolab_Session
         }
         return $id;
     }
-
-    /**
-     * Set the user id used for connecting the session.
-     *
-     * @param string $id The user id.
-     *
-     * @return NULL
-     */
-    public function setId($id)
-    {
-        $this->_session->setId($id);
-    }
-
-    /**
-     * Return the users mail address.
-     *
-     * @return string The users mail address.
-     */
-    public function getMail()
-    {
-        return $this->_session->getMail();
-    }
-
-    /**
-     * Return the users uid.
-     *
-     * @return string The users uid.
-     */
-    public function getUid()
-    {
-        return $this->_session->getUid();
-    }
-
-    /**
-     * Return the users name.
-     *
-     * @return string The users name.
-     */
-    public function getName()
-    {
-        return $this->_session->getName();
-    }
-
-    /**
-     * Return the imap server.
-     *
-     * @return string The imap host for the current user.
-     */
-    public function getImapServer()
-    {
-        return $this->_session->getImapServer();
-    }
-
-    /**
-     * Return the freebusy server.
-     *
-     * @return string The freebusy host for the current user.
-     */
-    public function getFreebusyServer()
-    {
-        return $this->_session->getFreebusyServer();
-    }
-
-    /**
-     * Return a connection to the Kolab storage system.
-     *
-     * @return Horde_Kolab_Storage The storage connection.
-     *
-     * @todo Adapt to new structure of this class.
-     */
-    public function getStorage()
-    {
-        return $this->_session->getStorage();
-    }
 }
diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Decorator/Base.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Decorator/Base.php
new file mode 100644 (file)
index 0000000..4570e33
--- /dev/null
@@ -0,0 +1,127 @@
+<?php
+/**
+ * The Horde_Kolab_Session_Decorator_Base provides a base for session
+ * decorators.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Session
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Session
+ */
+
+/**
+ * The Horde_Kolab_Session_Decorator_Base provides a base for session
+ * decorators.
+ *
+ * Copyright 2009-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_Session
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Session
+ */
+class Horde_Kolab_Session_Decorator_Base
+implements Horde_Kolab_Session
+{
+    /**
+     * The session handler this instance provides with anonymous access.
+     *
+     * @var Horde_Kolab_Session
+     */
+    protected $_session;
+
+    /**
+     * Constructor.
+     *
+     * @param Horde_Kolab_Session $session The this instance should provide
+     *                                     anonymous access for.
+     */
+    public function __construct(
+        Horde_Kolab_Session $session
+    ) {
+        $this->_session        = $session;
+    }
+
+    /**
+     * Try to connect the session handler.
+     *
+     * @param string $user_id     The user ID to connect with.
+     * @param array  $credentials An array of login credentials. For Kolab,
+     *                            this must contain a "password" entry.
+     *
+     * @return NULL
+     *
+     * @throws Horde_Kolab_Session_Exception If the connection failed.
+     */
+    public function connect($user_id = null, array $credentials = null)
+    {
+        $this->_session->connect($user_id, $credentials);
+    }
+
+    /**
+     * Return the user id used for connecting the session.
+     *
+     * @return string The user id.
+     */
+    public function getId()
+    {
+        return $this->_session->getId();
+    }
+
+    /**
+     * Return the users mail address.
+     *
+     * @return string The users mail address.
+     */
+    public function getMail()
+    {
+        return $this->_session->getMail();
+    }
+
+    /**
+     * Return the users uid.
+     *
+     * @return string The users uid.
+     */
+    public function getUid()
+    {
+        return $this->_session->getUid();
+    }
+
+    /**
+     * Return the users name.
+     *
+     * @return string The users name.
+     */
+    public function getName()
+    {
+        return $this->_session->getName();
+    }
+
+    /**
+     * Return the imap server.
+     *
+     * @return string The imap host for the current user.
+     */
+    public function getImapServer()
+    {
+        return $this->_session->getImapServer();
+    }
+
+    /**
+     * Return the freebusy server.
+     *
+     * @return string The freebusy host for the current user.
+     */
+    public function getFreebusyServer()
+    {
+        return $this->_session->getFreebusyServer();
+    }
+}
index a2a2fb5..0ba31d6 100644 (file)
  * @link     http://pear.horde.org/index.php?package=Kolab_Session
  */
 class Horde_Kolab_Session_Decorator_Logged
-implements Horde_Kolab_Session
+extends Horde_Kolab_Session_Decorator_Base
 {
     /**
-     * The session handler.
-     *
-     * @var Horde_Kolab_Session
-     */
-    private $_session;
-
-    /**
      * The logger.
      *
      * @var mixed
@@ -55,7 +48,7 @@ implements Horde_Kolab_Session
         Horde_Kolab_Session $session,
         $logger
     ) {
-        $this->_session = $session;
+        parent::__construct($session);
         $this->_logger  = $logger;
     }
 
@@ -90,86 +83,4 @@ implements Horde_Kolab_Session
             throw $e;
         }
     }
-
-    /**
-     * Return the user id used for connecting the session.
-     *
-     * @return string The user id.
-     */
-    public function getId()
-    {
-        return $this->_session->getId();
-    }
-
-    /**
-     * Set the user id used for connecting the session.
-     *
-     * @param string $id The user id.
-     *
-     * @return NULL
-     */
-    public function setId($id)
-    {
-        $this->_session->setId($id);
-    }
-
-    /**
-     * Return the users mail address.
-     *
-     * @return string The users mail address.
-     */
-    public function getMail()
-    {
-        return $this->_session->getMail();
-    }
-
-    /**
-     * Return the users uid.
-     *
-     * @return string The users uid.
-     */
-    public function getUid()
-    {
-        return $this->_session->getUid();
-    }
-
-    /**
-     * Return the users name.
-     *
-     * @return string The users name.
-     */
-    public function getName()
-    {
-        return $this->_session->getName();
-    }
-
-    /**
-     * Return the imap server.
-     *
-     * @return string The imap host for the current user.
-     */
-    public function getImapServer()
-    {
-        return $this->_session->getImapServer();
-    }
-
-    /**
-     * Return the freebusy server.
-     *
-     * @return string The freebusy host for the current user.
-     */
-    public function getFreebusyServer()
-    {
-        return $this->_session->getFreebusyServer();
-    }
-
-    /**
-     * Return a connection to the Kolab storage system.
-     *
-     * @return Horde_Kolab_Storage The storage connection.
-     */
-    public function getStorage()
-    {
-        return $this->_session->getStorage();
-    }
 }
index b9d7c5e..ee6e656 100644 (file)
  * @link     http://pear.horde.org/index.php?package=Kolab_Session
  */
 class Horde_Kolab_Session_Decorator_Stored
-implements Horde_Kolab_Session
+extends Horde_Kolab_Session_Decorator_Base
 {
     /**
-     * The session handler.
-     *
-     * @var Horde_Kolab_Session
-     */
-    private $_session;
-
-    /**
      * The storage.
      *
      * @var Horde_Kolab_Session_Storage
@@ -59,7 +52,7 @@ implements Horde_Kolab_Session
         Horde_Kolab_Session $session,
         Horde_Kolab_Session_Storage_Interface $storage
     ) {
-        $this->_session = $session;
+        parent::__construct($session);
         $this->_storage = $storage;
     }
 
@@ -87,86 +80,4 @@ implements Horde_Kolab_Session
         $this->_session->connect($user_id, $credentials);
         $this->_connected = true;
     }
-
-    /**
-     * Return the user id used for connecting the session.
-     *
-     * @return string The user id.
-     */
-    public function getId()
-    {
-        return $this->_session->getId();
-    }
-
-    /**
-     * Set the user id used for connecting the session.
-     *
-     * @param string $id The user id.
-     *
-     * @return NULL
-     */
-    public function setId($id)
-    {
-        $this->_session->setId($id);
-    }
-
-    /**
-     * Return the users mail address.
-     *
-     * @return string The users mail address.
-     */
-    public function getMail()
-    {
-        return $this->_session->getMail();
-    }
-
-    /**
-     * Return the users uid.
-     *
-     * @return string The users uid.
-     */
-    public function getUid()
-    {
-        return $this->_session->getUid();
-    }
-
-    /**
-     * Return the users name.
-     *
-     * @return string The users name.
-     */
-    public function getName()
-    {
-        return $this->_session->getName();
-    }
-
-    /**
-     * Return the imap server.
-     *
-     * @return string The imap host for the current user.
-     */
-    public function getImapServer()
-    {
-        return $this->_session->getImapServer();
-    }
-
-    /**
-     * Return the freebusy server.
-     *
-     * @return string The freebusy host for the current user.
-     */
-    public function getFreebusyServer()
-    {
-        return $this->_session->getFreebusyServer();
-    }
-
-    /**
-     * Return a connection to the Kolab storage system.
-     *
-     * @return Horde_Kolab_Storage The storage connection.
-     */
-    public function getStorage()
-    {
-        return $this->_session->getStorage();
-    }
 }
diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Singleton.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Singleton.php
deleted file mode 100644 (file)
index e32a152..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-<?php
-/**
- * A singleton pattern providing Horde_Kolab_Session instances.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package  Kolab_Session
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Session
- */
-
-/**
- * A singleton pattern providing Horde_Kolab_Session instances.
- *
- * Copyright 2008-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_Session
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Session
- */
-class Horde_Kolab_Session_Singleton
-{
-    /**
-     * Horde_Kolab_Session instance.
-     *
-     * @var Horde_Kolab_Session
-     */
-    static private $_instance;
-
-    /**
-     * Attempts to return a reference to a concrete Horde_Kolab_Session instance.
-     *
-     * It will only create a new instance if no Horde_Kolab_Session instance
-     * currently exists
-     *
-     * @param string $user        The session will be setup for the user with
-     *                            this ID. For Kolab this must either contain
-     *                            the user id or the primary user mail address.
-     *
-     * @param array  $credentials An array of login credentials. For Kolab,
-     *                            this must contain a "password" entry.
-     *
-     * @return Horde_Kolab_Session The concrete Session reference.
-     *
-     * @throws Horde_Kolab_Session_Exception If the connection failed.
-     */
-    static public function singleton($user = null, array $credentials = null)
-    {
-        global $conf;
-
-        if (!isset(self::$_instance)) {
-            $config            = $conf['kolab'];
-            $config['logger']  = Horde::getLogger();
-            $factory = new Horde_Kolab_Session_Factory_Configuration($config);
-            self::$_instance = $factory->getSession($user, $credentials);
-        }
-        return self::$_instance;
-    }
-}
index fa316b7..4c0c306 100644 (file)
@@ -55,6 +55,7 @@ http://pear.php.net/dtd/package-2.0.xsd">
        <file name="Base.php" role="php" />
        <dir name="Decorator">
         <file name="Anonymous.php" role="php" />
+        <file name="Base.php" role="php" />
         <file name="Logged.php" role="php" />
         <file name="Stored.php" role="php" />
        </dir> <!-- /lib/Horde/Session/Decorator -->
@@ -62,7 +63,6 @@ http://pear.php.net/dtd/package-2.0.xsd">
        <dir name="Exception">
         <file name="Badlogin.php" role="php" />
        </dir> <!-- /lib/Horde/Session/Exception -->
-       <file name="Singleton.php" role="php" />
        <dir name="Storage">
         <file name="Mock.php" role="php" />
         <file name="Interface.php" role="php" />
@@ -109,7 +109,6 @@ http://pear.php.net/dtd/package-2.0.xsd">
        </dir> <!-- /test/Horde/Kolab/Session/Class -->
        <dir name="Integration">
         <file name="AnonymousTest.php" role="test" />
-        <file name="SessionTest.php" role="test" />
         <file name="ValidTest.php" role="test" />
        </dir> <!-- /test/Horde/Kolab/Session/Integration -->
        <file name="phpunit.xml" role="test" />
@@ -166,9 +165,9 @@ http://pear.php.net/dtd/package-2.0.xsd">
    <install name="lib/Horde/Kolab/Session/Exception.php" as="Horde/Kolab/Session/Exception.php" />
    <install name="lib/Horde/Kolab/Session/Exception/Badlogin.php" as="Horde/Kolab/Session/Exception/Badlogin.php" />
    <install name="lib/Horde/Kolab/Session/Decorator/Anonymous.php" as="Horde/Kolab/Session/Decorator/Anonymous.php" />
+   <install name="lib/Horde/Kolab/Session/Decorator/Base.php" as="Horde/Kolab/Session/Decorator/Base.php" />
    <install name="lib/Horde/Kolab/Session/Decorator/Logged.php" as="Horde/Kolab/Session/Decorator/Logged.php" />
    <install name="lib/Horde/Kolab/Session/Decorator/Stored.php" as="Horde/Kolab/Session/Decorator/Stored.php" />
-   <install name="lib/Horde/Kolab/Session/Singleton.php" as="Horde/Kolab/Session/Singleton.php" />
    <install name="lib/Horde/Kolab/Session/Storage/Interface.php" as="Horde/Kolab/Session/Storage/Interface.php" />
    <install name="lib/Horde/Kolab/Session/Storage/Mock.php" as="Horde/Kolab/Session/Storage/Mock.php" />
    <install name="lib/Horde/Kolab/Session/Storage/Sessionobjects.php" as="Horde/Kolab/Session/Storage/Sessionobjects.php" />
@@ -188,7 +187,6 @@ http://pear.php.net/dtd/package-2.0.xsd">
    <install name="test/Horde/Kolab/Session/Class/Valid/BaseTest.php" as="Horde/Kolab/Session/Class/Valid/BaseTest.php" />
    <install name="test/Horde/Kolab/Session/Class/Valid/Decorator/LoggedTest.php" as="Horde/Kolab/Session/Class/Valid/Decorator/LoggedTest.php" />
    <install name="test/Horde/Kolab/Session/Integration/AnonymousTest.php" as="Horde/Kolab/Session/Integration/AnonymousTest.php" />
-   <install name="test/Horde/Kolab/Session/Integration/SessionTest.php" as="Horde/Kolab/Session/Integration/SessionTest.php" />
    <install name="test/Horde/Kolab/Session/Integration/ValidTest.php" as="Horde/Kolab/Session/Integration/ValidTest.php" />
    <install name="test/Horde/Kolab/Session/phpunit.xml" as="Horde/Kolab/Session/phpunit.php" />
    <install name="test/Horde/Kolab/Session/SessionTestCase.php" as="Horde/Kolab/Session/SessionTestCase.php" />
index cd690ac..d419a43 100644 (file)
@@ -459,9 +459,4 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest
         $session->connect('userid', array('password' => ''));
         $this->assertEquals('localhost', $session->getImapServer());
     }
-
-    public function testMethodGetstorageHasResultKolabstorageConnectionForTheCurrentUser()
-    {
-        $this->markTestIncomplete('Not implemented');
-    }
 }
\ No newline at end of file
index 223be23..e885bc9 100644 (file)
@@ -80,90 +80,4 @@ extends Horde_Kolab_Session_SessionTestCase
         );
         $anonymous->getId();
     }
-
-    public function testMethodSetidGetsDelegated()
-    {
-        $session = $this->getMock('Horde_Kolab_Session');
-        $session->expects($this->once())
-            ->method('setId')
-            ->with('1');
-        $anonymous = new Horde_Kolab_Session_Decorator_Anonymous(
-            $session, 'anonymous', 'pass'
-        );
-        $anonymous->setId('1');
-    }
-
-    public function testMethodGetmailGetsDelegated()
-    {
-        $session = $this->getMock('Horde_Kolab_Session');
-        $session->expects($this->once())
-            ->method('getMail')
-            ->will($this->returnValue('1'));
-        $anonymous = new Horde_Kolab_Session_Decorator_Anonymous(
-            $session, 'anonymous', 'pass'
-        );
-        $anonymous->getMail();
-    }
-
-    public function testMethodGetuidGetsDelegated()
-    {
-        $session = $this->getMock('Horde_Kolab_Session');
-        $session->expects($this->once())
-            ->method('getUid')
-            ->will($this->returnValue('1'));
-        $anonymous = new Horde_Kolab_Session_Decorator_Anonymous(
-            $session, 'anonymous', 'pass'
-        );
-        $anonymous->getUid();
-    }
-
-    public function testMethodGetnameGetsDelegated()
-    {
-        $session = $this->getMock('Horde_Kolab_Session');
-        $session->expects($this->once())
-            ->method('getName')
-            ->will($this->returnValue('1'));
-        $anonymous = new Horde_Kolab_Session_Decorator_Anonymous(
-            $session, 'anonymous', 'pass'
-        );
-        $anonymous->getName();
-    }
-
-    public function testMethodGetimapserverGetsDelegated()
-    {
-        $session = $this->getMock('Horde_Kolab_Session');
-        $session->expects($this->once())
-            ->method('getImapServer')
-            ->will($this->returnValue('1'));
-        $anonymous = new Horde_Kolab_Session_Decorator_Anonymous(
-            $session, 'anonymous', 'pass'
-        );
-        $anonymous->getImapServer();
-    }
-
-    public function testMethodGetfreebusyserverGetsDelegated()
-    {
-        $session = $this->getMock('Horde_Kolab_Session');
-        $session->expects($this->once())
-            ->method('getFreebusyServer')
-            ->will($this->returnValue('1'));
-        $anonymous = new Horde_Kolab_Session_Decorator_Anonymous(
-            $session, 'anonymous', 'pass'
-        );
-        $anonymous->getFreebusyServer();
-    }
-
-    public function testMethodGetstorageGetsDelegated()
-    {
-        $session = $this->getMock('Horde_Kolab_Session');
-        $session->expects($this->once())
-            ->method('getStorage')
-            ->will($this->returnValue('1'));
-        $anonymous = new Horde_Kolab_Session_Decorator_Anonymous(
-            $session, 'anonymous', 'pass'
-        );
-        $anonymous->getStorage();
-    }
-
-
 }
\ No newline at end of file
diff --git a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Decorator/BaseTest.php b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Decorator/BaseTest.php
new file mode 100644 (file)
index 0000000..93b124a
--- /dev/null
@@ -0,0 +1,119 @@
+<?php
+/**
+ * Test the base decorator.
+ *
+ * PHP version 5
+ *
+ * @category Kolab
+ * @package  Kolab_Session
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Session
+ */
+
+/**
+ * Prepare the test setup.
+ */
+require_once dirname(__FILE__) . '/../../Autoload.php';
+
+/**
+ * Test the base decorator.
+ *
+ * Copyright 2009-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_Session
+ * @author   Gunnar Wrobel <wrobel@pardus.de>
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link     http://pear.horde.org/index.php?package=Kolab_Session
+ */
+class Horde_Kolab_Session_Class_Decorator_BaseTest
+extends Horde_Kolab_Session_SessionTestCase
+{
+    public function testMethodConnectGetsDelegated()
+    {
+        $session = $this->getMock('Horde_Kolab_Session');
+        $session->expects($this->once())
+            ->method('connect')
+            ->with(array('password' => 'pass'));
+        $anonymous = new Horde_Kolab_Session_Decorator_Base(
+            $session
+        );
+        $anonymous->connect(array('password' => 'pass'));
+    }
+
+    public function testMethodGetidGetsDelegated()
+    {
+        $session = $this->getMock('Horde_Kolab_Session');
+        $session->expects($this->once())
+            ->method('getId')
+            ->will($this->returnValue('1'));
+        $anonymous = new Horde_Kolab_Session_Decorator_Base(
+            $session
+        );
+        $anonymous->getId();
+    }
+
+    public function testMethodGetmailGetsDelegated()
+    {
+        $session = $this->getMock('Horde_Kolab_Session');
+        $session->expects($this->once())
+            ->method('getMail')
+            ->will($this->returnValue('1'));
+        $anonymous = new Horde_Kolab_Session_Decorator_Base(
+            $session
+        );
+        $anonymous->getMail();
+    }
+
+    public function testMethodGetuidGetsDelegated()
+    {
+        $session = $this->getMock('Horde_Kolab_Session');
+        $session->expects($this->once())
+            ->method('getUid')
+            ->will($this->returnValue('1'));
+        $anonymous = new Horde_Kolab_Session_Decorator_Base(
+            $session
+        );
+        $anonymous->getUid();
+    }
+
+    public function testMethodGetnameGetsDelegated()
+    {
+        $session = $this->getMock('Horde_Kolab_Session');
+        $session->expects($this->once())
+            ->method('getName')
+            ->will($this->returnValue('1'));
+        $anonymous = new Horde_Kolab_Session_Decorator_Base(
+            $session
+        );
+        $anonymous->getName();
+    }
+
+    public function testMethodGetimapserverGetsDelegated()
+    {
+        $session = $this->getMock('Horde_Kolab_Session');
+        $session->expects($this->once())
+            ->method('getImapServer')
+            ->will($this->returnValue('1'));
+        $anonymous = new Horde_Kolab_Session_Decorator_Base(
+            $session
+        );
+        $anonymous->getImapServer();
+    }
+
+    public function testMethodGetfreebusyserverGetsDelegated()
+    {
+        $session = $this->getMock('Horde_Kolab_Session');
+        $session->expects($this->once())
+            ->method('getFreebusyServer')
+            ->will($this->returnValue('1'));
+        $anonymous = new Horde_Kolab_Session_Decorator_Base(
+            $session
+        );
+        $anonymous->getFreebusyServer();
+    }
+}
\ No newline at end of file
index 76148f9..68ee12c 100644 (file)
@@ -89,96 +89,4 @@ extends Horde_Kolab_Session_SessionTestCase
         } catch (Horde_Kolab_Session_Exception $e) {
         }
     }
-
-    public function testMethodConnectGetsDelegated()
-    {
-        $session = $this->getMock('Horde_Kolab_Session');
-        $session->expects($this->once())
-            ->method('connect')
-            ->with(array('password' => 'pass'));
-        $logged = new Horde_Kolab_Session_Decorator_Logged($session, $this->logger);
-        $logged->connect(array('password' => 'pass'));
-    }
-
-    public function testMethodGetidGetsDelegated()
-    {
-        $session = $this->getMock('Horde_Kolab_Session');
-        $session->expects($this->once())
-            ->method('getId')
-            ->will($this->returnValue('1'));
-        $logged = new Horde_Kolab_Session_Decorator_Logged($session, $this->logger);
-        $logged->getId();
-    }
-
-    public function testMethodSetidGetsDelegated()
-    {
-        $session = $this->getMock('Horde_Kolab_Session');
-        $session->expects($this->once())
-            ->method('setId')
-            ->with('1');
-        $logged = new Horde_Kolab_Session_Decorator_Logged($session, $this->logger);
-        $logged->setId('1');
-    }
-
-    public function testMethodGetmailGetsDelegated()
-    {
-        $session = $this->getMock('Horde_Kolab_Session');
-        $session->expects($this->once())
-            ->method('getMail')
-            ->will($this->returnValue('1'));
-        $logged = new Horde_Kolab_Session_Decorator_Logged($session, $this->logger);
-        $logged->getMail();
-    }
-
-    public function testMethodGetuidGetsDelegated()
-    {
-        $session = $this->getMock('Horde_Kolab_Session');
-        $session->expects($this->once())
-            ->method('getUid')
-            ->will($this->returnValue('1'));
-        $logged = new Horde_Kolab_Session_Decorator_Logged($session, $this->logger);
-        $logged->getUid();
-    }
-
-    public function testMethodGetnameGetsDelegated()
-    {
-        $session = $this->getMock('Horde_Kolab_Session');
-        $session->expects($this->once())
-            ->method('getName')
-            ->will($this->returnValue('1'));
-        $logged = new Horde_Kolab_Session_Decorator_Logged($session, $this->logger);
-        $logged->getName();
-    }
-
-    public function testMethodGetimapserverGetsDelegated()
-    {
-        $session = $this->getMock('Horde_Kolab_Session');
-        $session->expects($this->once())
-            ->method('getImapServer')
-            ->will($this->returnValue('1'));
-        $logged = new Horde_Kolab_Session_Decorator_Logged($session, $this->logger);
-        $logged->getImapServer();
-    }
-
-    public function testMethodGetfreebusyserverGetsDelegated()
-    {
-        $session = $this->getMock('Horde_Kolab_Session');
-        $session->expects($this->once())
-            ->method('getFreebusyServer')
-            ->will($this->returnValue('1'));
-        $logged = new Horde_Kolab_Session_Decorator_Logged($session, $this->logger);
-        $logged->getFreebusyServer();
-    }
-
-    public function testMethodGetstorageGetsDelegated()
-    {
-        $session = $this->getMock('Horde_Kolab_Session');
-        $session->expects($this->once())
-            ->method('getStorage')
-            ->will($this->returnValue('1'));
-        $logged = new Horde_Kolab_Session_Decorator_Logged($session, $this->logger);
-        $logged->getStorage();
-    }
-
-
 }
\ No newline at end of file
index 59fec16..50cd9e1 100644 (file)
@@ -59,86 +59,4 @@ extends Horde_Kolab_Session_SessionTestCase
         $stored = new Horde_Kolab_Session_Decorator_Stored($session, $this->storage);
         $stored->connect(array('password' => 'pass'));
     }
-
-    public function testMethodGetidGetsDelegated()
-    {
-        $session = $this->getMock('Horde_Kolab_Session');
-        $session->expects($this->once())
-            ->method('getId')
-            ->will($this->returnValue('1'));
-        $stored = new Horde_Kolab_Session_Decorator_Stored($session, $this->storage);
-        $stored->getId();
-    }
-
-    public function testMethodSetidGetsDelegated()
-    {
-        $session = $this->getMock('Horde_Kolab_Session');
-        $session->expects($this->once())
-            ->method('setId')
-            ->with('1');
-        $stored = new Horde_Kolab_Session_Decorator_Stored($session, $this->storage);
-        $stored->setId('1');
-    }
-
-    public function testMethodGetmailGetsDelegated()
-    {
-        $session = $this->getMock('Horde_Kolab_Session');
-        $session->expects($this->once())
-            ->method('getMail')
-            ->will($this->returnValue('1'));
-        $stored = new Horde_Kolab_Session_Decorator_Stored($session, $this->storage);
-        $stored->getMail();
-    }
-
-    public function testMethodGetuidGetsDelegated()
-    {
-        $session = $this->getMock('Horde_Kolab_Session');
-        $session->expects($this->once())
-            ->method('getUid')
-            ->will($this->returnValue('1'));
-        $stored = new Horde_Kolab_Session_Decorator_Stored($session, $this->storage);
-        $stored->getUid();
-    }
-
-    public function testMethodGetnameGetsDelegated()
-    {
-        $session = $this->getMock('Horde_Kolab_Session');
-        $session->expects($this->once())
-            ->method('getName')
-            ->will($this->returnValue('1'));
-        $stored = new Horde_Kolab_Session_Decorator_Stored($session, $this->storage);
-        $stored->getName();
-    }
-
-    public function testMethodGetimapserverGetsDelegated()
-    {
-        $session = $this->getMock('Horde_Kolab_Session');
-        $session->expects($this->once())
-            ->method('getImapServer')
-            ->will($this->returnValue('1'));
-        $stored = new Horde_Kolab_Session_Decorator_Stored($session, $this->storage);
-        $stored->getImapServer();
-    }
-
-    public function testMethodGetfreebusyserverGetsDelegated()
-    {
-        $session = $this->getMock('Horde_Kolab_Session');
-        $session->expects($this->once())
-            ->method('getFreebusyServer')
-            ->will($this->returnValue('1'));
-        $stored = new Horde_Kolab_Session_Decorator_Stored($session, $this->storage);
-        $stored->getFreebusyServer();
-    }
-
-    public function testMethodGetstorageGetsDelegated()
-    {
-        $session = $this->getMock('Horde_Kolab_Session');
-        $session->expects($this->once())
-            ->method('getStorage')
-            ->will($this->returnValue('1'));
-        $stored = new Horde_Kolab_Session_Decorator_Stored($session, $this->storage);
-        $stored->getStorage();
-    }
-
-
 }
\ No newline at end of file
diff --git a/framework/Kolab_Session/test/Horde/Kolab/Session/Integration/SessionTest.php b/framework/Kolab_Session/test/Horde/Kolab/Session/Integration/SessionTest.php
deleted file mode 100644 (file)
index 66ec59e..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-<?php
-/**
- * Test the Kolab session handler.
- *
- * PHP version 5
- *
- * @category Kolab
- * @package  Kolab_Session
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Session
- */
-
-/**
- * Prepare the test setup.
- */
-require_once dirname(__FILE__) . '/../Autoload.php';
-
-/**
- * Test the Kolab session handler.
- *
- * Copyright 2008-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_Session
- * @author   Gunnar Wrobel <wrobel@pardus.de>
- * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link     http://pear.horde.org/index.php?package=Kolab_Session
- */
-class Horde_Kolab_Session_Integration_SessionTest
-extends Horde_Kolab_Session_SessionTestCase
-{
-    /**
-     * Test class construction.
-     *
-     * @return NULL
-     */
-    public function testConstructEmpty()
-    {
-        global $conf;
-        $conf['kolab']['imap']['allow_special_users'] = true;
-
-        $session = Horde_Kolab_Session::singleton();
-
-        $this->assertEquals('anonymous', $session->user_mail);
-
-        $params = $session->getImapParams();
-        $this->assertNoError($params);
-        $this->assertEquals('localhost', $params['hostspec']);
-        $this->assertEquals(143, $params['port']);
-    }
-
-    /**
-     * Test old style class construction.
-     *
-     * @return NULL
-     */
-    public function testConstructSimple()
-    {
-        global $conf;
-        $conf['kolab']['imap']['server']     = 'example.com';
-        $conf['kolab']['imap']['port']       = 200;
-        $conf['kolab']['freebusy']['server'] = 'fb.example.com';
-
-        $session = new Horde_Kolab_Session();
-        $params  = $session->getImapParams();
-        $this->assertEquals('example.com', $params['hostspec']);
-        $this->assertEquals(200, $params['port']);
-    }
-
-    /**
-     * Test IMAP server retrieval.
-     *
-     * @return NULL
-     */
-    public function testGetSession()
-    {
-        $this->markTestSkipped();
-        $server = &$this->prepareEmptyKolabServer();
-        $result = $server->add($this->provideBasicUserTwo());
-        $this->assertNoError($result);
-        $this->assertEquals(1, count($GLOBALS['KOLAB_SERVER_TEST_DATA']));
-
-        $session = Horde_Kolab_Session::singleton(
-            'test',
-            array('password' => 'test')
-        );
-
-        $this->assertNoError($session->auth);
-        $this->assertEquals('test@example.org', $session->user_mail);
-
-        $params = $session->getImapParams();
-        $this->assertNoError($params);
-        $this->assertEquals('home.example.org', $params['hostspec']);
-        $this->assertEquals(143, $params['port']);
-        $this->assertEquals('test@example.org', $session->user_mail);
-
-        $session->shutdown();
-
-        $hs = Horde_SessionObjects::singleton();
-
-        $recovered_session = &$hs->query('kolab_session');
-        $params            = $recovered_session->getImapParams();
-        $this->assertNoError($params);
-        $this->assertEquals('home.example.org', $params['hostspec']);
-        $this->assertEquals(143, $params['port']);
-        $this->assertEquals('test@example.org', $session->user_mail);
-
-        $this->assertEquals(
-            'https://fb.example.org/freebusy', $session->freebusy_server
-        );
-    }
-
-    /**
-     * Test retrieving the FreeBusy server for the unauthenticated state.
-     *
-     * @return NULL
-     */
-    public function testGetFreeBusySession()
-    {
-        $this->markTestSkipped();
-        $server = $this->prepareEmptyKolabServer();
-        $result = $server->add($this->provideBasicUserTwo());
-        $this->assertNoError($result);
-        $session = Horde_Kolab_Session::singleton();
-        $this->assertEquals('', $session->freebusy_server);
-    }
-
-
-}