From: Gunnar Wrobel
Date: Thu, 5 Nov 2009 22:35:50 +0000 (+0100)
Subject: Rename interfaces and decorators.
X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=8c970f8b665cdecab5ee1664e82141e9cf1bbd21;p=horde.git
Rename interfaces and decorators.
---
diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session.php b/framework/Kolab_Session/lib/Horde/Kolab/Session.php
deleted file mode 100644
index f36a04ade..000000000
--- a/framework/Kolab_Session/lib/Horde/Kolab/Session.php
+++ /dev/null
@@ -1,109 +0,0 @@
-
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Session
- */
-
-/**
- * The interface describing Horde_Kolab_Session handlers.
- *
- * Horde_Kolab_Server currently has no caching so we mainly cache some core user
- * information in the Kolab session handler as reading this data is expensive
- * and it is sufficient to read it once per session.
- *
- * The core user credentials (login, pass) are kept within the Auth module and
- * can be retrieved using Auth::getAuth() respectively
- * Auth::getCredential('password'). Any additional Kolab user data
- * relevant for the user session should be accessed via the Horde_Kolab_Session
- * class.
- *
- * Copyright 2008-2009 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
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Session
- */
-interface Horde_Kolab_Session
-{
- /**
- * Try to connect the session handler.
- *
- * @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(array $credentials = null);
-
- /**
- * Return the user id used for connecting the session.
- *
- * @return string The user id.
- */
- 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.
- */
- public function getMail();
-
- /**
- * Return the users uid.
- *
- * @return string The users uid.
- */
- public function getUid();
-
- /**
- * Return the users name.
- *
- * @return string The users name.
- */
- public function getName();
-
- /**
- * Return the imap server.
- *
- * @return string The imap host for the current user.
- */
- public function getImapServer();
-
- /**
- * Return the freebusy server.
- *
- * @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();
-}
diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Anonymous.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Anonymous.php
deleted file mode 100644
index 9c046a6b2..000000000
--- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Anonymous.php
+++ /dev/null
@@ -1,182 +0,0 @@
-
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Session
- */
-
-/**
- * The Horde_Kolab_Session_Anonymous class allows anonymous access to the Kolab
- * system.
- *
- * The core user credentials (login, pass) are kept within the Auth module and
- * can be retrieved using Auth::getAuth() respectively
- * Auth::getCredential('password'). Any additional Kolab user data
- * relevant for the user session should be accessed via the Horde_Kolab_Session
- * class.
- *
- * Copyright 2009 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
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Session
- */
-class Horde_Kolab_Session_Anonymous implements Horde_Kolab_Session
-{
- /**
- * The session handler this instance provides with anonymous access.
- *
- * @var Horde_Kolab_Session
- */
- private $_session;
-
- /**
- * Anonymous user ID.
- *
- * @var string
- */
- private $_anonymous_id;
-
- /**
- * Anonymous password.
- *
- * @var string
- */
- private $_anonymous_pass;
-
- /**
- * Constructor.
- *
- * @param Horde_Kolab_Session $session The this instance should provide
- * anonymous access for.
- * @param string $user ID of the anonymous user.
- * @param string $pass Password of the anonymous user.
- */
- public function __construct(Horde_Kolab_Session $session, $user, $pass)
- {
- $this->_session = $session;
- $this->_anonymous_id = $user;
- $this->_anonymous_pass = $pass;
- }
-
- /**
- * Try to connect the session handler.
- *
- * @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(array $credentials = null)
- {
- $id = $this->_session->getId();
- if (empty($id) && $credentials === null) {
- $this->_session->setId($this->_anonymous_id);
- $this->_session->connect(array('password' => $this->_anonymous_pass));
- } else {
- $this->_session->connect($credentials);
- }
- }
-
- /**
- * Return the user id used for connecting the session.
- *
- * @return string The user id.
- */
- public function getId()
- {
- $id = $this->_session->getId();
- if ($id == $this->_anonymous_id) {
- return null;
- }
- 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/Auth.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Auth.php
deleted file mode 100644
index 1f0ab1fff..000000000
--- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Auth.php
+++ /dev/null
@@ -1,36 +0,0 @@
-
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Session
- */
-
-/**
- * Defines an authentication wrapper for the Kolab session information.
- *
- * Copyright 2009 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
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Session
- */
-interface Horde_Kolab_Session_Auth
-{
- /**
- * Get the current user ID.
- *
- * @return string The ID of the current user.
- */
- public function getCurrentUser();
-}
diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Auth/Horde.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Auth/Horde.php
index 31d0901ae..8401d7445 100644
--- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Auth/Horde.php
+++ b/framework/Kolab_Session/lib/Horde/Kolab/Session/Auth/Horde.php
@@ -25,7 +25,8 @@
* @license http://www.fsf.org/copyleft/lgpl.html LGPL
* @link http://pear.horde.org/index.php?package=Kolab_Session
*/
-class Horde_Kolab_Session_Auth_Horde implements Horde_Kolab_Session_Auth
+class Horde_Kolab_Session_Auth_Horde
+implements Horde_Kolab_Session_Auth_Interface
{
/**
* Get the current user ID.
diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Auth/Interface.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Auth/Interface.php
new file mode 100644
index 000000000..46a64bda3
--- /dev/null
+++ b/framework/Kolab_Session/lib/Horde/Kolab/Session/Auth/Interface.php
@@ -0,0 +1,36 @@
+
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Session
+ */
+
+/**
+ * Defines an authentication wrapper for the Kolab session information.
+ *
+ * Copyright 2009 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
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Session
+ */
+interface Horde_Kolab_Session_Auth_Interface
+{
+ /**
+ * Get the current user ID.
+ *
+ * @return string The ID of the current user.
+ */
+ public function getCurrentUser();
+}
diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Auth/Mock.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Auth/Mock.php
index bf0893652..bc39dc43f 100644
--- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Auth/Mock.php
+++ b/framework/Kolab_Session/lib/Horde/Kolab/Session/Auth/Mock.php
@@ -25,7 +25,8 @@
* @license http://www.fsf.org/copyleft/lgpl.html LGPL
* @link http://pear.horde.org/index.php?package=Kolab_Session
*/
-class Horde_Kolab_Session_Auth_Mock implements Horde_Kolab_Session_Auth
+class Horde_Kolab_Session_Auth_Mock
+implements Horde_Kolab_Session_Auth_Interface
{
/**
* The user this instance will report.
diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Base.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Base.php
index f9b82303d..1aeb63e56 100644
--- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Base.php
+++ b/framework/Kolab_Session/lib/Horde/Kolab/Session/Base.php
@@ -31,7 +31,7 @@
* @license http://www.fsf.org/copyleft/lgpl.html LGPL
* @link http://pear.horde.org/index.php?package=Kolab_Session
*/
-class Horde_Kolab_Session_Base implements Horde_Kolab_Session
+class Horde_Kolab_Session_Base implements Horde_Kolab_Session_Interface
{
/**
* Kolab configuration parameters.
diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Decorator/Anonymous.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Decorator/Anonymous.php
new file mode 100644
index 000000000..75ba38a43
--- /dev/null
+++ b/framework/Kolab_Session/lib/Horde/Kolab/Session/Decorator/Anonymous.php
@@ -0,0 +1,186 @@
+
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Session
+ */
+
+/**
+ * The Horde_Kolab_Session_Anonymous class allows anonymous access to the Kolab
+ * system.
+ *
+ * The core user credentials (login, pass) are kept within the Auth module and
+ * can be retrieved using Auth::getAuth() respectively
+ * Auth::getCredential('password'). Any additional Kolab user data
+ * relevant for the user session should be accessed via the Horde_Kolab_Session
+ * class.
+ *
+ * Copyright 2009 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
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Session
+ */
+class Horde_Kolab_Session_Decorator_Anonymous
+implements Horde_Kolab_Session_Interface
+{
+ /**
+ * The session handler this instance provides with anonymous access.
+ *
+ * @var Horde_Kolab_Session_Interface
+ */
+ private $_session;
+
+ /**
+ * Anonymous user ID.
+ *
+ * @var string
+ */
+ private $_anonymous_id;
+
+ /**
+ * Anonymous password.
+ *
+ * @var string
+ */
+ private $_anonymous_pass;
+
+ /**
+ * Constructor.
+ *
+ * @param Horde_Kolab_Session_Interface $session The this instance should provide
+ * anonymous access for.
+ * @param string $user ID of the anonymous user.
+ * @param string $pass Password of the anonymous user.
+ */
+ public function __construct(
+ Horde_Kolab_Session_Interface $session,
+ $user,
+ $pass
+ ) {
+ $this->_session = $session;
+ $this->_anonymous_id = $user;
+ $this->_anonymous_pass = $pass;
+ }
+
+ /**
+ * Try to connect the session handler.
+ *
+ * @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(array $credentials = null)
+ {
+ $id = $this->_session->getId();
+ if (empty($id) && $credentials === null) {
+ $this->_session->setId($this->_anonymous_id);
+ $this->_session->connect(array('password' => $this->_anonymous_pass));
+ } else {
+ $this->_session->connect($credentials);
+ }
+ }
+
+ /**
+ * Return the user id used for connecting the session.
+ *
+ * @return string The user id.
+ */
+ public function getId()
+ {
+ $id = $this->_session->getId();
+ if ($id == $this->_anonymous_id) {
+ return null;
+ }
+ 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/Logged.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Decorator/Logged.php
new file mode 100644
index 000000000..10310f600
--- /dev/null
+++ b/framework/Kolab_Session/lib/Horde/Kolab/Session/Decorator/Logged.php
@@ -0,0 +1,174 @@
+
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Session
+ */
+
+/**
+ * A logger for Horde_Kolab_Session handlers.
+ *
+ * Copyright 2009 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
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Session
+ */
+class Horde_Kolab_Session_Decorator_Logged
+implements Horde_Kolab_Session_Interface
+{
+ /**
+ * The session handler.
+ *
+ * @var Horde_Kolab_Session_Interface
+ */
+ private $_session;
+
+ /**
+ * The logger.
+ *
+ * @var mixed
+ */
+ private $_logger;
+
+ /**
+ * Constructor.
+ *
+ * The provided logger class needs to implement the methods info() and
+ * err().
+ *
+ * @param Horde_Kolab_Session_Interface $session The session handler.
+ * @param mixed $logger The logger instance.
+ */
+ public function __construct(
+ Horde_Kolab_Session_Interface $session,
+ $logger
+ ) {
+ $this->_session = $session;
+ $this->_logger = $logger;
+ }
+
+ /**
+ * Try to connect the session handler.
+ *
+ * @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(array $credentials = null)
+ {
+ try {
+ $this->_session->connect($credentials);
+ $this->_logger->info(
+ sprintf(
+ "Connected Kolab session for \"%s\".",
+ $this->_session->getId()
+ )
+ );
+ } catch (Horde_Kolab_Session_Exception $e) {
+ $this->_logger->err(
+ sprintf(
+ "Failed to connect Kolab session for \"%s\". Error was: %s",
+ $this->_session->getId(), $e->getMessage()
+ )
+ );
+ 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();
+ }
+}
diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Decorator/Stored.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Decorator/Stored.php
new file mode 100644
index 000000000..134a3e20a
--- /dev/null
+++ b/framework/Kolab_Session/lib/Horde/Kolab/Session/Decorator/Stored.php
@@ -0,0 +1,171 @@
+
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Session
+ */
+
+/**
+ * Storage for Horde_Kolab_Session handlers.
+ *
+ * Copyright 2009 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
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Session
+ */
+class Horde_Kolab_Session_Decorator_Stored
+implements Horde_Kolab_Session_Interface
+{
+ /**
+ * The session handler.
+ *
+ * @var Horde_Kolab_Session_Interface
+ */
+ private $_session;
+
+ /**
+ * The storage.
+ *
+ * @var Horde_Kolab_Session_Storage
+ */
+ private $_storage;
+
+ /**
+ * Has the storage been connected successfully?
+ *
+ * @var boolean
+ */
+ private $_connected = false;
+
+ /**
+ * Constructor.
+ *
+ * @param Horde_Kolab_Session_Interface $session The session handler.
+ * @param Horde_Kolab_Session_Storage $storage Store the session here.
+ */
+ public function __construct(
+ Horde_Kolab_Session_Interface $session,
+ Horde_Kolab_Session_Storage_Interface $storage
+ ) {
+ $this->_session = $session;
+ $this->_storage = $storage;
+ }
+
+ /**
+ * Destructor.
+ *
+ * Save the session in the storage on shutdown.
+ */
+ public function __destruct()
+ {
+ $this->_storage->save($this->_session);
+ }
+
+ /**
+ * Try to connect the session handler.
+ *
+ * @param array $credentials An array of login credentials. For Kolab,
+ * this must contain a "password" entry.
+ *
+ * @return NULL
+ */
+ public function connect(array $credentials = null)
+ {
+ $this->_session->connect($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/Factory.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory.php
deleted file mode 100644
index 9fdba64f3..000000000
--- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory.php
+++ /dev/null
@@ -1,104 +0,0 @@
-
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Session
- */
-
-/**
- * Interface for Horde_Kolab_Session factories.
- *
- * Copyright 2009 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
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Session
- */
-interface Horde_Kolab_Session_Factory
-{
- /**
- * Return the kolab user db connection.
- *
- * @return Horde_Kolab_Server The server connection.
- */
- public function getServer();
-
- /**
- * Return the auth handler for sessions.
- *
- * @return Horde_Kolab_Session_Auth The authentication handler.
- */
- public function getSessionAuth();
-
- /**
- * Return the configuration parameters for the session.
- *
- * @return array The configuration values.
- */
- public function getSessionConfiguration();
-
- /**
- * Return the session storage driver.
- *
- * @return Horde_Kolab_Session_Storage The driver for storing sessions.
- */
- public function getSessionStorage();
-
- /**
- * Return the session validation driver.
- *
- * @param Horde_Kolab_Session $session The session to validate.
- * @param Horde_Kolab_Session_Auth $auth The auth handler.
- *
- * @return Horde_Kolab_Session_Valid The driver for validating sessions.
- */
- public function getSessionValidator(
- Horde_Kolab_Session $session,
- Horde_Kolab_Session_Auth $auth
- );
-
- /**
- * Validate the given session.
- *
- * Validate the given session.
- *
- * @param Horde_Kolab_Session $session The session to validate.
- * @param string $user The session will be validated for
- * this user ID.
- *
- * @return boolean True if the given session is valid.
- */
- public function validate(Horde_Kolab_Session $session, $user = null);
-
- /**
- * Returns a new session handler.
- *
- * @param string $user The session will be setup for the user with this ID.
- *
- * @return Horde_Kolab_Session The concrete Kolab session reference.
- */
- public function createSession($user = null);
-
- /**
- * Returns either a reference to a session handler with data retrieved from
- * the session or a new session handler.
- *
- * @param string $user The session will be setup for the user with
- * this ID.
- * @param array $credentials An array of login credentials.
- *
- * @return Horde_Kolab_Session The concrete Kolab session reference.
- */
- public function getSession($user = null, array $credentials = null);
-}
diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Anonymous.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Anonymous.php
deleted file mode 100644
index 85f5081ca..000000000
--- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Anonymous.php
+++ /dev/null
@@ -1,171 +0,0 @@
-
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Session
- */
-
-/**
- * A factory decorator that adds an anonymous user to the generated instances.
- *
- * Copyright 2009 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
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Session
- */
-class Horde_Kolab_Session_Factory_Anonymous
-implements Horde_Kolab_Session_Factory
-{
- /**
- * The factory setup resulting from the configuration.
- *
- * @var Horde_Kolab_Session_Factory
- */
- private $_factory;
-
- /**
- * Anonymous user ID.
- *
- * @var string
- */
- private $_anonymous_id;
-
- /**
- * Anonymous password.
- *
- * @var string
- */
- private $_anonymous_pass;
-
- /**
- * Constructor.
- *
- * @param Horde_Kolab_Session_Factory $factory The base factory.
- * @param string $user ID of the anonymous user.
- * @param string $pass Password of the anonymous
- * user.
- */
- public function __construct(
- Horde_Kolab_Session_Factory $factory,
- $user,
- $pass
- ) {
- $this->_factory = $factory;
- $this->_anonymous_id = $user;
- $this->_anonymous_pass = $pass;
- }
-
- /**
- * Return the kolab user db connection.
- *
- * @return Horde_Kolab_Server The server connection.
- */
- public function getServer()
- {
- return $this->_factory->getServer();
- }
-
- /**
- * Return the auth handler for sessions.
- *
- * @return Horde_Kolab_Session_Auth The authentication handler.
- */
- public function getSessionAuth()
- {
- return $this->_factory->getSessionAuth();
- }
-
- /**
- * Return the configuration parameters for the session.
- *
- * @return array The configuration values.
- */
- public function getSessionConfiguration()
- {
- return $this->_factory->getSessionConfiguration();
- }
-
- /**
- * Return the session storage driver.
- *
- * @return Horde_Kolab_Session_Storage The driver for storing sessions.
- */
- public function getSessionStorage()
- {
- return $this->_factory->getSessionStorage();
- }
-
- /**
- * Return the session validation driver.
- *
- * @param Horde_Kolab_Session $session The session to validate.
- * @param Horde_Kolab_Session_Auth $auth The auth handler.
- *
- * @return Horde_Kolab_Session_Valid The driver for validating sessions.
- */
- public function getSessionValidator(
- Horde_Kolab_Session $session,
- Horde_Kolab_Session_Auth $auth
- ) {
- return $this->_factory->getSessionValidator($session, $auth);
- }
-
- /**
- * Validate the given session.
- *
- * @param Horde_Kolab_Session $session The session to validate.
- * @param string $user The session will be validated for
- * this user ID.
- *
- * @return boolean True if thxe given session is valid.
- */
- public function validate(Horde_Kolab_Session $session, $user = null)
- {
- return $this->_factory->validate($session, $user);
- }
-
- /**
- * Returns a new session handler.
- *
- * @param string $user The session will be setup for the user with this ID.
- *
- * @return Horde_Kolab_Session The concrete Kolab session reference.
- */
- public function createSession($user = null)
- {
- $session = $this->_factory->createSession($user);
- $session = new Horde_Kolab_Session_Anonymous(
- $session,
- $this->_anonymous_id,
- $this->_anonymous_pass
- );
- return $session;
- }
-
- /**
- * Returns either a reference to a session handler with data retrieved from
- * the session or a new session handler.
- *
- * @param string $user The session will be setup for the user with
- * this ID.
- * @param array $credentials An array of login credentials.
- *
- * @return Horde_Kolab_Session The concrete Kolab session reference.
- */
- public function getSession($user = null, array $credentials = null)
- {
- return $this->_factory->getSession($user, $credentials);
- }
-}
diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Base.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Base.php
index e9951070f..2ddf23075 100644
--- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Base.php
+++ b/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Base.php
@@ -28,19 +28,20 @@
* @link http://pear.horde.org/index.php?package=Kolab_Session
*/
abstract class Horde_Kolab_Session_Factory_Base
-implements Horde_Kolab_Session_Factory
+implements Horde_Kolab_Session_Factory_Interface
{
/**
* Return the session validation driver.
*
- * @param Horde_Kolab_Session $session The session to validate.
- * @param Horde_Kolab_Session_Auth $auth The auth handler.
+ * @param Horde_Kolab_Session_Interface $session The session to validate.
+ * @param Horde_Kolab_Session_Auth_Interface $auth The auth handler.
*
- * @return Horde_Kolab_Session_Valid The driver for validating sessions.
+ * @return Horde_Kolab_Session_Valid_Interface The driver for validating
+ * sessions.
*/
public function getSessionValidator(
- Horde_Kolab_Session $session,
- Horde_Kolab_Session_Auth $auth
+ Horde_Kolab_Session_Interface $session,
+ Horde_Kolab_Session_Auth_Interface $auth
) {
$validator = new Horde_Kolab_Session_Valid_Base(
$session, $auth
@@ -57,8 +58,10 @@ implements Horde_Kolab_Session_Factory
*
* @return boolean True if the given session is valid.
*/
- public function validate(Horde_Kolab_Session $session, $user = null)
- {
+ public function validate(
+ Horde_Kolab_Session_Interface $session,
+ $user = null
+ ) {
return $this->getSessionValidator(
$session,
$this->getSessionAuth()
@@ -80,7 +83,7 @@ implements Horde_Kolab_Session_Factory
$this->getSessionConfiguration()
);
/** If we created a new session handler it needs to be stored once */
- $session = new Horde_Kolab_Session_Stored(
+ $session = new Horde_Kolab_Session_Decorator_Stored(
$session,
$this->getSessionStorage()
);
diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Configuration.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Configuration.php
index 8fa9930ab..0869ee34a 100644
--- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Configuration.php
+++ b/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Configuration.php
@@ -26,7 +26,7 @@
* @link http://pear.horde.org/index.php?package=Kolab_Session
*/
class Horde_Kolab_Session_Factory_Configuration
-implements Horde_Kolab_Session_Factory
+implements Horde_Kolab_Session_Factory_Interface
{
/**
* Configuration parameters for the session.
@@ -70,7 +70,7 @@ implements Horde_Kolab_Session_Factory
);
if (isset($config['logger'])) {
- $factory = new Horde_Kolab_Session_Factory_Logged(
+ $factory = new Horde_Kolab_Session_Factory_Decorator_Logged(
$factory, $config['logger']
);
}
@@ -78,7 +78,7 @@ implements Horde_Kolab_Session_Factory
if (isset($config['session']['anonymous']['user'])
&& isset($config['session']['anonymous']['pass'])
) {
- $factory = new Horde_Kolab_Session_Factory_Anonymous(
+ $factory = new Horde_Kolab_Session_Factory_Decorator_Anonymous(
$factory,
$config['session']['anonymous']['user'],
$config['session']['anonymous']['pass']
@@ -137,8 +137,8 @@ implements Horde_Kolab_Session_Factory
* @return Horde_Kolab_Session_Valid The driver for validating sessions.
*/
public function getSessionValidator(
- Horde_Kolab_Session $session,
- Horde_Kolab_Session_Auth $auth
+ Horde_Kolab_Session_Interface $session,
+ Horde_Kolab_Session_Auth_Interface $auth
) {
return $this->_factory->getSessionValidator($session, $auth);
}
@@ -152,7 +152,7 @@ implements Horde_Kolab_Session_Factory
*
* @return boolean True if the given session is valid.
*/
- public function validate(Horde_Kolab_Session $session, $user = null)
+ public function validate(Horde_Kolab_Session_Interface $session, $user = null)
{
return $this->_factory->validate($session, $user);
}
diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Constructor.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Constructor.php
index df50a24b5..22fd5aac2 100644
--- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Constructor.php
+++ b/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Constructor.php
@@ -31,14 +31,14 @@ extends Horde_Kolab_Session_Factory_Base
/**
* The connection to the Kolab user db.
*
- * @var Horde_Kolab_Server_Composite
+ * @var Horde_Kolab_Server_Composite_Interface
*/
private $_server;
/**
* The auth handler for the session.
*
- * @var Horde_Kolab_Session_Auth
+ * @var Horde_Kolab_Session_Auth_Interface
*/
private $_auth;
@@ -52,27 +52,28 @@ extends Horde_Kolab_Session_Factory_Base
/**
* The storage handler for the session.
*
- * @var Horde_Kolab_Session_Storage
+ * @var Horde_Kolab_Session_Storage_Interface
*/
private $_storage;
/**
* Constructor.
*
- * @param Horde_Kolab_Server_Composite $server The connection to the Kolab
- * user db.
- * @param Horde_Kolab_Session_Auth $auth The auth handler for the
- * session.
- * @param array $config Configuration parameters for
- * the session.
- * @param Horde_Kolab_Session_Storage $storage The storage handler for the
- * session.
+ * @param Horde_Kolab_Server_Composite_Interface $server The connection to the
+ * Kolab user db.
+ * @param Horde_Kolab_Session_Auth_Interface $auth The auth handler for
+ * the session.
+ * @param array $config Configuration
+ * parameters for the
+ * session.
+ * @param Horde_Kolab_Session_Storage_Interface $storage The storage handler
+ * for the session.
*/
public function __construct(
Horde_Kolab_Server_Composite_Interface $server,
- Horde_Kolab_Session_Auth $auth,
+ Horde_Kolab_Session_Auth_Interface $auth,
array $config,
- Horde_Kolab_Session_Storage $storage
+ Horde_Kolab_Session_Storage_Interface $storage
) {
$this->_server = $server;
$this->_auth = $auth;
@@ -93,7 +94,7 @@ extends Horde_Kolab_Session_Factory_Base
/**
* Return the auth handler for sessions.
*
- * @return Horde_Kolab_Session_Auth The authentication handler.
+ * @return Horde_Kolab_Session_Auth_Interface The authentication handler.
*/
public function getSessionAuth()
{
@@ -113,7 +114,7 @@ extends Horde_Kolab_Session_Factory_Base
/**
* Return the session storage driver.
*
- * @return Horde_Kolab_Session_Storage The driver for storing sessions.
+ * @return Horde_Kolab_Session_Storage_Interface The driver for storing sessions.
*/
public function getSessionStorage()
{
diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Decorator/Anonymous.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Decorator/Anonymous.php
new file mode 100644
index 000000000..6dabf789e
--- /dev/null
+++ b/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Decorator/Anonymous.php
@@ -0,0 +1,175 @@
+
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Session
+ */
+
+/**
+ * A factory decorator that adds an anonymous user to the generated instances.
+ *
+ * Copyright 2009 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
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Session
+ */
+class Horde_Kolab_Session_Factory_Decorator_Anonymous
+implements Horde_Kolab_Session_Factory_Interface
+{
+ /**
+ * The factory setup resulting from the configuration.
+ *
+ * @var Horde_Kolab_Session_Factory_Interface
+ */
+ private $_factory;
+
+ /**
+ * Anonymous user ID.
+ *
+ * @var string
+ */
+ private $_anonymous_id;
+
+ /**
+ * Anonymous password.
+ *
+ * @var string
+ */
+ private $_anonymous_pass;
+
+ /**
+ * Constructor.
+ *
+ * @param Horde_Kolab_Session_Factory_Interface $factory The base factory.
+ * @param string $user ID of the anonymous
+ * user.
+ * @param string $pass Password of the
+ * anonymous user.
+ */
+ public function __construct(
+ Horde_Kolab_Session_Factory_Interface $factory,
+ $user,
+ $pass
+ ) {
+ $this->_factory = $factory;
+ $this->_anonymous_id = $user;
+ $this->_anonymous_pass = $pass;
+ }
+
+ /**
+ * Return the kolab user db connection.
+ *
+ * @return Horde_Kolab_Server_Interface The server connection.
+ */
+ public function getServer()
+ {
+ return $this->_factory->getServer();
+ }
+
+ /**
+ * Return the auth handler for sessions.
+ *
+ * @return Horde_Kolab_Session_Auth_Interface The authentication handler.
+ */
+ public function getSessionAuth()
+ {
+ return $this->_factory->getSessionAuth();
+ }
+
+ /**
+ * Return the configuration parameters for the session.
+ *
+ * @return array The configuration values.
+ */
+ public function getSessionConfiguration()
+ {
+ return $this->_factory->getSessionConfiguration();
+ }
+
+ /**
+ * Return the session storage driver.
+ *
+ * @return Horde_Kolab_Session_Storage_Interface The driver for storing sessions.
+ */
+ public function getSessionStorage()
+ {
+ return $this->_factory->getSessionStorage();
+ }
+
+ /**
+ * Return the session validation driver.
+ *
+ * @param Horde_Kolab_Session_Interface $session The session to validate.
+ * @param Horde_Kolab_Session_Auth_Interface $auth The auth handler.
+ *
+ * @return Horde_Kolab_Session_Valid_Interface The driver for validating
+ * sessions.
+ */
+ public function getSessionValidator(
+ Horde_Kolab_Session_Interface $session,
+ Horde_Kolab_Session_Auth_Interface $auth
+ ) {
+ return $this->_factory->getSessionValidator($session, $auth);
+ }
+
+ /**
+ * Validate the given session.
+ *
+ * @param Horde_Kolab_Session_Interface $session The session to validate.
+ * @param string $user The session will be validated
+ * for this user ID.
+ *
+ * @return boolean True if the given session is valid.
+ */
+ public function validate(
+ Horde_Kolab_Session_Interface $session,
+ $user = null
+ ) {
+ return $this->_factory->validate($session, $user);
+ }
+
+ /**
+ * Returns a new session handler.
+ *
+ * @param string $user The session will be setup for the user with this ID.
+ *
+ * @return Horde_Kolab_Session_Interface The concrete Kolab session reference.
+ */
+ public function createSession($user = null)
+ {
+ $session = $this->_factory->createSession($user);
+ $session = new Horde_Kolab_Session_Decorator_Anonymous(
+ $session,
+ $this->_anonymous_id,
+ $this->_anonymous_pass
+ );
+ return $session;
+ }
+
+ /**
+ * Returns either a reference to a session handler with data retrieved from
+ * the session or a new session handler.
+ *
+ * @param string $user The session will be setup for the user with
+ * this ID.
+ * @param array $credentials An array of login credentials.
+ *
+ * @return Horde_Kolab_Session_Interface The concrete Kolab session reference.
+ */
+ public function getSession($user = null, array $credentials = null)
+ {
+ return $this->_factory->getSession($user, $credentials);
+ }
+}
diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Decorator/Logged.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Decorator/Logged.php
new file mode 100644
index 000000000..5296712d7
--- /dev/null
+++ b/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Decorator/Logged.php
@@ -0,0 +1,165 @@
+
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Session
+ */
+
+/**
+ * A factory decorator that adds logging to the generated instances.
+ *
+ * Copyright 2009 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
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Session
+ */
+class Horde_Kolab_Session_Factory_Decorator_Logged
+implements Horde_Kolab_Session_Factory_Interface
+{
+ /**
+ * The factory setup resulting from the configuration.
+ *
+ * @var Horde_Kolab_Session_Factory_Interface
+ */
+ private $_factory;
+
+ /**
+ * The logger.
+ *
+ * @var mixed
+ */
+ private $_logger;
+
+ /**
+ * Constructor.
+ *
+ * @param Horde_Kolab_Session_Factory_Interface $factory The base factory.
+ * @param mixed $logger The logger isntance.
+ */
+ public function __construct(
+ Horde_Kolab_Session_Factory_Interface $factory,
+ $logger
+ ) {
+ $this->_factory = $factory;
+ $this->_logger = $logger;
+ }
+
+ /**
+ * Return the kolab user db connection.
+ *
+ * @return Horde_Kolab_Server_Interface The server connection.
+ */
+ public function getServer()
+ {
+ return $this->_factory->getServer();
+ }
+
+ /**
+ * Return the auth handler for sessions.
+ *
+ * @return Horde_Kolab_Session_Auth_Interface The authentication handler.
+ */
+ public function getSessionAuth()
+ {
+ return $this->_factory->getSessionAuth();
+ }
+
+ /**
+ * Return the configuration parameters for the session.
+ *
+ * @return array The configuration values.
+ */
+ public function getSessionConfiguration()
+ {
+ return $this->_factory->getSessionConfiguration();
+ }
+
+ /**
+ * Return the session storage driver.
+ *
+ * @return Horde_Kolab_Session_Storage_Interface The driver for storing sessions.
+ */
+ public function getSessionStorage()
+ {
+ return $this->_factory->getSessionStorage();
+ }
+
+ /**
+ * Return the session validation driver.
+ *
+ * @param Horde_Kolab_Session_Interface $session The session to validate.
+ * @param Horde_Kolab_Session_Auth_Interface $auth The auth handler.
+ *
+ * @return Horde_Kolab_Session_Valid_Interface The driver for validating
+ * sessions.
+ */
+ public function getSessionValidator(
+ Horde_Kolab_Session_Interface $session,
+ Horde_Kolab_Session_Auth_Interface $auth
+ ) {
+ $valid = $this->_factory->getSessionValidator($session, $auth);
+ $valid = new Horde_Kolab_Session_Valid_Decorator_Logged(
+ $valid, $this->_logger
+ );
+ return $valid;
+ }
+
+ /**
+ * Validate the given session.
+ *
+ * @param Horde_Kolab_Session_Interface $session The session to validate.
+ * @param string $user The session will be validated
+ * for this user ID.
+ *
+ * @return boolean True if the given session is valid.
+ */
+ public function validate(
+ Horde_Kolab_Session_Interface $session,
+ $user = null
+ ) {
+ return $this->_factory->validate($session, $user);
+ }
+
+ /**
+ * Returns a new session handler.
+ *
+ * @param string $user The session will be setup for the user with this ID.
+ *
+ * @return Horde_Kolab_Session_Interface The concrete Kolab session reference.
+ */
+ public function createSession($user = null)
+ {
+ $session = $this->_factory->createSession($user);
+ $session = new Horde_Kolab_Session_Decorator_Logged(
+ $session, $this->_logger
+ );
+ return $session;
+ }
+
+ /**
+ * Returns either a reference to a session handler with data retrieved from
+ * the session or a new session handler.
+ *
+ * @param string $user The session will be setup for the user with
+ * this ID.
+ * @param array $credentials An array of login credentials.
+ *
+ * @return Horde_Kolab_Session_Interface The concrete Kolab session reference.
+ */
+ public function getSession($user = null, array $credentials = null)
+ {
+ return $this->_factory->getSession($user, $credentials);
+ }
+}
diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Interface.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Interface.php
new file mode 100644
index 000000000..ecb592a17
--- /dev/null
+++ b/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Interface.php
@@ -0,0 +1,108 @@
+
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Session
+ */
+
+/**
+ * Interface for Horde_Kolab_Session factories.
+ *
+ * Copyright 2009 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
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Session
+ */
+interface Horde_Kolab_Session_Factory_Interface
+{
+ /**
+ * Return the kolab user db connection.
+ *
+ * @return Horde_Kolab_Server_Interface The server connection.
+ */
+ public function getServer();
+
+ /**
+ * Return the auth handler for sessions.
+ *
+ * @return Horde_Kolab_Session_Auth_Interface The authentication handler.
+ */
+ public function getSessionAuth();
+
+ /**
+ * Return the configuration parameters for the session.
+ *
+ * @return array The configuration values.
+ */
+ public function getSessionConfiguration();
+
+ /**
+ * Return the session storage driver.
+ *
+ * @return Horde_Kolab_Session_Storage_Interface The driver for storing sessions.
+ */
+ public function getSessionStorage();
+
+ /**
+ * Return the session validation driver.
+ *
+ * @param Horde_Kolab_Session_Interface $session The session to validate.
+ * @param Horde_Kolab_Session_Auth_Interface $auth The auth handler.
+ *
+ * @return Horde_Kolab_Session_Valid_Interface The driver for validating
+ * sessions.
+ */
+ public function getSessionValidator(
+ Horde_Kolab_Session_Interface $session,
+ Horde_Kolab_Session_Auth_Interface $auth
+ );
+
+ /**
+ * Validate the given session.
+ *
+ * Validate the given session.
+ *
+ * @param Horde_Kolab_Session_Interface $session The session to validate.
+ * @param string $user The session will be validated
+ * for this user ID.
+ *
+ * @return boolean True if the given session is valid.
+ */
+ public function validate(
+ Horde_Kolab_Session_Interface $session,
+ $user = null
+ );
+
+ /**
+ * Returns a new session handler.
+ *
+ * @param string $user The session will be setup for the user with this ID.
+ *
+ * @return Horde_Kolab_Session_Interface The concrete Kolab session reference.
+ */
+ public function createSession($user = null);
+
+ /**
+ * Returns either a reference to a session handler with data retrieved from
+ * the session or a new session handler.
+ *
+ * @param string $user The session will be setup for the user with
+ * this ID.
+ * @param array $credentials An array of login credentials.
+ *
+ * @return Horde_Kolab_Session_Interface The concrete Kolab session reference.
+ */
+ public function getSession($user = null, array $credentials = null);
+}
diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Logged.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Logged.php
deleted file mode 100644
index c398ebf69..000000000
--- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Logged.php
+++ /dev/null
@@ -1,156 +0,0 @@
-
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Session
- */
-
-/**
- * A factory decorator that adds logging to the generated instances.
- *
- * Copyright 2009 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
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Session
- */
-class Horde_Kolab_Session_Factory_Logged
-implements Horde_Kolab_Session_Factory
-{
- /**
- * The factory setup resulting from the configuration.
- *
- * @var Horde_Kolab_Session_Factory
- */
- private $_factory;
-
- /**
- * The logger.
- *
- * @var mixed
- */
- private $_logger;
-
- /**
- * Constructor.
- *
- * @param Horde_Kolab_Session_Factory $factory The base factory.
- * @param mixed $logger The logger isntance.
- */
- public function __construct(Horde_Kolab_Session_Factory $factory, $logger)
- {
- $this->_factory = $factory;
- $this->_logger = $logger;
- }
-
- /**
- * Return the kolab user db connection.
- *
- * @return Horde_Kolab_Server The server connection.
- */
- public function getServer()
- {
- return $this->_factory->getServer();
- }
-
- /**
- * Return the auth handler for sessions.
- *
- * @return Horde_Kolab_Session_Auth The authentication handler.
- */
- public function getSessionAuth()
- {
- return $this->_factory->getSessionAuth();
- }
-
- /**
- * Return the configuration parameters for the session.
- *
- * @return array The configuration values.
- */
- public function getSessionConfiguration()
- {
- return $this->_factory->getSessionConfiguration();
- }
-
- /**
- * Return the session storage driver.
- *
- * @return Horde_Kolab_Session_Storage The driver for storing sessions.
- */
- public function getSessionStorage()
- {
- return $this->_factory->getSessionStorage();
- }
-
- /**
- * Return the session validation driver.
- *
- * @param Horde_Kolab_Session $session The session to validate.
- * @param Horde_Kolab_Session_Auth $auth The auth handler.
- *
- * @return Horde_Kolab_Session_Valid The driver for validating sessions.
- */
- public function getSessionValidator(
- Horde_Kolab_Session $session,
- Horde_Kolab_Session_Auth $auth
- ) {
- $valid = $this->_factory->getSessionValidator($session, $auth);
- $valid = new Horde_Kolab_Session_Valid_Logged($valid, $this->_logger);
- return $valid;
- }
-
- /**
- * Validate the given session.
- *
- * @param Horde_Kolab_Session $session The session to validate.
- * @param string $user The session will be validated for
- * this user ID.
- *
- * @return boolean True if thxe given session is valid.
- */
- public function validate(Horde_Kolab_Session $session, $user = null)
- {
- return $this->_factory->validate($session, $user);
- }
-
- /**
- * Returns a new session handler.
- *
- * @param string $user The session will be setup for the user with this ID.
- *
- * @return Horde_Kolab_Session The concrete Kolab session reference.
- */
- public function createSession($user = null)
- {
- $session = $this->_factory->createSession($user);
- $session = new Horde_Kolab_Session_Logged($session, $this->_logger);
- return $session;
- }
-
- /**
- * Returns either a reference to a session handler with data retrieved from
- * the session or a new session handler.
- *
- * @param string $user The session will be setup for the user with
- * this ID.
- * @param array $credentials An array of login credentials.
- *
- * @return Horde_Kolab_Session The concrete Kolab session reference.
- */
- public function getSession($user = null, array $credentials = null)
- {
- return $this->_factory->getSession($user, $credentials);
- }
-}
diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Interface.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Interface.php
new file mode 100644
index 000000000..2c422591f
--- /dev/null
+++ b/framework/Kolab_Session/lib/Horde/Kolab/Session/Interface.php
@@ -0,0 +1,109 @@
+
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Session
+ */
+
+/**
+ * The interface describing Horde_Kolab_Session handlers.
+ *
+ * Horde_Kolab_Server currently has no caching so we mainly cache some core user
+ * information in the Kolab session handler as reading this data is expensive
+ * and it is sufficient to read it once per session.
+ *
+ * The core user credentials (login, pass) are kept within the Auth module and
+ * can be retrieved using Auth::getAuth() respectively
+ * Auth::getCredential('password'). Any additional Kolab user data
+ * relevant for the user session should be accessed via the Horde_Kolab_Session
+ * class.
+ *
+ * Copyright 2008-2009 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
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Session
+ */
+interface Horde_Kolab_Session_Interface
+{
+ /**
+ * Try to connect the session handler.
+ *
+ * @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(array $credentials = null);
+
+ /**
+ * Return the user id used for connecting the session.
+ *
+ * @return string The user id.
+ */
+ 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.
+ */
+ public function getMail();
+
+ /**
+ * Return the users uid.
+ *
+ * @return string The users uid.
+ */
+ public function getUid();
+
+ /**
+ * Return the users name.
+ *
+ * @return string The users name.
+ */
+ public function getName();
+
+ /**
+ * Return the imap server.
+ *
+ * @return string The imap host for the current user.
+ */
+ public function getImapServer();
+
+ /**
+ * Return the freebusy server.
+ *
+ * @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();
+}
diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Logged.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Logged.php
deleted file mode 100644
index bba8424bd..000000000
--- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Logged.php
+++ /dev/null
@@ -1,171 +0,0 @@
-
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Session
- */
-
-/**
- * A logger for Horde_Kolab_Session handlers.
- *
- * Copyright 2009 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
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Session
- */
-class Horde_Kolab_Session_Logged implements Horde_Kolab_Session
-{
- /**
- * The session handler.
- *
- * @var Horde_Kolab_Session
- */
- private $_session;
-
- /**
- * The logger.
- *
- * @var mixed
- */
- private $_logger;
-
- /**
- * Constructor.
- *
- * The provided logger class needs to implement the methods info() and
- * err().
- *
- * @param Horde_Kolab_Session $session The session handler.
- * @param mixed $logger The logger instance.
- */
- public function __construct(Horde_Kolab_Session $session, $logger)
- {
- $this->_session = $session;
- $this->_logger = $logger;
- }
-
- /**
- * Try to connect the session handler.
- *
- * @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(array $credentials = null)
- {
- try {
- $this->_session->connect($credentials);
- $this->_logger->info(
- sprintf(
- "Connected Kolab session for \"%s\".",
- $this->_session->getId()
- )
- );
- } catch (Horde_Kolab_Session_Exception $e) {
- $this->_logger->err(
- sprintf(
- "Failed to connect Kolab session for \"%s\". Error was: %s",
- $this->_session->getId(), $e->getMessage()
- )
- );
- 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();
- }
-}
diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Storage.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Storage.php
deleted file mode 100644
index 5eab9a754..000000000
--- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Storage.php
+++ /dev/null
@@ -1,46 +0,0 @@
-
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Session
- */
-
-/**
- * Defines storage containers for the Kolab session information.
- *
- * Copyright 2009 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
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Session
- */
-interface Horde_Kolab_Session_Storage
-{
- /**
- * Load the session information.
- *
- * @return Horde_Kolab_Session|boolean The session information or false if
- * it could not be loaded.
- */
- public function load();
-
- /**
- * Lave the session information.
- *
- * @param Horde_Kolab_Session $session The session information.
- *
- * @return NULL
- */
- public function save(Horde_Kolab_Session $session);
-}
diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Storage/Interface.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Storage/Interface.php
new file mode 100644
index 000000000..de9a7ef51
--- /dev/null
+++ b/framework/Kolab_Session/lib/Horde/Kolab/Session/Storage/Interface.php
@@ -0,0 +1,46 @@
+
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Session
+ */
+
+/**
+ * Defines storage containers for the Kolab session information.
+ *
+ * Copyright 2009 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
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Session
+ */
+interface Horde_Kolab_Session_Storage_Interface
+{
+ /**
+ * Load the session information.
+ *
+ * @return Horde_Kolab_Session|boolean The session information or false if
+ * it could not be loaded.
+ */
+ public function load();
+
+ /**
+ * Lave the session information.
+ *
+ * @param Horde_Kolab_Session $session The session information.
+ *
+ * @return NULL
+ */
+ public function save(Horde_Kolab_Session_Interface $session);
+}
diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Storage/Mock.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Storage/Mock.php
index 4d3a4155c..de13c944f 100644
--- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Storage/Mock.php
+++ b/framework/Kolab_Session/lib/Horde/Kolab/Session/Storage/Mock.php
@@ -26,7 +26,7 @@
* @link http://pear.horde.org/index.php?package=Kolab_Session
*/
class Horde_Kolab_Session_Storage_Mock
-implements Horde_Kolab_Session_Storage
+implements Horde_Kolab_Session_Storage_Interface
{
/**
* The session information.
@@ -47,11 +47,11 @@ implements Horde_Kolab_Session_Storage
/**
* Save the session information.
*
- * @param Horde_Kolab_Session $session The session information.
+ * @param Horde_Kolab_Session_Interface $session The session information.
*
* @return NULL
*/
- public function save(Horde_Kolab_Session $session)
+ public function save(Horde_Kolab_Session_Interface $session)
{
$this->session = $session;
}
diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Storage/Sessionobjects.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Storage/Sessionobjects.php
index c7163fe80..8d5128d47 100644
--- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Storage/Sessionobjects.php
+++ b/framework/Kolab_Session/lib/Horde/Kolab/Session/Storage/Sessionobjects.php
@@ -26,7 +26,7 @@
* @link http://pear.horde.org/index.php?package=Kolab_Session
*/
class Horde_Kolab_Session_Storage_Sessionobjects
-implements Horde_Kolab_Session_Storage
+implements Horde_Kolab_Session_Storage_Interface
{
/**
* The handler for session objects.
@@ -59,11 +59,11 @@ implements Horde_Kolab_Session_Storage
/**
* Save the session information.
*
- * @param Horde_Kolab_Session $session The session information.
+ * @param Horde_Kolab_Session_Interface $session The session information.
*
* @return NULL
*/
- public function save(Horde_Kolab_Session $session)
+ public function save(Horde_Kolab_Session_Interface $session)
{
$this->_session_objects->overwrite('kolab_session', $session);
}
diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Stored.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Stored.php
deleted file mode 100644
index c1455908f..000000000
--- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Stored.php
+++ /dev/null
@@ -1,170 +0,0 @@
-
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Session
- */
-
-/**
- * Storage for Horde_Kolab_Session handlers.
- *
- * Copyright 2009 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
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Session
- */
-class Horde_Kolab_Session_Stored implements Horde_Kolab_Session
-{
- /**
- * The session handler.
- *
- * @var Horde_Kolab_Session
- */
- private $_session;
-
- /**
- * The storage.
- *
- * @var Horde_Kolab_Session_Storage
- */
- private $_storage;
-
- /**
- * Has the storage been connected successfully?
- *
- * @var boolean
- */
- private $_connected = false;
-
- /**
- * Constructor.
- *
- * @param Horde_Kolab_Session $session The session handler.
- * @param Horde_Kolab_Session_Storage $storage Store the session here.
- */
- public function __construct(
- Horde_Kolab_Session $session,
- Horde_Kolab_Session_Storage $storage
- ) {
- $this->_session = $session;
- $this->_storage = $storage;
- }
-
- /**
- * Destructor.
- *
- * Save the session in the storage on shutdown.
- */
- public function __destruct()
- {
- $this->_storage->save($this->_session);
- }
-
- /**
- * Try to connect the session handler.
- *
- * @param array $credentials An array of login credentials. For Kolab,
- * this must contain a "password" entry.
- *
- * @return NULL
- */
- public function connect(array $credentials = null)
- {
- $this->_session->connect($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/Valid.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Valid.php
deleted file mode 100644
index a1c2fe8b5..000000000
--- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Valid.php
+++ /dev/null
@@ -1,60 +0,0 @@
-
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Session
- */
-
-/**
- * Interface for session validators.
- *
- * The core user credentials (login, pass) are kept within the Auth module and
- * can be retrieved using Auth::getAuth() respectively
- * Auth::getCredential('password'). Any additional Kolab user data
- * relevant for the user session should be accessed via the Horde_Kolab_Session
- * class.
- *
- * Copyright 2009 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
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Session
- */
-interface Horde_Kolab_Session_Valid
-{
- /**
- * Does the current session still match the authentication information?
- *
- * @param string $user The user the session information is being requested
- * for. This is usually empty, indicating the current
- * user.
- *
- * @return boolean True if the session is still valid.
- */
- public function isValid($user = null);
-
- /**
- * Return the session this validator checks.
- *
- * @return Horde_Kolab_Session The session checked by this validator.
- */
- public function getSession();
-
- /**
- * Return the auth driver of this validator.
- *
- * @return Horde_Kolab_Session_Auth The auth driver set for this validator.
- */
- public function getAuth();
-}
\ No newline at end of file
diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Valid/Base.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Valid/Base.php
index 1e6be37b8..118cb2f01 100644
--- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Valid/Base.php
+++ b/framework/Kolab_Session/lib/Horde/Kolab/Session/Valid/Base.php
@@ -31,32 +31,33 @@
* @license http://www.fsf.org/copyleft/lgpl.html LGPL
* @link http://pear.horde.org/index.php?package=Kolab_Session
*/
-class Horde_Kolab_Session_Valid_Base implements Horde_Kolab_Session_Valid
+class Horde_Kolab_Session_Valid_Base
+implements Horde_Kolab_Session_Valid_Interface
{
/**
* The session handler this instance provides with anonymous access.
*
- * @var Horde_Kolab_Session
+ * @var Horde_Kolab_Session_Interface
*/
private $_session;
/**
* Provides authentication information for this object.
*
- * @var Horde_Kolab_Session_Auth
+ * @var Horde_Kolab_Session_Auth_Interface
*/
private $_auth;
/**
* Constructor.
*
- * @param Horde_Kolab_Session $session The session that should be
- * validated.
- * @param Horde_Kolab_Session_Auth $auth The authentication handler.
+ * @param Horde_Kolab_Session_Interface $session The session that should be
+ * validated.
+ * @param Horde_Kolab_Session_Auth_Interface $auth The authentication handler.
*/
public function __construct(
- Horde_Kolab_Session $session,
- Horde_Kolab_Session_Auth $auth
+ Horde_Kolab_Session_Interface $session,
+ Horde_Kolab_Session_Auth_Interface $auth
) {
$this->_session = $session;
$this->_auth = $auth;
@@ -89,7 +90,8 @@ class Horde_Kolab_Session_Valid_Base implements Horde_Kolab_Session_Valid
/**
* Return the session this validator checks.
*
- * @return Horde_Kolab_Session The session checked by this validator.
+ * @return Horde_Kolab_Session_Interface The session checked by this
+ * validator.
*/
public function getSession()
{
@@ -99,7 +101,8 @@ class Horde_Kolab_Session_Valid_Base implements Horde_Kolab_Session_Valid
/**
* Return the auth driver of this validator.
*
- * @return Horde_Kolab_Session_Auth The auth driver set for this validator.
+ * @return Horde_Kolab_Session_Auth_Interface The auth driver set for this
+ * validator.
*/
public function getAuth()
{
diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Valid/Decorator/Logged.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Valid/Decorator/Logged.php
new file mode 100644
index 000000000..bae5a8008
--- /dev/null
+++ b/framework/Kolab_Session/lib/Horde/Kolab/Session/Valid/Decorator/Logged.php
@@ -0,0 +1,109 @@
+
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Session
+ */
+
+/**
+ * A logger for Horde_Kolab_Session_Valid validators.
+ *
+ * Copyright 2009 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
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Session
+ */
+class Horde_Kolab_Session_Valid_Decorator_Logged
+implements Horde_Kolab_Session_Valid_Interface
+{
+ /**
+ * The valid handler.
+ *
+ * @var Horde_Kolab_Session_Valid_Interface
+ */
+ private $_valid;
+
+ /**
+ * The logger.
+ *
+ * @var mixed
+ */
+ private $_logger;
+
+ /**
+ * Constructor.
+ *
+ * The provided logger class needs to implement the methods info() and
+ * err().
+ *
+ * @param Horde_Kolab_Session_Valid_Interface $valid The validator.
+ * @param mixed $logger The logger instance.
+ */
+ public function __construct(
+ Horde_Kolab_Session_Valid_Interface $valid,
+ $logger
+ ) {
+ $this->_valid = $valid;
+ $this->_logger = $logger;
+ }
+
+ /**
+ * Does the current session still match the authentication information?
+ *
+ * @param string $user The user the session information is being requested
+ * for. This is usually empty, indicating the current
+ * user.
+ *
+ * @return boolean True if the session is still valid.
+ */
+ public function isValid($user = null)
+ {
+ $result = $this->_valid->isValid($user);
+ if ($result === false) {
+ $this->_logger->info(
+ sprintf(
+ "Invalid Kolab session for current user \"%s\", requested"
+ . " user \"%s\" and stored user \"%s\".",
+ $this->_valid->getAuth()->getCurrentUser(),
+ $user,
+ $this->_valid->getSession()->getMail()
+ )
+ );
+ }
+ return $result;
+ }
+
+ /**
+ * Return the session this validator checks.
+ *
+ * @return Horde_Kolab_Session_Interface The session checked by this
+ * validator.
+ */
+ public function getSession()
+ {
+ return $this->_valid->getSession();
+ }
+
+ /**
+ * Return the auth driver of this validator.
+ *
+ * @return Horde_Kolab_Session_Auth_Interface The auth driver set for this
+ * validator.
+ */
+ public function getAuth()
+ {
+ return $this->_valid->getAuth();
+ }
+}
diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Valid/Interface.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Valid/Interface.php
new file mode 100644
index 000000000..bb3991493
--- /dev/null
+++ b/framework/Kolab_Session/lib/Horde/Kolab/Session/Valid/Interface.php
@@ -0,0 +1,62 @@
+
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Session
+ */
+
+/**
+ * Interface for session validators.
+ *
+ * The core user credentials (login, pass) are kept within the Auth module and
+ * can be retrieved using Auth::getAuth() respectively
+ * Auth::getCredential('password'). Any additional Kolab user data
+ * relevant for the user session should be accessed via the Horde_Kolab_Session
+ * class.
+ *
+ * Copyright 2009 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
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Session
+ */
+interface Horde_Kolab_Session_Valid_Interface
+{
+ /**
+ * Does the current session still match the authentication information?
+ *
+ * @param string $user The user the session information is being requested
+ * for. This is usually empty, indicating the current
+ * user.
+ *
+ * @return boolean True if the session is still valid.
+ */
+ public function isValid($user = null);
+
+ /**
+ * Return the session this validator checks.
+ *
+ * @return Horde_Kolab_Session_Interface The session checked by this
+ * validator.
+ */
+ public function getSession();
+
+ /**
+ * Return the auth driver of this validator.
+ *
+ * @return Horde_Kolab_Session_Auth_Interface The auth driver set for this
+ * validator.
+ */
+ public function getAuth();
+}
\ No newline at end of file
diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Valid/Logged.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Valid/Logged.php
deleted file mode 100644
index bb0f70380..000000000
--- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Valid/Logged.php
+++ /dev/null
@@ -1,104 +0,0 @@
-
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Session
- */
-
-/**
- * A logger for Horde_Kolab_Session_Valid validators.
- *
- * Copyright 2009 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
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Session
- */
-class Horde_Kolab_Session_Valid_Logged implements Horde_Kolab_Session_Valid
-{
- /**
- * The valid handler.
- *
- * @var Horde_Kolab_Session_Valid
- */
- private $_valid;
-
- /**
- * The logger.
- *
- * @var mixed
- */
- private $_logger;
-
- /**
- * Constructor.
- *
- * The provided logger class needs to implement the methods info() and
- * err().
- *
- * @param Horde_Kolab_Session_Valid $valid The validator.
- * @param mixed $logger The logger instance.
- */
- public function __construct(Horde_Kolab_Session_Valid $valid, $logger)
- {
- $this->_valid = $valid;
- $this->_logger = $logger;
- }
-
- /**
- * Does the current session still match the authentication information?
- *
- * @param string $user The user the session information is being requested
- * for. This is usually empty, indicating the current
- * user.
- *
- * @return boolean True if the session is still valid.
- */
- public function isValid($user = null)
- {
- $result = $this->_valid->isValid($user);
- if ($result === false) {
- $this->_logger->info(
- sprintf(
- "Invalid Kolab session for current user \"%s\", requested"
- . " user \"%s\" and stored user \"%s\".",
- $this->_valid->getAuth()->getCurrentUser(),
- $user,
- $this->_valid->getSession()->getMail()
- )
- );
- }
- return $result;
- }
-
- /**
- * Return the session this validator checks.
- *
- * @return Horde_Kolab_Session The session checked by this validator.
- */
- public function getSession()
- {
- return $this->_valid->getSession();
- }
-
- /**
- * Return the auth driver of this validator.
- *
- * @return Horde_Kolab_Session_Auth The auth driver set for this validator.
- */
- public function getAuth()
- {
- return $this->_valid->getAuth();
- }
-}
diff --git a/framework/Kolab_Session/package.xml b/framework/Kolab_Session/package.xml
index 5918bfa54..000b6933d 100644
--- a/framework/Kolab_Session/package.xml
+++ b/framework/Kolab_Session/package.xml
@@ -45,41 +45,47 @@ http://pear.php.net/dtd/package-2.0.xsd">
-
-
-
+
+
+
+
+
+
-
-
+
+
+
+
-
+
-
+
-
+
-
-
-
+
+
+
+
@@ -92,30 +98,36 @@ http://pear.php.net/dtd/package-2.0.xsd">
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
@@ -170,50 +182,50 @@ http://pear.php.net/dtd/package-2.0.xsd">
-
-
-
+
-
-
+
+
+
+
+
-
-
+
+
-
+
-
-
-
+
+
-
-
+
+
+
+
+
-
-
-
-
+
diff --git a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/AnonymousTest.php b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/AnonymousTest.php
deleted file mode 100644
index 05b0f2b24..000000000
--- a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/AnonymousTest.php
+++ /dev/null
@@ -1,174 +0,0 @@
-
- * @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 anonymous decorator.
- *
- * Copyright 2009 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
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Session
- */
-class Horde_Kolab_Session_Class_AnonymousTest extends Horde_Kolab_Session_SessionTestCase
-{
- public function testMethodConnectHasPostconditionThatTheConnectionHasBeenEstablishedAsAnonymousUserIfRequired()
- {
- $session = $this->getMock('Horde_Kolab_Session');
- $session->expects($this->once())
- ->method('getId')
- ->will($this->returnValue(null));
- $session->expects($this->once())
- ->method('setId')
- ->with('anonymous');
- $session->expects($this->once())
- ->method('connect')
- ->with(array('password' => 'pass'));
- $anonymous = new Horde_Kolab_Session_Anonymous(
- $session, 'anonymous', 'pass'
- );
- $anonymous->connect();
- }
-
- public function testMethodGetidReturnsNullIfConnectedUserIsAnonymousUser()
- {
- $session = $this->getMock('Horde_Kolab_Session');
- $session->expects($this->once())
- ->method('getId')
- ->will($this->returnValue('anonymous'));
- $anonymous = new Horde_Kolab_Session_Anonymous(
- $session, 'anonymous', 'pass'
- );
- $this->assertNull($anonymous->getId());
- }
-
- public function testMethodConnectGetsDelegated()
- {
- $session = $this->getMock('Horde_Kolab_Session');
- $session->expects($this->once())
- ->method('connect')
- ->with(array('password' => 'pass'));
- $anonymous = new Horde_Kolab_Session_Anonymous(
- $session, 'anonymous', 'pass'
- );
- $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_Anonymous(
- $session, 'anonymous', 'pass'
- );
- $anonymous->getId();
- }
-
- public function testMethodSetidGetsDelegated()
- {
- $session = $this->getMock('Horde_Kolab_Session');
- $session->expects($this->once())
- ->method('setId')
- ->with('1');
- $anonymous = new Horde_Kolab_Session_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_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_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_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_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_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_Anonymous(
- $session, 'anonymous', 'pass'
- );
- $anonymous->getStorage();
- }
-
-
-}
\ No newline at end of file
diff --git a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Decorator/AnonymousTest.php b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Decorator/AnonymousTest.php
new file mode 100644
index 000000000..d98e4c659
--- /dev/null
+++ b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Decorator/AnonymousTest.php
@@ -0,0 +1,175 @@
+
+ * @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 anonymous decorator.
+ *
+ * Copyright 2009 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
+ * @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_AnonymousTest
+extends Horde_Kolab_Session_SessionTestCase
+{
+ public function testMethodConnectHasPostconditionThatTheConnectionHasBeenEstablishedAsAnonymousUserIfRequired()
+ {
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
+ $session->expects($this->once())
+ ->method('getId')
+ ->will($this->returnValue(null));
+ $session->expects($this->once())
+ ->method('setId')
+ ->with('anonymous');
+ $session->expects($this->once())
+ ->method('connect')
+ ->with(array('password' => 'pass'));
+ $anonymous = new Horde_Kolab_Session_Decorator_Anonymous(
+ $session, 'anonymous', 'pass'
+ );
+ $anonymous->connect();
+ }
+
+ public function testMethodGetidReturnsNullIfConnectedUserIsAnonymousUser()
+ {
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
+ $session->expects($this->once())
+ ->method('getId')
+ ->will($this->returnValue('anonymous'));
+ $anonymous = new Horde_Kolab_Session_Decorator_Anonymous(
+ $session, 'anonymous', 'pass'
+ );
+ $this->assertNull($anonymous->getId());
+ }
+
+ public function testMethodConnectGetsDelegated()
+ {
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
+ $session->expects($this->once())
+ ->method('connect')
+ ->with(array('password' => 'pass'));
+ $anonymous = new Horde_Kolab_Session_Decorator_Anonymous(
+ $session, 'anonymous', 'pass'
+ );
+ $anonymous->connect(array('password' => 'pass'));
+ }
+
+ public function testMethodGetidGetsDelegated()
+ {
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
+ $session->expects($this->once())
+ ->method('getId')
+ ->will($this->returnValue('1'));
+ $anonymous = new Horde_Kolab_Session_Decorator_Anonymous(
+ $session, 'anonymous', 'pass'
+ );
+ $anonymous->getId();
+ }
+
+ public function testMethodSetidGetsDelegated()
+ {
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
+ $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_Interface');
+ $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_Interface');
+ $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_Interface');
+ $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_Interface');
+ $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_Interface');
+ $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_Interface');
+ $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/LoggedTest.php b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Decorator/LoggedTest.php
new file mode 100644
index 000000000..80bf6c5e2
--- /dev/null
+++ b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Decorator/LoggedTest.php
@@ -0,0 +1,184 @@
+
+ * @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 log decorator.
+ *
+ * Copyright 2009 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
+ * @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_LoggedTest
+extends Horde_Kolab_Session_SessionTestCase
+{
+ public function setUp()
+ {
+ parent::setUp();
+
+ $this->setupLogger();
+ }
+
+ public function testMethodConnectHasPostconditionThatASuccessfulConnectionGetsLogged()
+ {
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
+ $session->expects($this->once())
+ ->method('connect')
+ ->with(array('password' => 'pass'));
+ $session->expects($this->once())
+ ->method('getId')
+ ->will($this->returnValue('somebody@example.org'));
+ $this->logger->expects($this->once())
+ ->method('__call')
+ ->with(
+ 'info',
+ array(
+ 'Connected Kolab session for "somebody@example.org".'
+ )
+ );
+ $logged = new Horde_Kolab_Session_Decorator_Logged(
+ $session, $this->logger
+ );
+ $logged->connect(array('password' => 'pass'));
+ }
+
+ public function testMethodConnectHasPostconditionThatAnUnsuccessfulConnectionGetsLogged()
+ {
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
+ $session->expects($this->once())
+ ->method('connect')
+ ->will($this->throwException(new Horde_Kolab_Session_Exception('Error.')));
+ $session->expects($this->once())
+ ->method('getId')
+ ->will($this->returnValue('somebody@example.org'));
+ $this->logger->expects($this->once())
+ ->method('__call')
+ ->with(
+ 'err',
+ array(
+ 'Failed to connect Kolab session for "somebody@example.org". Error was: Error.'
+ )
+ );
+ $logged = new Horde_Kolab_Session_Decorator_Logged(
+ $session, $this->logger
+ );
+ try {
+ $logged->connect(array('password' => 'pass'));
+ $this->fail('No Exception!');
+ } catch (Horde_Kolab_Session_Exception $e) {
+ }
+ }
+
+ public function testMethodConnectGetsDelegated()
+ {
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
+ $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_Interface');
+ $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_Interface');
+ $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_Interface');
+ $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_Interface');
+ $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_Interface');
+ $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_Interface');
+ $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_Interface');
+ $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_Interface');
+ $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
diff --git a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Decorator/StoredTest.php b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Decorator/StoredTest.php
new file mode 100644
index 000000000..f18146391
--- /dev/null
+++ b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Decorator/StoredTest.php
@@ -0,0 +1,144 @@
+
+ * @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 storing decorator.
+ *
+ * Copyright 2009 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
+ * @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_StoredTest
+extends Horde_Kolab_Session_SessionTestCase
+{
+ public function setUp()
+ {
+ parent::setUp();
+
+ $this->setupStorage();
+ }
+
+ public function testMethodDestructHasPostconditionThatTheSessionWasSaved()
+ {
+ $this->storage->expects($this->once())
+ ->method('save')
+ ->with($this->isInstanceOf('Horde_Kolab_Session_Interface'));
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
+ $stored = new Horde_Kolab_Session_Decorator_Stored($session, $this->storage);
+ $stored = null;
+ }
+
+ public function testMethodConnectGetsDelegated()
+ {
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
+ $session->expects($this->once())
+ ->method('connect')
+ ->with(array('password' => 'pass'));
+ $stored = new Horde_Kolab_Session_Decorator_Stored($session, $this->storage);
+ $stored->connect(array('password' => 'pass'));
+ }
+
+ public function testMethodGetidGetsDelegated()
+ {
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
+ $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_Interface');
+ $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_Interface');
+ $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_Interface');
+ $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_Interface');
+ $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_Interface');
+ $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_Interface');
+ $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_Interface');
+ $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/Class/Factory/AnonymousTest.php b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/AnonymousTest.php
deleted file mode 100644
index 6209ea7eb..000000000
--- a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/AnonymousTest.php
+++ /dev/null
@@ -1,164 +0,0 @@
-
- * @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 anonymous decorator factory.
- *
- * Copyright 2009 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
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Session
- */
-class Horde_Kolab_Session_Class_Factory_AnonymousTest extends Horde_Kolab_Session_SessionTestCase
-{
- public function testMethodCreatesessionHasResultHordekolabsessionanonymous()
- {
- $session = $this->getMock('Horde_Kolab_Session');
- $factory = $this->getMock('Horde_Kolab_Session_Factory');
- $factory->expects($this->once())
- ->method('createSession')
- ->will($this->returnValue($session));
- $factory = new Horde_Kolab_Session_Factory_Anonymous(
- $factory, 'anonymous', ''
- );
- $this->assertType(
- 'Horde_Kolab_Session_Anonymous',
- $factory->createSession()
- );
- }
-
- public function testMethodGetserverGetsDelegated()
- {
- $server = $this->getMock('Horde_Kolab_Server');
- $factory = $this->getMock('Horde_Kolab_Session_Factory');
- $factory->expects($this->once())
- ->method('getServer')
- ->will($this->returnValue($server));
- $factory = new Horde_Kolab_Session_Factory_Anonymous(
- $factory, 'anonymous', ''
- );
- $this->assertType('Horde_Kolab_Server', $factory->getServer());
- }
-
- public function testMethodGetsessionauthGetsDelegated()
- {
- $auth = $this->getMock('Horde_Kolab_Session_Auth');
- $factory = $this->getMock('Horde_Kolab_Session_Factory');
- $factory->expects($this->once())
- ->method('getSessionAuth')
- ->will($this->returnValue($auth));
- $factory = new Horde_Kolab_Session_Factory_Anonymous(
- $factory, 'anonymous', ''
- );
- $this->assertType(
- 'Horde_Kolab_Session_Auth',
- $factory->getSessionAuth()
- );
- }
-
- public function testMethodGetsessionconfigurationGetsDelegated()
- {
- $factory = $this->getMock('Horde_Kolab_Session_Factory');
- $factory->expects($this->once())
- ->method('getSessionConfiguration')
- ->will($this->returnValue(array()));
- $factory = new Horde_Kolab_Session_Factory_Anonymous(
- $factory, 'anonymous', ''
- );
- $this->assertType('array', $factory->getSessionConfiguration());
- }
-
- public function testMethodGetsessionstorageGetsDelegated()
- {
- $storage = $this->getMock('Horde_Kolab_Session_Storage');
- $factory = $this->getMock('Horde_Kolab_Session_Factory');
- $factory->expects($this->once())
- ->method('getSessionStorage')
- ->will($this->returnValue($storage));
- $factory = new Horde_Kolab_Session_Factory_Anonymous(
- $factory, 'anonymous', ''
- );
- $this->assertType(
- 'Horde_Kolab_Session_Storage',
- $factory->getSessionStorage()
- );
- }
-
- public function testMethodGetsessionvalidatorGetsDelegated()
- {
- $session = $this->getMock('Horde_Kolab_Session');
- $auth = $this->getMock('Horde_Kolab_Session_Auth');
- $validator = $this->getMock('Horde_Kolab_Session_Valid');
- $factory = $this->getMock('Horde_Kolab_Session_Factory');
- $factory->expects($this->once())
- ->method('getSessionValidator')
- ->will($this->returnValue($validator));
- $factory = new Horde_Kolab_Session_Factory_Anonymous(
- $factory, 'anonymous', ''
- );
- $this->assertType(
- 'Horde_Kolab_Session_Valid',
- $factory->getSessionValidator($session, $auth)
- );
- }
-
- public function testMethodValidateGetsDelegated()
- {
- $session = $this->getMock('Horde_Kolab_Session');
- $factory = $this->getMock('Horde_Kolab_Session_Factory');
- $factory->expects($this->once())
- ->method('validate')
- ->will($this->returnValue(true));
- $factory = new Horde_Kolab_Session_Factory_Anonymous(
- $factory, 'anonymous', ''
- );
- $this->assertTrue($factory->validate($session, 'test'));
- }
-
- public function testMethodCreatesessionGetsDelegated()
- {
- $session = $this->getMock('Horde_Kolab_Session');
- $factory = $this->getMock('Horde_Kolab_Session_Factory');
- $factory->expects($this->once())
- ->method('createSession')
- ->will($this->returnValue($session));
- $factory = new Horde_Kolab_Session_Factory_Anonymous(
- $factory, 'anonymous', ''
- );
- $this->assertType('Horde_Kolab_Session', $factory->createSession());
- }
-
- public function testMethodGetsessionGetsDelegated()
- {
- $session = $this->getMock('Horde_Kolab_Session');
- $factory = $this->getMock('Horde_Kolab_Session_Factory');
- $factory->expects($this->once())
- ->method('getSession')
- ->will($this->returnValue($session));
- $factory = new Horde_Kolab_Session_Factory_Anonymous(
- $factory, 'anonymous', ''
- );
- $this->assertType('Horde_Kolab_Session', $factory->getSession());
- }
-}
\ No newline at end of file
diff --git a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/BaseTest.php b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/BaseTest.php
index 0ff43c543..2284c165e 100644
--- a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/BaseTest.php
+++ b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/BaseTest.php
@@ -43,12 +43,12 @@ class Horde_Kolab_Session_Class_Factory_BaseTest extends Horde_Kolab_Session_Ses
public function testMethodGetvalidatorHasResultHordekolabsesessionvalid()
{
- $session = $this->getMock('Horde_Kolab_Session');
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
$factory = new Horde_Kolab_Session_Factory_Constructor(
$this->server, $this->session_auth, array(), $this->session_storage
);
$this->assertType(
- 'Horde_Kolab_Session_Valid',
+ 'Horde_Kolab_Session_Valid_Interface',
$factory->getSessionValidator($session, $this->session_auth)
);
}
@@ -58,7 +58,7 @@ class Horde_Kolab_Session_Class_Factory_BaseTest extends Horde_Kolab_Session_Ses
$this->session_auth->expects($this->once())
->method('getCurrentUser')
->will($this->returnValue('mail@example.org'));
- $session = $this->getMock('Horde_Kolab_Session');
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
$session->expects($this->once())
->method('getMail')
->will($this->returnValue('mail@example.org'));
@@ -73,12 +73,12 @@ class Horde_Kolab_Session_Class_Factory_BaseTest extends Horde_Kolab_Session_Ses
$factory = new Horde_Kolab_Session_Factory_Constructor(
$this->server, $this->session_auth, array(), $this->session_storage
);
- $this->assertType('Horde_Kolab_Session_Stored', $factory->createSession());
+ $this->assertType('Horde_Kolab_Session_Decorator_Stored', $factory->createSession());
}
public function testMethodGetsessionHasResultHordekolabsessionTheOldSessionIfAnOldSessionWasStoredAndValid()
{
- $session = $this->getMock('Horde_Kolab_Session');
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
$session->expects($this->once())
->method('getMail')
->will($this->returnValue('mail@example.org'));
@@ -96,7 +96,7 @@ class Horde_Kolab_Session_Class_Factory_BaseTest extends Horde_Kolab_Session_Ses
public function testMethodGetsessionHasResultHordekolabsessionANewSessionIfAnOldSessionWasStoredAndInvalid()
{
- $session = $this->getMock('Horde_Kolab_Session');
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
$session->expects($this->once())
->method('getMail')
->will($this->returnValue('mail@example.org'));
@@ -138,6 +138,6 @@ class Horde_Kolab_Session_Class_Factory_BaseTest extends Horde_Kolab_Session_Ses
$factory = new Horde_Kolab_Session_Factory_Constructor(
$this->server, $this->session_auth, array(), $this->session_storage
);
- $this->assertType('Horde_Kolab_Session', $factory->getSession());
+ $this->assertType('Horde_Kolab_Session_Interface', $factory->getSession());
}
}
\ No newline at end of file
diff --git a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/ConfigurationTest.php b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/ConfigurationTest.php
index 5946485de..f47b6195d 100644
--- a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/ConfigurationTest.php
+++ b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/ConfigurationTest.php
@@ -67,7 +67,7 @@ class Horde_Kolab_Session_Class_Factory_ConfigurationTest extends Horde_Kolab_Se
)
);
$this->assertType(
- 'Horde_Kolab_Session_Anonymous',
+ 'Horde_Kolab_Session_Decorator_Anonymous',
$factory->createSession()
);
}
@@ -83,15 +83,15 @@ class Horde_Kolab_Session_Class_Factory_ConfigurationTest extends Horde_Kolab_Se
)
);
$this->assertType(
- 'Horde_Kolab_Session_Logged',
+ 'Horde_Kolab_Session_Decorator_Logged',
$factory->createSession()
);
}
public function testMethodGetsessionvalidatorHasResultHordekolabsessionvalidloggedIfConfiguredThatWay()
{
- $session = $this->getMock('Horde_Kolab_Session');
- $auth = $this->getMock('Horde_Kolab_Session_Auth');
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
+ $auth = $this->getMock('Horde_Kolab_Session_Auth_Interface');
$factory = new Horde_Kolab_Session_Factory_Configuration(
array(
'logger' => $this->logger,
@@ -101,7 +101,7 @@ class Horde_Kolab_Session_Class_Factory_ConfigurationTest extends Horde_Kolab_Se
)
);
$this->assertType(
- 'Horde_Kolab_Session_Valid_Logged',
+ 'Horde_Kolab_Session_Valid_Decorator_Logged',
$factory->getSessionValidator($session, $auth)
);
}
@@ -131,7 +131,7 @@ class Horde_Kolab_Session_Class_Factory_ConfigurationTest extends Horde_Kolab_Se
)
);
$this->assertType(
- 'Horde_Kolab_Session_Auth',
+ 'Horde_Kolab_Session_Auth_Interface',
$factory->getSessionAuth()
);
}
@@ -158,15 +158,15 @@ class Horde_Kolab_Session_Class_Factory_ConfigurationTest extends Horde_Kolab_Se
)
);
$this->assertType(
- 'Horde_Kolab_Session_Storage',
+ 'Horde_Kolab_Session_Storage_Interface',
$factory->getSessionStorage()
);
}
public function testMethodGetsessionvalidatorHasResultSessionvalid()
{
- $session = $this->getMock('Horde_Kolab_Session');
- $auth = $this->getMock('Horde_Kolab_Session_Auth');
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
+ $auth = $this->getMock('Horde_Kolab_Session_Auth_Interface');
$factory = new Horde_Kolab_Session_Factory_Configuration(
array(
'server' => array(
@@ -175,14 +175,14 @@ class Horde_Kolab_Session_Class_Factory_ConfigurationTest extends Horde_Kolab_Se
)
);
$this->assertType(
- 'Horde_Kolab_Session_Valid',
+ 'Horde_Kolab_Session_Valid_Interface',
$factory->getSessionValidator($session, $auth)
);
}
public function testMethodValidateHasResultBooleanTrueIfTheSessionIsStillValid()
{
- $session = $this->getMock('Horde_Kolab_Session');
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
$factory = new Horde_Kolab_Session_Factory_Configuration(
array(
'server' => array(
@@ -202,7 +202,7 @@ class Horde_Kolab_Session_Class_Factory_ConfigurationTest extends Horde_Kolab_Se
)
)
);
- $this->assertType('Horde_Kolab_Session', $factory->createSession());
+ $this->assertType('Horde_Kolab_Session_Interface', $factory->createSession());
}
public function testMethodGetsessionHasResultSession()
@@ -226,6 +226,6 @@ class Horde_Kolab_Session_Class_Factory_ConfigurationTest extends Horde_Kolab_Se
)
)
);
- $this->assertType('Horde_Kolab_Session', $factory->getSession());
+ $this->assertType('Horde_Kolab_Session_Interface', $factory->getSession());
}
}
\ No newline at end of file
diff --git a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/ConstructorTest.php b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/ConstructorTest.php
index d80a0354c..6a23d9ddc 100644
--- a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/ConstructorTest.php
+++ b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/ConstructorTest.php
@@ -51,7 +51,7 @@ class Horde_Kolab_Session_Class_Factory_ConstructorTest extends Horde_Kolab_Sess
$factory = new Horde_Kolab_Session_Factory_Constructor(
$this->server, $this->session_auth, array(), $this->session_storage
);
- $this->assertType('Horde_Kolab_Session_Auth', $factory->getSessionAuth());
+ $this->assertType('Horde_Kolab_Session_Auth_Interface', $factory->getSessionAuth());
}
public function testMethodGetsessionconfigurationHasResultArray()
@@ -67,6 +67,6 @@ class Horde_Kolab_Session_Class_Factory_ConstructorTest extends Horde_Kolab_Sess
$factory = new Horde_Kolab_Session_Factory_Constructor(
$this->server, $this->session_auth, array(), $this->session_storage
);
- $this->assertType('Horde_Kolab_Session_Storage', $factory->getSessionStorage());
+ $this->assertType('Horde_Kolab_Session_Storage_Interface', $factory->getSessionStorage());
}
}
\ No newline at end of file
diff --git a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/Decorator/AnonymousTest.php b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/Decorator/AnonymousTest.php
new file mode 100644
index 000000000..50abdeb74
--- /dev/null
+++ b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/Decorator/AnonymousTest.php
@@ -0,0 +1,165 @@
+
+ * @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 anonymous decorator factory.
+ *
+ * Copyright 2009 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
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Session
+ */
+class Horde_Kolab_Session_Class_Factory_Decorator_AnonymousTest
+extends Horde_Kolab_Session_SessionTestCase
+{
+ public function testMethodCreatesessionHasResultHordekolabsessionanonymous()
+ {
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
+ $factory = $this->getMock('Horde_Kolab_Session_Factory_Interface');
+ $factory->expects($this->once())
+ ->method('createSession')
+ ->will($this->returnValue($session));
+ $factory = new Horde_Kolab_Session_Factory_Decorator_Anonymous(
+ $factory, 'anonymous', ''
+ );
+ $this->assertType(
+ 'Horde_Kolab_Session_Decorator_Anonymous',
+ $factory->createSession()
+ );
+ }
+
+ public function testMethodGetserverGetsDelegated()
+ {
+ $server = $this->getMock('Horde_Kolab_Server');
+ $factory = $this->getMock('Horde_Kolab_Session_Factory_Interface');
+ $factory->expects($this->once())
+ ->method('getServer')
+ ->will($this->returnValue($server));
+ $factory = new Horde_Kolab_Session_Factory_Decorator_Anonymous(
+ $factory, 'anonymous', ''
+ );
+ $this->assertType('Horde_Kolab_Server', $factory->getServer());
+ }
+
+ public function testMethodGetsessionauthGetsDelegated()
+ {
+ $auth = $this->getMock('Horde_Kolab_Session_Auth_Interface');
+ $factory = $this->getMock('Horde_Kolab_Session_Factory_Interface');
+ $factory->expects($this->once())
+ ->method('getSessionAuth')
+ ->will($this->returnValue($auth));
+ $factory = new Horde_Kolab_Session_Factory_Decorator_Anonymous(
+ $factory, 'anonymous', ''
+ );
+ $this->assertType(
+ 'Horde_Kolab_Session_Auth_Interface',
+ $factory->getSessionAuth()
+ );
+ }
+
+ public function testMethodGetsessionconfigurationGetsDelegated()
+ {
+ $factory = $this->getMock('Horde_Kolab_Session_Factory_Interface');
+ $factory->expects($this->once())
+ ->method('getSessionConfiguration')
+ ->will($this->returnValue(array()));
+ $factory = new Horde_Kolab_Session_Factory_Decorator_Anonymous(
+ $factory, 'anonymous', ''
+ );
+ $this->assertType('array', $factory->getSessionConfiguration());
+ }
+
+ public function testMethodGetsessionstorageGetsDelegated()
+ {
+ $storage = $this->getMock('Horde_Kolab_Session_Storage_Interface');
+ $factory = $this->getMock('Horde_Kolab_Session_Factory_Interface');
+ $factory->expects($this->once())
+ ->method('getSessionStorage')
+ ->will($this->returnValue($storage));
+ $factory = new Horde_Kolab_Session_Factory_Decorator_Anonymous(
+ $factory, 'anonymous', ''
+ );
+ $this->assertType(
+ 'Horde_Kolab_Session_Storage_Interface',
+ $factory->getSessionStorage()
+ );
+ }
+
+ public function testMethodGetsessionvalidatorGetsDelegated()
+ {
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
+ $auth = $this->getMock('Horde_Kolab_Session_Auth_Interface');
+ $validator = $this->getMock('Horde_Kolab_Session_Valid_Interface');
+ $factory = $this->getMock('Horde_Kolab_Session_Factory_Interface');
+ $factory->expects($this->once())
+ ->method('getSessionValidator')
+ ->will($this->returnValue($validator));
+ $factory = new Horde_Kolab_Session_Factory_Decorator_Anonymous(
+ $factory, 'anonymous', ''
+ );
+ $this->assertType(
+ 'Horde_Kolab_Session_Valid_Interface',
+ $factory->getSessionValidator($session, $auth)
+ );
+ }
+
+ public function testMethodValidateGetsDelegated()
+ {
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
+ $factory = $this->getMock('Horde_Kolab_Session_Factory_Interface');
+ $factory->expects($this->once())
+ ->method('validate')
+ ->will($this->returnValue(true));
+ $factory = new Horde_Kolab_Session_Factory_Decorator_Anonymous(
+ $factory, 'anonymous', ''
+ );
+ $this->assertTrue($factory->validate($session, 'test'));
+ }
+
+ public function testMethodCreatesessionGetsDelegated()
+ {
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
+ $factory = $this->getMock('Horde_Kolab_Session_Factory_Interface');
+ $factory->expects($this->once())
+ ->method('createSession')
+ ->will($this->returnValue($session));
+ $factory = new Horde_Kolab_Session_Factory_Decorator_Anonymous(
+ $factory, 'anonymous', ''
+ );
+ $this->assertType('Horde_Kolab_Session_Interface', $factory->createSession());
+ }
+
+ public function testMethodGetsessionGetsDelegated()
+ {
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
+ $factory = $this->getMock('Horde_Kolab_Session_Factory_Interface');
+ $factory->expects($this->once())
+ ->method('getSession')
+ ->will($this->returnValue($session));
+ $factory = new Horde_Kolab_Session_Factory_Decorator_Anonymous(
+ $factory, 'anonymous', ''
+ );
+ $this->assertType('Horde_Kolab_Session_Interface', $factory->getSession());
+ }
+}
\ No newline at end of file
diff --git a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/Decorator/LoggedTest.php b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/Decorator/LoggedTest.php
new file mode 100644
index 000000000..32b2cb173
--- /dev/null
+++ b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/Decorator/LoggedTest.php
@@ -0,0 +1,189 @@
+
+ * @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 log decorator factory.
+ *
+ * Copyright 2009 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
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Session
+ */
+class Horde_Kolab_Session_Class_Factory_Decorator_LoggedTest
+extends Horde_Kolab_Session_SessionTestCase
+{
+ public function setUp()
+ {
+ parent::setUp();
+ $this->setupLogger();
+ }
+
+ public function testMethodCreatesessionHasResultHordekolabsessionlogged()
+ {
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
+ $factory = $this->getMock('Horde_Kolab_Session_Factory_Interface');
+ $factory->expects($this->once())
+ ->method('createSession')
+ ->will($this->returnValue($session));
+ $factory = new Horde_Kolab_Session_Factory_Decorator_Logged(
+ $factory, $this->logger
+ );
+ $this->assertType(
+ 'Horde_Kolab_Session_Decorator_Logged',
+ $factory->createSession()
+ );
+ }
+
+ public function testMethodGetsessionvalidatorHasResultHordekolabsessionvalidlogged()
+ {
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
+ $auth = $this->getMock('Horde_Kolab_Session_Auth_Interface');
+ $validator = $this->getMock('Horde_Kolab_Session_Valid_Interface');
+ $factory = $this->getMock('Horde_Kolab_Session_Factory_Interface');
+ $factory->expects($this->once())
+ ->method('getSessionValidator')
+ ->will($this->returnValue($validator));
+ $factory = new Horde_Kolab_Session_Factory_Decorator_Logged(
+ $factory, $this->logger
+ );
+ $this->assertType(
+ 'Horde_Kolab_Session_Valid_Decorator_Logged',
+ $factory->getSessionValidator($session, $auth)
+ );
+ }
+
+ public function testMethodGetserverGetsDelegated()
+ {
+ $server = $this->getMock('Horde_Kolab_Server');
+ $factory = $this->getMock('Horde_Kolab_Session_Factory_Interface');
+ $factory->expects($this->once())
+ ->method('getServer')
+ ->will($this->returnValue($server));
+ $factory = new Horde_Kolab_Session_Factory_Decorator_Logged(
+ $factory, $this->logger
+ );
+ $this->assertType('Horde_Kolab_Server', $factory->getServer());
+ }
+
+ public function testMethodGetsessionauthGetsDelegated()
+ {
+ $auth = $this->getMock('Horde_Kolab_Session_Auth');
+ $factory = $this->getMock('Horde_Kolab_Session_Factory_Interface');
+ $factory->expects($this->once())
+ ->method('getSessionAuth')
+ ->will($this->returnValue($auth));
+ $factory = new Horde_Kolab_Session_Factory_Decorator_Logged(
+ $factory, $this->logger
+ );
+ $this->assertType(
+ 'Horde_Kolab_Session_Auth',
+ $factory->getSessionAuth()
+ );
+ }
+
+ public function testMethodGetsessionconfigurationGetsDelegated()
+ {
+ $factory = $this->getMock('Horde_Kolab_Session_Factory_Interface');
+ $factory->expects($this->once())
+ ->method('getSessionConfiguration')
+ ->will($this->returnValue(array()));
+ $factory = new Horde_Kolab_Session_Factory_Decorator_Logged(
+ $factory, $this->logger
+ );
+ $this->assertType('array', $factory->getSessionConfiguration());
+ }
+
+ public function testMethodGetsessionstorageGetsDelegated()
+ {
+ $storage = $this->getMock('Horde_Kolab_Session_Storage');
+ $factory = $this->getMock('Horde_Kolab_Session_Factory_Interface');
+ $factory->expects($this->once())
+ ->method('getSessionStorage')
+ ->will($this->returnValue($storage));
+ $factory = new Horde_Kolab_Session_Factory_Decorator_Logged(
+ $factory, $this->logger
+ );
+ $this->assertType(
+ 'Horde_Kolab_Session_Storage',
+ $factory->getSessionStorage()
+ );
+ }
+
+ public function testMethodGetsessionvalidatorGetsDelegated()
+ {
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
+ $auth = $this->getMock('Horde_Kolab_Session_Auth_Interface');
+ $validator = $this->getMock('Horde_Kolab_Session_Valid_Interface');
+ $factory = $this->getMock('Horde_Kolab_Session_Factory_Interface');
+ $factory->expects($this->once())
+ ->method('getSessionValidator')
+ ->will($this->returnValue($validator));
+ $factory = new Horde_Kolab_Session_Factory_Decorator_Logged(
+ $factory, $this->logger
+ );
+ $this->assertType(
+ 'Horde_Kolab_Session_Valid_Interface',
+ $factory->getSessionValidator($session, $auth)
+ );
+ }
+
+ public function testMethodValidateGetsDelegated()
+ {
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
+ $factory = $this->getMock('Horde_Kolab_Session_Factory_Interface');
+ $factory->expects($this->once())
+ ->method('validate')
+ ->will($this->returnValue(true));
+ $factory = new Horde_Kolab_Session_Factory_Decorator_Logged(
+ $factory, $this->logger
+ );
+ $this->assertTrue($factory->validate($session, 'test'));
+ }
+
+ public function testMethodCreatesessionGetsDelegated()
+ {
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
+ $factory = $this->getMock('Horde_Kolab_Session_Factory_Interface');
+ $factory->expects($this->once())
+ ->method('createSession')
+ ->will($this->returnValue($session));
+ $factory = new Horde_Kolab_Session_Factory_Decorator_Logged(
+ $factory, $this->logger
+ );
+ $this->assertType('Horde_Kolab_Session_Interface', $factory->createSession());
+ }
+
+ public function testMethodGetsessionGetsDelegated()
+ {
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
+ $factory = $this->getMock('Horde_Kolab_Session_Factory_Interface');
+ $factory->expects($this->once())
+ ->method('getSession')
+ ->will($this->returnValue($session));
+ $factory = new Horde_Kolab_Session_Factory_Decorator_Logged(
+ $factory, $this->logger
+ );
+ $this->assertType('Horde_Kolab_Session_Interface', $factory->getSession());
+ }
+}
\ No newline at end of file
diff --git a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/DefaultTest.php b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/DefaultTest.php
index c22d8926d..14587b3b2 100644
--- a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/DefaultTest.php
+++ b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/DefaultTest.php
@@ -54,7 +54,7 @@ class Horde_Kolab_Session_Class_Factory_DefaultTest extends Horde_Kolab_Session_
array('server' => array()),
$this->getMock('Horde_Kolab_Server_Factory_Interface')
);
- $this->assertType('Horde_Kolab_Session_Auth', $factory->getSessionAuth());
+ $this->assertType('Horde_Kolab_Session_Auth_Interface', $factory->getSessionAuth());
}
public function testMethodGetsessionconfigurationHasResultArray()
@@ -72,6 +72,6 @@ class Horde_Kolab_Session_Class_Factory_DefaultTest extends Horde_Kolab_Session_
array('server' => array()),
$this->getMock('Horde_Kolab_Server_Factory_Interface')
);
- $this->assertType('Horde_Kolab_Session_Storage', $factory->getSessionStorage());
+ $this->assertType('Horde_Kolab_Session_Storage_Interface', $factory->getSessionStorage());
}
}
\ No newline at end of file
diff --git a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/InjectorTest.php b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/InjectorTest.php
index 24dab3fd6..d455efc9d 100644
--- a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/InjectorTest.php
+++ b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/InjectorTest.php
@@ -51,7 +51,7 @@ class Horde_Kolab_Session_Class_Factory_InjectorTest extends Horde_Kolab_Session
$factory = new Horde_Kolab_Session_Factory_Injector(
array('server' => array()), $this->injector
);
- $this->assertType('Horde_Kolab_Session_Auth', $factory->getSessionAuth());
+ $this->assertType('Horde_Kolab_Session_Auth_Interface', $factory->getSessionAuth());
}
public function testMethodGetsessionconfigurationHasResultArray()
@@ -67,6 +67,6 @@ class Horde_Kolab_Session_Class_Factory_InjectorTest extends Horde_Kolab_Session
$factory = new Horde_Kolab_Session_Factory_Injector(
array('server' => array()), $this->injector
);
- $this->assertType('Horde_Kolab_Session_Storage', $factory->getSessionStorage());
+ $this->assertType('Horde_Kolab_Session_Storage_Interface', $factory->getSessionStorage());
}
}
\ No newline at end of file
diff --git a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/LoggedTest.php b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/LoggedTest.php
deleted file mode 100644
index 367b134b0..000000000
--- a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/LoggedTest.php
+++ /dev/null
@@ -1,188 +0,0 @@
-
- * @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 log decorator factory.
- *
- * Copyright 2009 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
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Session
- */
-class Horde_Kolab_Session_Class_Factory_LoggedTest extends Horde_Kolab_Session_SessionTestCase
-{
- public function setUp()
- {
- parent::setUp();
- $this->setupLogger();
- }
-
- public function testMethodCreatesessionHasResultHordekolabsessionlogged()
- {
- $session = $this->getMock('Horde_Kolab_Session');
- $factory = $this->getMock('Horde_Kolab_Session_Factory');
- $factory->expects($this->once())
- ->method('createSession')
- ->will($this->returnValue($session));
- $factory = new Horde_Kolab_Session_Factory_Logged(
- $factory, $this->logger
- );
- $this->assertType(
- 'Horde_Kolab_Session_Logged',
- $factory->createSession()
- );
- }
-
- public function testMethodGetsessionvalidatorHasResultHordekolabsessionvalidlogged()
- {
- $session = $this->getMock('Horde_Kolab_Session');
- $auth = $this->getMock('Horde_Kolab_Session_Auth');
- $validator = $this->getMock('Horde_Kolab_Session_Valid');
- $factory = $this->getMock('Horde_Kolab_Session_Factory');
- $factory->expects($this->once())
- ->method('getSessionValidator')
- ->will($this->returnValue($validator));
- $factory = new Horde_Kolab_Session_Factory_Logged(
- $factory, $this->logger
- );
- $this->assertType(
- 'Horde_Kolab_Session_Valid_Logged',
- $factory->getSessionValidator($session, $auth)
- );
- }
-
- public function testMethodGetserverGetsDelegated()
- {
- $server = $this->getMock('Horde_Kolab_Server');
- $factory = $this->getMock('Horde_Kolab_Session_Factory');
- $factory->expects($this->once())
- ->method('getServer')
- ->will($this->returnValue($server));
- $factory = new Horde_Kolab_Session_Factory_Logged(
- $factory, $this->logger
- );
- $this->assertType('Horde_Kolab_Server', $factory->getServer());
- }
-
- public function testMethodGetsessionauthGetsDelegated()
- {
- $auth = $this->getMock('Horde_Kolab_Session_Auth');
- $factory = $this->getMock('Horde_Kolab_Session_Factory');
- $factory->expects($this->once())
- ->method('getSessionAuth')
- ->will($this->returnValue($auth));
- $factory = new Horde_Kolab_Session_Factory_Logged(
- $factory, $this->logger
- );
- $this->assertType(
- 'Horde_Kolab_Session_Auth',
- $factory->getSessionAuth()
- );
- }
-
- public function testMethodGetsessionconfigurationGetsDelegated()
- {
- $factory = $this->getMock('Horde_Kolab_Session_Factory');
- $factory->expects($this->once())
- ->method('getSessionConfiguration')
- ->will($this->returnValue(array()));
- $factory = new Horde_Kolab_Session_Factory_Logged(
- $factory, $this->logger
- );
- $this->assertType('array', $factory->getSessionConfiguration());
- }
-
- public function testMethodGetsessionstorageGetsDelegated()
- {
- $storage = $this->getMock('Horde_Kolab_Session_Storage');
- $factory = $this->getMock('Horde_Kolab_Session_Factory');
- $factory->expects($this->once())
- ->method('getSessionStorage')
- ->will($this->returnValue($storage));
- $factory = new Horde_Kolab_Session_Factory_Logged(
- $factory, $this->logger
- );
- $this->assertType(
- 'Horde_Kolab_Session_Storage',
- $factory->getSessionStorage()
- );
- }
-
- public function testMethodGetsessionvalidatorGetsDelegated()
- {
- $session = $this->getMock('Horde_Kolab_Session');
- $auth = $this->getMock('Horde_Kolab_Session_Auth');
- $validator = $this->getMock('Horde_Kolab_Session_Valid');
- $factory = $this->getMock('Horde_Kolab_Session_Factory');
- $factory->expects($this->once())
- ->method('getSessionValidator')
- ->will($this->returnValue($validator));
- $factory = new Horde_Kolab_Session_Factory_Logged(
- $factory, $this->logger
- );
- $this->assertType(
- 'Horde_Kolab_Session_Valid',
- $factory->getSessionValidator($session, $auth)
- );
- }
-
- public function testMethodValidateGetsDelegated()
- {
- $session = $this->getMock('Horde_Kolab_Session');
- $factory = $this->getMock('Horde_Kolab_Session_Factory');
- $factory->expects($this->once())
- ->method('validate')
- ->will($this->returnValue(true));
- $factory = new Horde_Kolab_Session_Factory_Logged(
- $factory, $this->logger
- );
- $this->assertTrue($factory->validate($session, 'test'));
- }
-
- public function testMethodCreatesessionGetsDelegated()
- {
- $session = $this->getMock('Horde_Kolab_Session');
- $factory = $this->getMock('Horde_Kolab_Session_Factory');
- $factory->expects($this->once())
- ->method('createSession')
- ->will($this->returnValue($session));
- $factory = new Horde_Kolab_Session_Factory_Logged(
- $factory, $this->logger
- );
- $this->assertType('Horde_Kolab_Session', $factory->createSession());
- }
-
- public function testMethodGetsessionGetsDelegated()
- {
- $session = $this->getMock('Horde_Kolab_Session');
- $factory = $this->getMock('Horde_Kolab_Session_Factory');
- $factory->expects($this->once())
- ->method('getSession')
- ->will($this->returnValue($session));
- $factory = new Horde_Kolab_Session_Factory_Logged(
- $factory, $this->logger
- );
- $this->assertType('Horde_Kolab_Session', $factory->getSession());
- }
-}
\ No newline at end of file
diff --git a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/LoggedTest.php b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/LoggedTest.php
deleted file mode 100644
index f8be5455e..000000000
--- a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/LoggedTest.php
+++ /dev/null
@@ -1,175 +0,0 @@
-
- * @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 log decorator.
- *
- * Copyright 2009 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
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Session
- */
-class Horde_Kolab_Session_Class_LoggedTest extends Horde_Kolab_Session_SessionTestCase
-{
- public function setUp()
- {
- parent::setUp();
-
- $this->setupLogger();
- }
-
- public function testMethodConnectHasPostconditionThatASuccessfulConnectionGetsLogged()
- {
- $session = $this->getMock('Horde_Kolab_Session');
- $session->expects($this->once())
- ->method('connect')
- ->with(array('password' => 'pass'));
- $session->expects($this->once())
- ->method('getId')
- ->will($this->returnValue('somebody@example.org'));
- $this->logger->expects($this->once())
- ->method('__call')
- ->with(
- 'info',
- array('Connected Kolab session for "somebody@example.org".')
- );
- $logged = new Horde_Kolab_Session_Logged($session, $this->logger);
- $logged->connect(array('password' => 'pass'));
- }
-
- public function testMethodConnectHasPostconditionThatAnUnsuccessfulConnectionGetsLogged()
- {
- $session = $this->getMock('Horde_Kolab_Session');
- $session->expects($this->once())
- ->method('connect')
- ->will($this->throwException(new Horde_Kolab_Session_Exception('Error.')));
- $session->expects($this->once())
- ->method('getId')
- ->will($this->returnValue('somebody@example.org'));
- $this->logger->expects($this->once())
- ->method('__call')
- ->with(
- 'err',
- array('Failed to connect Kolab session for "somebody@example.org". Error was: Error.')
- );
- $logged = new Horde_Kolab_Session_Logged($session, $this->logger);
- try {
- $logged->connect(array('password' => 'pass'));
- $this->fail('No Exception!');
- } 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_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_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_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_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_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_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_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_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_Logged($session, $this->logger);
- $logged->getStorage();
- }
-
-
-}
\ No newline at end of file
diff --git a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Storage/MockTest.php b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Storage/MockTest.php
index b18725984..d08a8641f 100644
--- a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Storage/MockTest.php
+++ b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Storage/MockTest.php
@@ -40,7 +40,7 @@ class Horde_Kolab_Session_Class_Storage_MockTest extends Horde_Kolab_Session_Ses
public function testMethodSaveHasPostconditionThatTheSessionDataWasSaved()
{
- $session = $this->getMock('Horde_Kolab_Session');
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
$storage = new Horde_Kolab_Session_Storage_Mock('test');
$storage->save($session);
$this->assertSame($session, $storage->session);
diff --git a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Storage/SessionobjectsTest.php b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Storage/SessionobjectsTest.php
index ec620a6a8..06be6bea7 100644
--- a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Storage/SessionobjectsTest.php
+++ b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Storage/SessionobjectsTest.php
@@ -47,8 +47,8 @@ class Horde_Kolab_Session_Class_Storage_SessionobjectsTest extends Horde_Kolab_S
$session_objects = $this->getMock('Horde_SessionObjects', array(), array(), '', false, false);
$session_objects->expects($this->once())
->method('overwrite')
- ->with('kolab_session', $this->isInstanceOf('Horde_Kolab_Session'));
- $session = $this->getMock('Horde_Kolab_Session');
+ ->with('kolab_session', $this->isInstanceOf('Horde_Kolab_Session_Interface'));
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
$storage = new Horde_Kolab_Session_Storage_Sessionobjects($session_objects);
$storage->save($session);
}
diff --git a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/StoredTest.php b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/StoredTest.php
deleted file mode 100644
index 767da7be5..000000000
--- a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/StoredTest.php
+++ /dev/null
@@ -1,143 +0,0 @@
-
- * @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 storing decorator.
- *
- * Copyright 2009 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
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Session
- */
-class Horde_Kolab_Session_Class_StoredTest extends Horde_Kolab_Session_SessionTestCase
-{
- public function setUp()
- {
- parent::setUp();
-
- $this->setupStorage();
- }
-
- public function testMethodDestructHasPostconditionThatTheSessionWasSaved()
- {
- $this->storage->expects($this->once())
- ->method('save')
- ->with($this->isInstanceOf('Horde_Kolab_Session'));
- $session = $this->getMock('Horde_Kolab_Session');
- $stored = new Horde_Kolab_Session_Stored($session, $this->storage);
- $stored = null;
- }
-
- public function testMethodConnectGetsDelegated()
- {
- $session = $this->getMock('Horde_Kolab_Session');
- $session->expects($this->once())
- ->method('connect')
- ->with(array('password' => 'pass'));
- $stored = new Horde_Kolab_Session_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_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_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_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_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_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_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_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_Stored($session, $this->storage);
- $stored->getStorage();
- }
-
-
-}
\ No newline at end of file
diff --git a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Valid/BaseTest.php b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Valid/BaseTest.php
index 7f9b700df..42a976df2 100644
--- a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Valid/BaseTest.php
+++ b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Valid/BaseTest.php
@@ -34,11 +34,11 @@ class Horde_Kolab_Session_Class_Valid_BaseTest extends Horde_Kolab_Session_Sessi
{
public function testMethodIsvalidHasResultBooleanTrueIfTheSessionIsNotConnectedAndTheCurrentUserIsAnonymous()
{
- $auth = $this->getMock('Horde_Kolab_Session_Auth');
+ $auth = $this->getMock('Horde_Kolab_Session_Auth_Interface');
$auth->expects($this->once())
->method('getCurrentUser')
->will($this->returnValue(''));
- $session = $this->getMock('Horde_Kolab_Session');
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
$session->expects($this->once())
->method('getMail')
->will($this->returnValue(''));
@@ -48,11 +48,11 @@ class Horde_Kolab_Session_Class_Valid_BaseTest extends Horde_Kolab_Session_Sessi
public function testMethodIsvalidHasResultBooleanFalseIfTheSessionIsNotConnected()
{
- $auth = $this->getMock('Horde_Kolab_Session_Auth');
+ $auth = $this->getMock('Horde_Kolab_Session_Auth_Interface');
$auth->expects($this->once())
->method('getCurrentUser')
->will($this->returnValue('mail@example.org'));
- $session = $this->getMock('Horde_Kolab_Session');
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
$session->expects($this->once())
->method('getMail')
->will($this->returnValue(''));
@@ -62,11 +62,11 @@ class Horde_Kolab_Session_Class_Valid_BaseTest extends Horde_Kolab_Session_Sessi
public function testMethodIsvalidHasResultBooleanFalseIfTheMailOfTheCurrentUserDoesNotMatchTheCurrentUserOfTheSession()
{
- $auth = $this->getMock('Horde_Kolab_Session_Auth');
+ $auth = $this->getMock('Horde_Kolab_Session_Auth_Interface');
$auth->expects($this->once())
->method('getCurrentUser')
->will($this->returnValue('somebody@example.org'));
- $session = $this->getMock('Horde_Kolab_Session');
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
$session->expects($this->once())
->method('getMail')
->will($this->returnValue('mail@example.org'));
@@ -76,11 +76,11 @@ class Horde_Kolab_Session_Class_Valid_BaseTest extends Horde_Kolab_Session_Sessi
public function testMethodIsvalidHasResultBooleanTrueIfTheMailOfTheCurrentUserMatchesTheCurrentUserOfTheSessionAndNoNewUserWasSet()
{
- $auth = $this->getMock('Horde_Kolab_Session_Auth');
+ $auth = $this->getMock('Horde_Kolab_Session_Auth_Interface');
$auth->expects($this->once())
->method('getCurrentUser')
->will($this->returnValue('mail@example.org'));
- $session = $this->getMock('Horde_Kolab_Session');
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
$session->expects($this->once())
->method('getMail')
->will($this->returnValue('mail@example.org'));
@@ -90,11 +90,11 @@ class Horde_Kolab_Session_Class_Valid_BaseTest extends Horde_Kolab_Session_Sessi
public function testMethodIsvalidHasResultBooleanFalseIfTheMailOfTheCurrentUserMatchesTheCurrentUserOfTheSessionAndTheNewUserMatchesNeitherTheCurrentUserMailAndUid()
{
- $auth = $this->getMock('Horde_Kolab_Session_Auth');
+ $auth = $this->getMock('Horde_Kolab_Session_Auth_Interface');
$auth->expects($this->once())
->method('getCurrentUser')
->will($this->returnValue('mail@example.org'));
- $session = $this->getMock('Horde_Kolab_Session');
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
$session->expects($this->once())
->method('getMail')
->will($this->returnValue('mail@example.org'));
@@ -104,11 +104,11 @@ class Horde_Kolab_Session_Class_Valid_BaseTest extends Horde_Kolab_Session_Sessi
public function testMethodIsvalidHasResultBooleanTrueIfTheMailOfTheCurrentUserMatchesTheCurrentUserOfTheSessionAndTheNewUserMatchesEitherTheCurrentUserMailAndUid()
{
- $auth = $this->getMock('Horde_Kolab_Session_Auth');
+ $auth = $this->getMock('Horde_Kolab_Session_Auth_Interface');
$auth->expects($this->once())
->method('getCurrentUser')
->will($this->returnValue('mail@example.org'));
- $session = $this->getMock('Horde_Kolab_Session');
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
$session->expects($this->once())
->method('getMail')
->will($this->returnValue('mail@example.org'));
diff --git a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Valid/Decorator/LoggedTest.php b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Valid/Decorator/LoggedTest.php
new file mode 100644
index 000000000..04a59f41b
--- /dev/null
+++ b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Valid/Decorator/LoggedTest.php
@@ -0,0 +1,98 @@
+
+ * @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 log decorator for validators.
+ *
+ * Copyright 2009 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
+ * @license http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @link http://pear.horde.org/index.php?package=Kolab_Session
+ */
+class Horde_Kolab_Session_Class_Valid_Decorator_LoggedTest
+extends Horde_Kolab_Session_SessionTestCase
+{
+ public function setUp()
+ {
+ parent::setUp();
+
+ $this->setupLogger();
+ }
+
+ public function testMethodIsvalidHasPostconditionThatAnInvalidSessionGetsLogged()
+ {
+ $auth = $this->getMock('Horde_Kolab_Session_Auth_Interface');
+ $auth->expects($this->exactly(2))
+ ->method('getCurrentUser')
+ ->will($this->returnValue('auth@example.org'));
+ $session = $this->getMock('Horde_Kolab_Session_Interface');
+ $session->expects($this->exactly(2))
+ ->method('getMail')
+ ->will($this->returnValue('somebody@example.org'));
+ $this->logger->expects($this->once())
+ ->method('__call')
+ ->with(
+ 'info',
+ array('Invalid Kolab session for current user "auth@example.org", requested user "nobody@example.org" and stored user "somebody@example.org".')
+ );
+ $logged = new Horde_Kolab_Session_Decorator_Logged(
+ $session, $this->logger
+ );
+ $valid = new Horde_Kolab_Session_Valid_Base($session, $auth);
+ $logged = new Horde_Kolab_Session_Valid_Decorator_Logged(
+ $valid, $this->logger
+ );
+ $this->assertFalse($logged->isValid('nobody@example.org'));
+ }
+
+ public function testMethodIsvalidGetsDelegated()
+ {
+ $valid = $this->getMock('Horde_Kolab_Session_Valid_Interface');
+ $valid->expects($this->once())
+ ->method('isValid')
+ ->will($this->returnValue(true));
+ $logged = new Horde_Kolab_Session_Valid_Decorator_Logged(
+ $valid, $this->logger
+ );
+ $this->assertTrue($logged->isValid());
+ }
+
+ public function testMethodGetsessionGetsDelegated()
+ {
+ $valid = $this->getMock('Horde_Kolab_Session_Valid_Interface');
+ $valid->expects($this->once())
+ ->method('getSession');
+ $logged = new Horde_Kolab_Session_Valid_Decorator_Logged($valid, $this->logger);
+ $logged->getSession();
+ }
+
+ public function testMethodGetauthGetsDelegated()
+ {
+ $valid = $this->getMock('Horde_Kolab_Session_Valid_Interface');
+ $valid->expects($this->once())
+ ->method('getAuth');
+ $logged = new Horde_Kolab_Session_Valid_Decorator_Logged($valid, $this->logger);
+ $logged->getAuth();
+ }
+}
\ No newline at end of file
diff --git a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Valid/LoggedTest.php b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Valid/LoggedTest.php
deleted file mode 100644
index bd51d0432..000000000
--- a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Valid/LoggedTest.php
+++ /dev/null
@@ -1,91 +0,0 @@
-
- * @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 log decorator for validators.
- *
- * Copyright 2009 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
- * @license http://www.fsf.org/copyleft/lgpl.html LGPL
- * @link http://pear.horde.org/index.php?package=Kolab_Session
- */
-class Horde_Kolab_Session_Class_Valid_LoggedTest extends Horde_Kolab_Session_SessionTestCase
-{
- public function setUp()
- {
- parent::setUp();
-
- $this->setupLogger();
- }
-
- public function testMethodIsvalidHasPostconditionThatAnInvalidSessionGetsLogged()
- {
- $auth = $this->getMock('Horde_Kolab_Session_Auth');
- $auth->expects($this->exactly(2))
- ->method('getCurrentUser')
- ->will($this->returnValue('auth@example.org'));
- $session = $this->getMock('Horde_Kolab_Session');
- $session->expects($this->exactly(2))
- ->method('getMail')
- ->will($this->returnValue('somebody@example.org'));
- $this->logger->expects($this->once())
- ->method('__call')
- ->with(
- 'info',
- array('Invalid Kolab session for current user "auth@example.org", requested user "nobody@example.org" and stored user "somebody@example.org".')
- );
- $logged = new Horde_Kolab_Session_Logged($session, $this->logger);
- $valid = new Horde_Kolab_Session_Valid_Base($session, $auth);
- $logged = new Horde_Kolab_Session_Valid_Logged($valid, $this->logger);
- $this->assertFalse($logged->isValid('nobody@example.org'));
- }
-
- public function testMethodIsvalidGetsDelegated()
- {
- $valid = $this->getMock('Horde_Kolab_Session_Valid');
- $valid->expects($this->once())
- ->method('isValid')
- ->will($this->returnValue(true));
- $logged = new Horde_Kolab_Session_Valid_Logged($valid, $this->logger);
- $this->assertTrue($logged->isValid());
- }
-
- public function testMethodGetsessionGetsDelegated()
- {
- $valid = $this->getMock('Horde_Kolab_Session_Valid');
- $valid->expects($this->once())
- ->method('getSession');
- $logged = new Horde_Kolab_Session_Valid_Logged($valid, $this->logger);
- $logged->getSession();
- }
-
- public function testMethodGetauthGetsDelegated()
- {
- $valid = $this->getMock('Horde_Kolab_Session_Valid');
- $valid->expects($this->once())
- ->method('getAuth');
- $logged = new Horde_Kolab_Session_Valid_Logged($valid, $this->logger);
- $logged->getAuth();
- }
-}
\ No newline at end of file
diff --git a/framework/Kolab_Session/test/Horde/Kolab/Session/Integration/AnonymousTest.php b/framework/Kolab_Session/test/Horde/Kolab/Session/Integration/AnonymousTest.php
index 6791dc0dc..a09c46662 100644
--- a/framework/Kolab_Session/test/Horde/Kolab/Session/Integration/AnonymousTest.php
+++ b/framework/Kolab_Session/test/Horde/Kolab/Session/Integration/AnonymousTest.php
@@ -52,7 +52,7 @@ class Horde_Kolab_Session_Integration_AnonymousTest extends Horde_Kolab_Session_
$session = new Horde_Kolab_Session_Base(
'', $composite, array()
);
- $anonymous = new Horde_Kolab_Session_Anonymous(
+ $anonymous = new Horde_Kolab_Session_Decorator_Anonymous(
$session, 'anonymous', 'pass'
);
$anonymous->connect();
diff --git a/framework/Kolab_Session/test/Horde/Kolab/Session/Integration/SessionTest.php b/framework/Kolab_Session/test/Horde/Kolab/Session/Integration/SessionTest.php
index 6166e8c08..3d80fd353 100644
--- a/framework/Kolab_Session/test/Horde/Kolab/Session/Integration/SessionTest.php
+++ b/framework/Kolab_Session/test/Horde/Kolab/Session/Integration/SessionTest.php
@@ -30,7 +30,8 @@ require_once dirname(__FILE__) . '/../Autoload.php';
* @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
+class Horde_Kolab_Session_Integration_SessionTest
+extends Horde_Kolab_Session_SessionTestCase
{
/**
* Setup function.
@@ -93,8 +94,10 @@ class Horde_Kolab_Session_Integration_SessionTest extends Horde_Kolab_Session_Se
$this->assertNoError($result);
$this->assertEquals(1, count($GLOBALS['KOLAB_SERVER_TEST_DATA']));
- $session = Horde_Kolab_Session::singleton('test',
- array('password' => 'test'));
+ $session = Horde_Kolab_Session::singleton(
+ 'test',
+ array('password' => 'test')
+ );
$this->assertNoError($session->auth);
$this->assertEquals('test@example.org', $session->user_mail);
@@ -116,7 +119,9 @@ class Horde_Kolab_Session_Integration_SessionTest extends Horde_Kolab_Session_Se
$this->assertEquals(143, $params['port']);
$this->assertEquals('test@example.org', $session->user_mail);
- $this->assertEquals('https://fb.example.org/freebusy', $session->freebusy_server);
+ $this->assertEquals(
+ 'https://fb.example.org/freebusy', $session->freebusy_server
+ );
}
/**
@@ -157,19 +162,25 @@ class Horde_Kolab_Session_Integration_SessionTest extends Horde_Kolab_Session_Se
$this->assertNoError($result);
}
- $session = Horde_Kolab_Session::singleton('wrobel',
- array('password' => 'none'),
- true);
+ $session = Horde_Kolab_Session::singleton(
+ 'wrobel',
+ array('password' => 'none'),
+ true
+ );
$this->assertNoError($session->auth);
$this->assertEquals('wrobel@example.org', $session->user_mail);
try {
- $session = Horde_Kolab_Session::singleton('test',
- array('password' => 'test'),
- true);
+ $session = Horde_Kolab_Session::singleton(
+ 'test',
+ array('password' => 'test'),
+ true
+ );
} catch (Horde_Kolab_Session_Exception $e) {
- $this->assertError($e, 'You are no member of a group that may login on this server.');
+ $this->assertError(
+ $e, 'You are no member of a group that may login on this server.'
+ );
}
// FIXME: Ensure that the session gets overwritten
//$this->assertTrue(empty($session->user_mail));
@@ -198,19 +209,25 @@ class Horde_Kolab_Session_Integration_SessionTest extends Horde_Kolab_Session_Se
$this->assertNoError($result);
}
- $session = Horde_Kolab_Session::singleton('test',
- array('password' => 'test'),
- true);
+ $session = Horde_Kolab_Session::singleton(
+ 'test',
+ array('password' => 'test'),
+ true
+ );
$this->assertNoError($session->auth);
$this->assertEquals('test@example.org', $session->user_mail);
try {
- $session = Horde_Kolab_Session::singleton('wrobel',
- array('password' => 'none'),
- true);
+ $session = Horde_Kolab_Session::singleton(
+ 'wrobel',
+ array('password' => 'none'),
+ true
+ );
} catch (Horde_Kolab_Session_Exception $e) {
- $this->assertError($e, 'You are member of a group that may not login on this server.');
+ $this->assertError(
+ $e, 'You are member of a group that may not login on this server.'
+ );
}
// FIXME: Ensure that the session gets overwritten
//$this->assertTrue(empty($session->user_mail));
diff --git a/framework/Kolab_Session/test/Horde/Kolab/Session/Integration/SingletonTest.php b/framework/Kolab_Session/test/Horde/Kolab/Session/Integration/SingletonTest.php
index ecd608da5..af81445e4 100644
--- a/framework/Kolab_Session/test/Horde/Kolab/Session/Integration/SingletonTest.php
+++ b/framework/Kolab_Session/test/Horde/Kolab/Session/Integration/SingletonTest.php
@@ -55,7 +55,7 @@ class Horde_Kolab_Session_Integration_SingletonTest extends Horde_Kolab_Session_
public function testMethodSingletonHasResultHordekolabsession()
{
$this->assertType(
- 'Horde_Kolab_Session',
+ 'Horde_Kolab_Session_Interface',
Horde_Kolab_Session_Singleton::singleton(
'user', array('password' => 'pass')
)
diff --git a/framework/Kolab_Session/test/Horde/Kolab/Session/Integration/ValidTest.php b/framework/Kolab_Session/test/Horde/Kolab/Session/Integration/ValidTest.php
index 2a0785afb..a4a62411f 100644
--- a/framework/Kolab_Session/test/Horde/Kolab/Session/Integration/ValidTest.php
+++ b/framework/Kolab_Session/test/Horde/Kolab/Session/Integration/ValidTest.php
@@ -41,7 +41,7 @@ class Horde_Kolab_Session_Integration_ValidTest extends Horde_Kolab_Session_Sess
public function testMethodIsvalidHasResultBooleanTrueIfTheSessionIsNotConnectedAndTheCurrentUserIsAnonymous()
{
- $auth = $this->getMock('Horde_Kolab_Session_Auth');
+ $auth = $this->getMock('Horde_Kolab_Session_Auth_Interface');
$auth->expects($this->once())
->method('getCurrentUser')
->will($this->returnValue(''));
@@ -55,7 +55,7 @@ class Horde_Kolab_Session_Integration_ValidTest extends Horde_Kolab_Session_Sess
public function testMethodIsvalidHasResultBooleanFalseIfTheSessionIsNotConnected()
{
- $auth = $this->getMock('Horde_Kolab_Session_Auth');
+ $auth = $this->getMock('Horde_Kolab_Session_Auth_Interface');
$auth->expects($this->once())
->method('getCurrentUser')
->will($this->returnValue('mail@example.org'));
@@ -69,7 +69,7 @@ class Horde_Kolab_Session_Integration_ValidTest extends Horde_Kolab_Session_Sess
public function testMethodIsvalidHasResultBooleanFalseIfTheMailOfTheCurrentUserDoesNotMatchTheCurrentUserOfTheSession()
{
- $auth = $this->getMock('Horde_Kolab_Session_Auth');
+ $auth = $this->getMock('Horde_Kolab_Session_Auth_Interface');
$auth->expects($this->once())
->method('getCurrentUser')
->will($this->returnValue('somebody@example.org'));
@@ -93,7 +93,7 @@ class Horde_Kolab_Session_Integration_ValidTest extends Horde_Kolab_Session_Sess
public function testMethodIsvalidHasResultBooleanTrueIfTheMailOfTheCurrentUserMatchesTheCurrentUserOfTheSessionAndNoNewUserWasSet()
{
- $auth = $this->getMock('Horde_Kolab_Session_Auth');
+ $auth = $this->getMock('Horde_Kolab_Session_Auth_Interface');
$auth->expects($this->once())
->method('getCurrentUser')
->will($this->returnValue('mail@example.org'));
@@ -117,7 +117,7 @@ class Horde_Kolab_Session_Integration_ValidTest extends Horde_Kolab_Session_Sess
public function testMethodIsvalidHasResultBooleanFalseIfTheMailOfTheCurrentUserMatchesTheCurrentUserOfTheSessionAndTheNewUserMatchesNeitherTheCurrentUserMailAndUid()
{
- $auth = $this->getMock('Horde_Kolab_Session_Auth');
+ $auth = $this->getMock('Horde_Kolab_Session_Auth_Interface');
$auth->expects($this->once())
->method('getCurrentUser')
->will($this->returnValue('mail@example.org'));
@@ -141,7 +141,7 @@ class Horde_Kolab_Session_Integration_ValidTest extends Horde_Kolab_Session_Sess
public function testMethodIsvalidHasResultBooleanTrueIfTheMailOfTheCurrentUserMatchesTheCurrentUserOfTheSessionAndTheNewUserMatchesEitherTheCurrentUserMailAndUid()
{
- $auth = $this->getMock('Horde_Kolab_Session_Auth');
+ $auth = $this->getMock('Horde_Kolab_Session_Auth_Interface');
$auth->expects($this->once())
->method('getCurrentUser')
->will($this->returnValue('mail@example.org'));
diff --git a/framework/Kolab_Session/test/Horde/Kolab/Session/SessionTestCase.php b/framework/Kolab_Session/test/Horde/Kolab/Session/SessionTestCase.php
index c74404f09..a8dcee447 100644
--- a/framework/Kolab_Session/test/Horde/Kolab/Session/SessionTestCase.php
+++ b/framework/Kolab_Session/test/Horde/Kolab/Session/SessionTestCase.php
@@ -50,13 +50,13 @@ class Horde_Kolab_Session_SessionTestCase extends PHPUnit_Framework_TestCase
protected function setupStorage()
{
- $this->storage = $this->getMock('Horde_Kolab_Session_Storage');
+ $this->storage = $this->getMock('Horde_Kolab_Session_Storage_Interface');
}
protected function setupFactoryMocks()
{
$this->server = $this->_getMockedComposite();
- $this->session_auth = $this->getMock('Horde_Kolab_Session_Auth');
- $this->session_storage = $this->getMock('Horde_Kolab_Session_Storage');
+ $this->session_auth = $this->getMock('Horde_Kolab_Session_Auth_Interface');
+ $this->session_storage = $this->getMock('Horde_Kolab_Session_Storage_Interface');
}
}
\ No newline at end of file