From: Gunnar Wrobel Date: Wed, 17 Mar 2010 05:23:04 +0000 (+0100) Subject: Condense the factory experiments from Kolab_Session into one factory in Horde_Core. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=0eed026b5dc934d66c5ef8243ecdcb782bd01972;p=horde.git Condense the factory experiments from Kolab_Session into one factory in Horde_Core. --- diff --git a/framework/Auth/lib/Horde/Auth/Kolab.php b/framework/Auth/lib/Horde/Auth/Kolab.php index 0a66c1e36..8f60222d9 100644 --- a/framework/Auth/lib/Horde/Auth/Kolab.php +++ b/framework/Auth/lib/Horde/Auth/Kolab.php @@ -107,7 +107,8 @@ class Horde_Auth_Kolab extends Horde_Auth_Base protected function _authenticate($userId, $credentials) { try { - $session = $this->getSession($userId, $credentials); + $session = $GLOBALS['injector']->getInstance('Horde_Kolab_Session'); + $session->connect($userId, $credentials); } catch (Horde_Kolab_Session_Exception_Badlogin $e) { throw new Horde_Auth_Exception('', Horde_Auth::REASON_BADLOGIN); } catch (Horde_Kolab_Session_Exception $e) { diff --git a/framework/Core/lib/Horde/Core/Factory/KolabSession.php b/framework/Core/lib/Horde/Core/Factory/KolabSession.php new file mode 100644 index 000000000..2b96ad313 --- /dev/null +++ b/framework/Core/lib/Horde/Core/Factory/KolabSession.php @@ -0,0 +1,218 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Core + */ + +/** + * A Horde_Injector:: based Kolab_Session:: factory. + * + * Copyright 2009-2010 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Horde + * @package Core + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Core + */ +class Horde_Core_Factory_KolabSession +{ + /** + * The injector. + * + * @var Horde_Injector + */ + private $_injector; + + /** + * Constructor. + * + * @param array $config Configuration parameters for the session. + * @param Horde_Injector $injector The injector to use. + */ + public function __construct( + Horde_Injector $injector + ) { + $this->_injector = $injector; + $this->_setup(); + } + + /** + * Setup the machinery to create Horde_Kolab_Session objects. + * + * @return NULL + */ + private function _setup() + { + $this->_setupConfiguration(); + $this->_setupAuth(); + $this->_setupStorage(); + } + + /** + * Provide configuration settings for Horde_Kolab_Session. + * + * @return NULL + */ + private function _setupConfiguration() + { + $configuration = array(); + if (!empty($GLOBALS['conf']['kolab']['session'])) { + $configuration = $GLOBALS['conf']['kolab']['session']; + } + $this->_injector->setInstance( + 'Horde_Kolab_Session_Configuration', $configuration + ); + } + + /** + * Setup the machinery to create a Horde_Kolab_Session_Auth handler. + * + * @return NULL + */ + private function _setupAuth() + { + $this->_injector->bindImplementation( + 'Horde_Kolab_Session_Auth_Interface', + 'Horde_Kolab_Session_Auth_Horde' + ); + } + + /** + * Setup the machinery to create a Horde_Kolab_Session_Storage handlers. + * + * @return NULL + */ + private function _setupStorage() + { + $this->_injector->bindFactory( + 'Horde_Kolab_Session_Storage_Interface', + 'Horde_Core_Factory_KolabSession', + 'getStorage' + ); + } + + /** + * Return the session storage driver. + * + * @return Horde_Kolab_Session_Storage The driver for storing sessions. + */ + public function getStorage() + { + $storage = new Horde_Kolab_Session_Storage_Sessionobjects( + Horde_SessionObjects::singleton() + ); + return $storage; + } + + /** + * 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 + ) { + $configuration = $this->_injector->getInstance('Horde_Kolab_Session_Configuration'); + + $validator = new Horde_Kolab_Session_Valid_Base( + $session, $auth + ); + + if (isset($configuration['debug']) || isset($configuration['log'])) { + $validator = new Horde_Kolab_Session_Valid_Decorator_Logged( + $validator, $this->_injector->getInstance('Horde_Log_Logger') + ); + } + + return $validator; + } + + /** + * Validate the given session. + * + * @param Horde_Kolab_Session_Interface $session The session to validate. + * + * @return boolean True if the given session is valid. + */ + public function validate( + Horde_Kolab_Session_Interface $session + ) { + return $this->getSessionValidator( + $session, + $this->_injector->getInstance('Horde_Kolab_Session_Auth_Interface') + )->isValid(); + } + + /** + * Returns a new session handler. + * + * @return Horde_Kolab_Session The concrete Kolab session reference. + */ + public function createSession() + { + $session = new Horde_Kolab_Session_Base( + $this->_injector->getInstance('Horde_Kolab_Server_Composite'), + $this->_injector->getInstance('Horde_Kolab_Session_Configuration') + ); + + //@todo: Fix validation + /** If we created a new session handler it needs to be stored once */ + $session = new Horde_Kolab_Session_Decorator_Stored( + $session, + $this->_injector->getInstance('Horde_Kolab_Session_Storage_Interface') + ); + return $session; + } + + /** + * Return the Horde_Kolab_Session:: instance. + * + * @return Horde_Kolab_Session The session handler. + */ + public function getSession() + { + $storage = $this->_injector->getInstance('Horde_Kolab_Session_Storage_Interface'); + $session = $storage->load(); + + if (empty($session) || !$this->validate($session)) { + $session = $this->createSession(); + } + + $configuration = $this->_injector->getInstance('Horde_Kolab_Session_Configuration'); + + + if (isset($configuration['debug']) || isset($configuration['log'])) { + $session = new Horde_Kolab_Session_Decorator_Logged( + $session, $this->_injector->getInstance('Horde_Log_Logger') + ); + } + + if (isset($configuration['anonymous']['user']) + && isset($configuration['anonymous']['pass']) + ) { + $session = new Horde_Kolab_Session_Decorator_Anonymous( + $session, + $configuration['anonymous']['user'], + $configuration['anonymous']['pass'] + ); + } + + return $session; + } +} diff --git a/framework/Core/lib/Horde/Registry.php b/framework/Core/lib/Horde/Registry.php index d967dbbb2..4484364ad 100644 --- a/framework/Core/lib/Horde/Registry.php +++ b/framework/Core/lib/Horde/Registry.php @@ -239,6 +239,7 @@ class Horde_Registry $injector->addBinder('Horde_Template', new Horde_Core_Binder_Template()); $injector->addBinder('Net_DNS_Resolver', new Horde_Core_Binder_Dns()); $injector->bindFactory('Horde_Kolab_Server_Composite', 'Horde_Core_Factory_KolabServer', 'getComposite'); + $injector->bindFactory('Horde_Kolab_Session', 'Horde_Core_Factory_KolabSession', 'getSession'); $GLOBALS['registry'] = $this; $injector->setInstance('Horde_Registry', $this); diff --git a/framework/Core/package.xml b/framework/Core/package.xml index b09e9b6cc..2412cfbd3 100644 --- a/framework/Core/package.xml +++ b/framework/Core/package.xml @@ -75,6 +75,7 @@ Application Framework. + @@ -115,6 +116,7 @@ Application Framework. + @@ -170,6 +172,14 @@ Application Framework. pear.horde.org + Kolab_Server + pear.horde.org + + + Kolab_Storage + pear.horde.org + + Form pear.horde.org @@ -190,6 +200,7 @@ Application Framework. + @@ -210,6 +221,7 @@ Application Framework. + diff --git a/framework/Core/test/Horde/Core/Factory/KolabSessionTest.php b/framework/Core/test/Horde/Core/Factory/KolabSessionTest.php new file mode 100644 index 000000000..ae0a92132 --- /dev/null +++ b/framework/Core/test/Horde/Core/Factory/KolabSessionTest.php @@ -0,0 +1,154 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Core + */ + +/** + * Require our basic test case definition + */ +require_once dirname(__FILE__) . '/../Autoload.php'; + +/** + * Test the Kolab_Session factory. + * + * Copyright 2009-2010 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Horde + * @package Core + * @author Gunnar Wrobel + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Core + */ +class Horde_Core_Factory_KolabSessionTest extends PHPUnit_Framework_TestCase +{ + private function _getFactory() + { + $GLOBALS['conf']['kolab']['server']['basedn'] = 'test'; + $injector = new Horde_Injector(new Horde_Injector_TopLevel()); + $server_factory = new Horde_Core_Factory_KolabServer($injector); + $factory = new Horde_Core_Factory_KolabSession($injector); + $this->session_auth = $this->getMock('Horde_Kolab_Session_Auth_Interface'); + $this->session_storage = $this->getMock('Horde_Kolab_Session_Storage_Interface'); + $injector->setInstance('Horde_Kolab_Session_Auth_Interface', $this->session_auth); + $injector->setInstance('Horde_Kolab_Session_Storage_Interface', $this->session_storage); + return $factory; + } + + public function testMethodGetvalidatorHasResultHordekolabsessionvalid() + { + $session = $this->getMock('Horde_Kolab_Session_Interface'); + $this->assertType( + 'Horde_Kolab_Session_Valid_Interface', + $this->_getFactory()->getSessionValidator($session, $this->session_auth) + ); + } + + public function testMethodValidateHasResultTrueIfTheSessionIsStillValid() + { + $factory = $this->_getFactory(); + $this->session_auth->expects($this->once()) + ->method('getCurrentUser') + ->will($this->returnValue('mail@example.org')); + $session = $this->getMock('Horde_Kolab_Session_Interface'); + $session->expects($this->once()) + ->method('getMail') + ->will($this->returnValue('mail@example.org')); + $this->assertTrue($factory->validate($session)); + } + + public function testMethodCreatesessionHasResultHordekolabsessionstored() + { + $this->assertType('Horde_Kolab_Session_Decorator_Stored', $this->_getFactory()->createSession()); + } + + public function testMethodGetsessionHasResultHordekolabsessionTheOldSessionIfAnOldSessionWasStoredAndValid() + { + $factory = $this->_getFactory(); + $session = $this->getMock('Horde_Kolab_Session_Interface'); + $session->expects($this->once()) + ->method('getMail') + ->will($this->returnValue('mail@example.org')); + $this->session_storage->expects($this->once()) + ->method('load') + ->will($this->returnValue($session)); + $this->session_auth->expects($this->once()) + ->method('getCurrentUser') + ->will($this->returnValue('mail@example.org')); + $this->assertSame($session, $factory->getSession()); + } + + public function testMethodGetsessionHasResultHordekolabsessionANewSessionIfAnOldSessionWasStoredAndInvalid() + { + $factory = $this->_getFactory(); + $session = $this->getMock('Horde_Kolab_Session_Interface'); + $session->expects($this->once()) + ->method('getMail') + ->will($this->returnValue('mail@example.org')); + $this->session_storage->expects($this->once()) + ->method('load') + ->will($this->returnValue($session)); + $this->session_auth->expects($this->once()) + ->method('getCurrentUser') + ->will($this->returnValue('new@example.org')); + $this->assertTrue($session !== $factory->getSession()); + } + + public function testMethodGetsessionHasResultHordekolabsessionANewSessionIfNoOldSessionExisted() + { + $factory = $this->_getFactory(); + $this->session_storage->expects($this->once()) + ->method('load') + ->will($this->returnValue(false)); + $this->assertType('Horde_Kolab_Session_Interface', $factory->getSession()); + } + + + public function testMethodCreatesessionHasResultHordekolabsessionanonymousIfConfiguredThatWay() + { + $GLOBALS['conf']['kolab']['session']['anonymous']['user'] = 'anonymous'; + $GLOBALS['conf']['kolab']['session']['anonymous']['pass'] = ''; + $this->assertType( + 'Horde_Kolab_Session_Decorator_Anonymous', + $this->_getFactory()->getSession() + ); + } + + public function testMethodCreatesessionHasResultHordekolabsessionloggedIfConfiguredThatWay() + { + $GLOBALS['conf']['kolab']['session']['log'] = true; + $this->assertType( + 'Horde_Kolab_Session_Decorator_Logged', + $this->_getFactory()->getSession() + ); + } + + public function testMethodGetsessionvalidatorHasResultHordekolabsessionvalidloggedIfConfiguredThatWay() + { + $session = $this->getMock('Horde_Kolab_Session_Interface'); + $auth = $this->getMock('Horde_Kolab_Session_Auth_Interface'); + $GLOBALS['conf']['kolab']['session']['log'] = true; + $this->assertType( + 'Horde_Kolab_Session_Valid_Decorator_Logged', + $this->_getFactory()->getSessionValidator($session, $auth) + ); + } + + public function testMethodGetstorageHasresultSessionstorage() + { + $this->assertType( + 'Horde_Kolab_Session_Storage_Interface', + $this->_getFactory()->getStorage() + ); + } +} \ No newline at end of file diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Base.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Base.php deleted file mode 100644 index 412dfbda0..000000000 --- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Base.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 - */ - -/** - * Revives an old Horde_Kolab_Session handler or generates a new one if - * required. - * - * Copyright 2008-2010 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Session - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Session - */ -abstract class Horde_Kolab_Session_Factory_Base -implements Horde_Kolab_Session_Factory_Interface -{ - /** - * 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 - ) { - $validator = new Horde_Kolab_Session_Valid_Base( - $session, $auth - ); - return $validator; - } - - /** - * Validate the given session. - * - * @param Horde_Kolab_Session_Interface $session The session to validate. - * - * @return boolean True if the given session is valid. - */ - public function validate( - Horde_Kolab_Session_Interface $session - ) { - return $this->getSessionValidator( - $session, - $this->getSessionAuth() - )->isValid(); - } - - /** - * Returns a new session handler. - * - * @return Horde_Kolab_Session The concrete Kolab session reference. - */ - public function createSession() - { - $session = new Horde_Kolab_Session_Base( - $this->getServer(), - $this->getSessionConfiguration() - ); - /** If we created a new session handler it needs to be stored once */ - $session = new Horde_Kolab_Session_Decorator_Stored( - $session, - $this->getSessionStorage() - ); - return $session; - } - - /** - * Returns either a reference to a session handler with data retrieved from - * the session or a new session handler. - * - * @return Horde_Kolab_Session The concrete Kolab session reference. - */ - public function getSession() - { - $storage = $this->getSessionStorage(); - $session = $storage->load(); - - if (!empty($session) && $this->validate($session)) { - return $session; - } - $session = $this->createSession(); - return $session; - } -} diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Configuration.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Configuration.php deleted file mode 100644 index 1c00556c0..000000000 --- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Configuration.php +++ /dev/null @@ -1,177 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Session - */ - -/** - * A factory that receives all required details via configuration parameters. - * - * Copyright 2009-2010 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Session - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Session - */ -class Horde_Kolab_Session_Factory_Configuration -implements Horde_Kolab_Session_Factory_Interface -{ - /** - * Configuration parameters for the session. - * - * @var array - */ - private $_configuration; - - /** - * The factory used for creating the instances. - * - * @var Horde_Kolab_Session_Factory - */ - private $_factory; - - /** - * Constructor. - * - * @param array $config Configuration parameters for the session. - */ - public function __construct(array $config) - { - $this->_configuration = $config; - - if (isset($config['server'])) { - $server_configuration = $config['server']; - } elseif (isset($config['ldap'])) { - $server_configuration = $config['ldap']; - } else { - throw new Horde_Kolab_Session_Exception( - 'The Kolab server configuration is missing!' - ); - } - - $server_factory = new Horde_Kolab_Server_Factory_Configuration( - $server_configuration - ); - - $factory = new Horde_Kolab_Session_Factory_Default( - $config, $server_factory - ); - - if (isset($config['logger'])) { - $factory = new Horde_Kolab_Session_Factory_Decorator_Logged( - $factory, $config['logger'] - ); - } - - if (isset($config['session']['anonymous']['user']) - && isset($config['session']['anonymous']['pass']) - ) { - $factory = new Horde_Kolab_Session_Factory_Decorator_Anonymous( - $factory, - $config['session']['anonymous']['user'], - $config['session']['anonymous']['pass'] - ); - } - - $this->_factory = $factory; - } - - /** - * 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_Interface $session, - Horde_Kolab_Session_Auth_Interface $auth - ) { - return $this->_factory->getSessionValidator($session, $auth); - } - - /** - * Validate the given session. - * - * @return boolean True if the given session is valid. - */ - public function validate( - Horde_Kolab_Session_Interface $session - ) { - return $this->_factory->validate($session); - } - - /** - * Returns a new session handler. - * - * @return Horde_Kolab_Session The concrete Kolab session reference. - */ - public function createSession() - { - return $this->_factory->createSession(); - } - - /** - * Returns either a reference to a session handler with data retrieved from - * the session or a new session handler. - * - * @return Horde_Kolab_Session The concrete Kolab session reference. - */ - public function getSession() - { - return $this->_factory->getSession(); - } -} diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Constructor.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Constructor.php deleted file mode 100644 index be70c1c50..000000000 --- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Constructor.php +++ /dev/null @@ -1,123 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Session - */ - -/** - * A factory that receives all required details via the factory constructor. - * - * Copyright 2009-2010 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Session - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Session - */ -class Horde_Kolab_Session_Factory_Constructor -extends Horde_Kolab_Session_Factory_Base -{ - /** - * The connection to the Kolab user db. - * - * @var Horde_Kolab_Server_Composite_Interface - */ - private $_server; - - /** - * The auth handler for the session. - * - * @var Horde_Kolab_Session_Auth_Interface - */ - private $_auth; - - /** - * Configuration parameters for the session. - * - * @var array - */ - private $_configuration; - - /** - * The storage handler for the session. - * - * @var Horde_Kolab_Session_Storage_Interface - */ - private $_storage; - - /** - * Constructor. - * - * @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 $server, - Horde_Kolab_Session_Auth_Interface $auth, - array $config, - Horde_Kolab_Session_Storage_Interface $storage - ) { - $this->_server = $server; - $this->_auth = $auth; - $this->_configuration = $config; - $this->_storage = $storage; - } - - /** - * Return the kolab user db connection. - * - * @return Horde_Kolab_Server The server connection. - */ - public function getServer() - { - return $this->_server; - } - - /** - * Return the auth handler for sessions. - * - * @return Horde_Kolab_Session_Auth_Interface The authentication handler. - */ - public function getSessionAuth() - { - return $this->_auth; - } - - /** - * Return the configuration parameters for the session. - * - * @return array The configuration values. - */ - public function getSessionConfiguration() - { - return $this->_configuration; - } - - /** - * Return the session storage driver. - * - * @return Horde_Kolab_Session_Storage_Interface The driver for storing sessions. - */ - public function getSessionStorage() - { - return $this->_storage; - } -} 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 deleted file mode 100644 index f49e5280c..000000000 --- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Decorator/Anonymous.php +++ /dev/null @@ -1,163 +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-2010 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Session - * @author Gunnar Wrobel - * @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. - * - * @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. - * - * @return boolean True if the given session is valid. - */ - public function validate( - Horde_Kolab_Session_Interface $session - ) { - return $this->_factory->validate($session); - } - - /** - * Returns a new session handler. - * - * @return Horde_Kolab_Session_Interface The concrete Kolab session reference. - */ - public function createSession() - { - $session = $this->_factory->createSession(); - $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. - * - * @return Horde_Kolab_Session_Interface The concrete Kolab session reference. - */ - public function getSession() - { - return $this->_factory->getSession(); - } -} 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 deleted file mode 100644 index 17b7c5122..000000000 --- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Decorator/Logged.php +++ /dev/null @@ -1,160 +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-2010 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Session - * @author Gunnar Wrobel - * @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. - * - * @return boolean True if the given session is valid. - */ - public function validate( - Horde_Kolab_Session_Interface $session - ) { - return $this->_factory->validate($session); - } - - /** - * Returns a new session handler. - * - * @return Horde_Kolab_Session_Interface The concrete Kolab session reference. - */ - public function createSession() - { - $session = $this->_factory->createSession(); - $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() - { - return $this->_factory->getSession(); - } -} diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Default.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Default.php deleted file mode 100644 index a099c31c3..000000000 --- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Default.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 factory implementing the default policy. - * - * Copyright 2008-2010 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Session - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Session - */ -class Horde_Kolab_Session_Factory_Default -extends Horde_Kolab_Session_Factory_Base -{ - /** - * Configuration parameters for the session. - * - * @var array - */ - private $_configuration; - - /** - * The server factory used by this instance. - * - * @var array - */ - private $_server_factory; - - /** - * Constructor. - * - * @param array $config Configuration parameters for - * the session. - * @param Horde_Kolab_Server_Factory $factory The factory for the Kolab user - * db connection. - */ - public function __construct( - array $config, - Horde_Kolab_Server_Factory_Interface $factory - ) { - $this->_configuration = $config; - $this->_server_factory = $factory; - } - - /** - * Return the kolab user db connection. - * - * @return Horde_Kolab_Server The server connection. - */ - public function getServer() - { - return $this->_server_factory->getComposite(); - } - - /** - * Return the auth handler for sessions. - * - * @return Horde_Kolab_Session_Auth The authentication handler. - */ - public function getSessionAuth() - { - $auth = new Horde_Kolab_Session_Auth_Horde(); - return $auth; - } - - /** - * Return the configuration parameters for the session. - * - * @return array The configuration values. - */ - public function getSessionConfiguration() - { - return $this->_configuration; - } - - /** - * Return the session storage driver. - * - * @return Horde_Kolab_Session_Storage The driver for storing sessions. - */ - public function getSessionStorage() - { - $storage = new Horde_Kolab_Session_Storage_Sessionobjects( - Horde_SessionObjects::singleton() - ); - return $storage; - } -} diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Injector.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Injector.php deleted file mode 100644 index 9ee9a83ab..000000000 --- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Injector.php +++ /dev/null @@ -1,192 +0,0 @@ - - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Session - */ - -/** - * A factory using a Horde_Injector instance. - * - * Copyright 2009-2010 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Session - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Session - */ -class Horde_Kolab_Session_Factory_Injector -extends Horde_Kolab_Session_Factory_Base -{ - /** - * Configuration parameters for the session. - * - * @var array - */ - private $_configuration; - - /** - * The injector. - * - * @var Horde_Injector - */ - private $_injector; - - /** - * Constructor. - * - * @param array $config Configuration parameters for the session. - * @param Horde_Injector $injector The injector to use. - */ - public function __construct( - array $config, - Horde_Injector $injector - ) { - $this->_configuration = $config; - $this->_injector = $injector; - $this->_setup(); - } - - /** - * Setup the machinery to create Horde_Kolab_Session objects. - * - * @return NULL - */ - private function _setup() - { - $this->_setupAuth(); - $this->_setupStorage(); - $this->_setupConfiguration(); - $this->_setupSession(); - } - - /** - * Setup the machinery to create a Horde_Kolab_Session_Auth handler. - * - * @return NULL - */ - private function _setupAuth() - { - $this->_injector->bindImplementation( - 'Horde_Kolab_Session_Auth', - 'Horde_Kolab_Session_Auth_Horde' - ); - } - - /** - * Setup the machinery to create a Horde_Kolab_Session_Storage handlers. - * - * @return NULL - */ - private function _setupStorage() - { - $this->_injector->bindFactory( - 'Horde_Kolab_Session_Storage', - 'Horde_Kolab_Session_Factory_Injector', - 'getStorage' - ); - } - - /** - * Provide configuration settings for Horde_Kolab_Session. - * - * @return NULL - */ - private function _setupConfiguration() - { - $this->_injector->setInstance( - 'Horde_Kolab_Session_Configuration', $this->_configuration - ); - } - - /** - * Setup the machinery to create a Horde_Kolab_Session handler. - * - * @return NULL - */ - private function _setupSession() - { - $this->_injector->bindFactory( - 'Horde_Kolab_Session', - 'Horde_Kolab_Session_Factory_Injector', - 'getSession' - ); - } - - /** - * A helper method to seed the injector with a Horde_Kolab_Server factory - * definition. This should usually be done by an external setup method - * before constructing the session injcetion factory. - * - * @param Horde_Injector $injector The injector to seed with the mock - * configuration. - * - * @return NULL - */ - static public function setupMockServerFactory( - Horde_Injector $injector - ) { - Horde_Kolab_Server_Factory_Injector::setup( - 'Horde_Kolab_Server_Factory_Connection_Mock', - array('basedn' => ''), - $injector - ); - /** Setup the injector by constructing the server factory */ - $injector->getInstance('Horde_Kolab_Server_Factory_Injector'); - } - - /** - * Return the kolab user db connection. - * - * @return Horde_Kolab_Server The server connection. - */ - public function getServer() - { - return $this->_injector->getInstance( - 'Horde_Kolab_Server_Composite_Interface' - ); - } - - /** - * Return the auth handler for sessions. - * - * @return Horde_Kolab_Session_Auth The authentication handler. - */ - public function getSessionAuth() - { - return $this->_injector->getInstance('Horde_Kolab_Session_Auth'); - } - - /** - * Return the configuration parameters for the session. - * - * @return array The configuration values. - */ - public function getSessionConfiguration() - { - return $this->_injector->getInstance('Horde_Kolab_Session_Configuration'); - } - - /** - * Return the session storage driver. - * - * @return Horde_Kolab_Session_Storage The driver for storing sessions. - */ - public function getSessionStorage() - { - $storage = new Horde_Kolab_Session_Storage_Sessionobjects( - Horde_SessionObjects::singleton() - ); - return $storage; - } -} diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Interface.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Interface.php deleted file mode 100644 index c9b757cb5..000000000 --- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Interface.php +++ /dev/null @@ -1,97 +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-2010 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Session - * @author Gunnar Wrobel - * @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. - * - * @param Horde_Kolab_Session_Interface $session The session to validate. - * - * @return boolean True if the given session is valid. - */ - public function validate( - Horde_Kolab_Session_Interface $session - ); - - /** - * Returns a new session handler. - * - * @return Horde_Kolab_Session_Interface The concrete Kolab session reference. - */ - public function createSession(); - - /** - * Returns either a reference to a session handler with data retrieved from - * the session or a new session handler. - * - * @return Horde_Kolab_Session_Interface The concrete Kolab session reference. - */ - public function getSession(); -} diff --git a/framework/Kolab_Session/package.xml b/framework/Kolab_Session/package.xml index 000b6933d..abfdcbb38 100644 --- a/framework/Kolab_Session/package.xml +++ b/framework/Kolab_Session/package.xml @@ -61,18 +61,6 @@ http://pear.php.net/dtd/package-2.0.xsd"> - - - - - - - - - - - - @@ -108,17 +96,6 @@ http://pear.php.net/dtd/package-2.0.xsd"> - - - - - - - - - - - @@ -133,7 +110,6 @@ http://pear.php.net/dtd/package-2.0.xsd"> - @@ -191,14 +167,6 @@ http://pear.php.net/dtd/package-2.0.xsd"> - - - - - - - - @@ -215,20 +183,12 @@ http://pear.php.net/dtd/package-2.0.xsd"> - - - - - - - - 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 deleted file mode 100644 index 464b574d0..000000000 --- a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/BaseTest.php +++ /dev/null @@ -1,125 +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 base factory definition via the constructor based factory. - * - * Copyright 2009-2010 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Session - * @author Gunnar Wrobel - * @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_BaseTest extends Horde_Kolab_Session_SessionTestCase -{ - public function setUp() - { - parent::setUp(); - $this->setupFactoryMocks(); - $this->user = $this->getMock( - 'Horde_Kolab_Server_Object_Hash', array(), array(), '', false, false - ); - } - - public function testMethodGetvalidatorHasResultHordekolabsesessionvalid() - { - $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_Interface', - $factory->getSessionValidator($session, $this->session_auth) - ); - } - - public function testMethodValidateHasResultTrueIfTheSessionIsStillValid() - { - $this->session_auth->expects($this->once()) - ->method('getCurrentUser') - ->will($this->returnValue('mail@example.org')); - $session = $this->getMock('Horde_Kolab_Session_Interface'); - $session->expects($this->once()) - ->method('getMail') - ->will($this->returnValue('mail@example.org')); - $factory = new Horde_Kolab_Session_Factory_Constructor( - $this->server, $this->session_auth, array(), $this->session_storage - ); - $this->assertTrue($factory->validate($session)); - } - - public function testMethodCreatesessionHasResultHordekolabsessionstored() - { - $factory = new Horde_Kolab_Session_Factory_Constructor( - $this->server, $this->session_auth, array(), $this->session_storage - ); - $this->assertType('Horde_Kolab_Session_Decorator_Stored', $factory->createSession()); - } - - public function testMethodGetsessionHasResultHordekolabsessionTheOldSessionIfAnOldSessionWasStoredAndValid() - { - $session = $this->getMock('Horde_Kolab_Session_Interface'); - $session->expects($this->once()) - ->method('getMail') - ->will($this->returnValue('mail@example.org')); - $this->session_storage->expects($this->once()) - ->method('load') - ->will($this->returnValue($session)); - $this->session_auth->expects($this->once()) - ->method('getCurrentUser') - ->will($this->returnValue('mail@example.org')); - $factory = new Horde_Kolab_Session_Factory_Constructor( - $this->server, $this->session_auth, array(), $this->session_storage - ); - $this->assertSame($session, $factory->getSession()); - } - - public function testMethodGetsessionHasResultHordekolabsessionANewSessionIfAnOldSessionWasStoredAndInvalid() - { - $session = $this->getMock('Horde_Kolab_Session_Interface'); - $session->expects($this->once()) - ->method('getMail') - ->will($this->returnValue('mail@example.org')); - $this->session_storage->expects($this->once()) - ->method('load') - ->will($this->returnValue($session)); - $this->session_auth->expects($this->once()) - ->method('getCurrentUser') - ->will($this->returnValue('new@example.org')); - $factory = new Horde_Kolab_Session_Factory_Constructor( - $this->server, $this->session_auth, array(), $this->session_storage - ); - $this->assertTrue($session !== $factory->getSession()); - } - - public function testMethodGetsessionHasResultHordekolabsessionANewSessionIfNoOldSessionExisted() - { - $this->session_storage->expects($this->once()) - ->method('load') - ->will($this->returnValue(false)); - $factory = new Horde_Kolab_Session_Factory_Constructor( - $this->server, $this->session_auth, array(), $this->session_storage - ); - $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 deleted file mode 100644 index 2b8d62823..000000000 --- a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/ConfigurationTest.php +++ /dev/null @@ -1,231 +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 configuration based factory. - * - * Copyright 2009-2010 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Session - * @author Gunnar Wrobel - * @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_ConfigurationTest extends Horde_Kolab_Session_SessionTestCase -{ - public function setUp() - { - parent::setUp(); - $this->setupLogger(); - } - - public function testMethodConstructThrowsExceptionIfTheServerConfigurationIsMissing() - { - try { - $factory = new Horde_Kolab_Session_Factory_Configuration(array()); - $this->fail('No exception!'); - } catch (Horde_Kolab_Session_Exception $e) { - $this->assertEquals( - 'The Kolab server configuration is missing!', - $e->getMessage() - ); - } - } - - public function testMethodCreatesessionHasResultHordekolabsessionanonymousIfConfiguredThatWay() - { - $factory = new Horde_Kolab_Session_Factory_Configuration( - array( - 'session' => array( - 'anonymous' => array( - 'user' => 'anonymous', - 'pass' => '' - ) - ), - 'server' => array( - 'basedn' => '' - ) - ) - ); - $this->assertType( - 'Horde_Kolab_Session_Decorator_Anonymous', - $factory->createSession() - ); - } - - public function testMethodCreatesessionHasResultHordekolabsessionloggedIfConfiguredThatWay() - { - $factory = new Horde_Kolab_Session_Factory_Configuration( - array( - 'logger' => $this->logger, - 'server' => array( - 'basedn' => '' - ) - ) - ); - $this->assertType( - 'Horde_Kolab_Session_Decorator_Logged', - $factory->createSession() - ); - } - - public function testMethodGetsessionvalidatorHasResultHordekolabsessionvalidloggedIfConfiguredThatWay() - { - $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, - 'server' => array( - 'basedn' => '' - ) - ) - ); - $this->assertType( - 'Horde_Kolab_Session_Valid_Decorator_Logged', - $factory->getSessionValidator($session, $auth) - ); - } - - public function testMethodGetserverHasResultServercomposite() - { - $factory = new Horde_Kolab_Session_Factory_Configuration( - array( - 'server' => array( - 'basedn' => '' - ) - ) - ); - $this->assertType( - 'Horde_Kolab_Server_Composite', - $factory->getServer() - ); - } - - public function testMethodGetsessionauthHasResultSessionauth() - { - $factory = new Horde_Kolab_Session_Factory_Configuration( - array( - 'server' => array( - 'basedn' => '' - ) - ) - ); - $this->assertType( - 'Horde_Kolab_Session_Auth_Interface', - $factory->getSessionAuth() - ); - } - - public function testMethodGetsessionconfigurationHasResultArray() - { - $factory = new Horde_Kolab_Session_Factory_Configuration( - array( - 'server' => array( - 'basedn' => '' - ) - ) - ); - $this->assertType('array', $factory->getSessionConfiguration()); - } - - public function testMethodGetsessionstorageHasresultSessionstorage() - { - $factory = new Horde_Kolab_Session_Factory_Configuration( - array( - 'server' => array( - 'basedn' => '' - ) - ) - ); - $this->assertType( - 'Horde_Kolab_Session_Storage_Interface', - $factory->getSessionStorage() - ); - } - - public function testMethodGetsessionvalidatorHasResultSessionvalid() - { - $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( - 'basedn' => '' - ) - ) - ); - $this->assertType( - 'Horde_Kolab_Session_Valid_Interface', - $factory->getSessionValidator($session, $auth) - ); - } - - public function testMethodValidateHasResultBooleanTrueIfTheSessionIsStillValid() - { - $session = $this->getMock('Horde_Kolab_Session_Interface'); - $factory = new Horde_Kolab_Session_Factory_Configuration( - array( - 'server' => array( - 'basedn' => '' - ) - ) - ); - $this->assertTrue($factory->validate($session, '')); - } - - public function testMethodCreatesessionHasResultSession() - { - $factory = new Horde_Kolab_Session_Factory_Configuration( - array( - 'server' => array( - 'basedn' => '' - ) - ) - ); - $this->assertType('Horde_Kolab_Session_Interface', $factory->createSession()); - } - - public function testMethodGetsessionHasResultSession() - { - $factory = new Horde_Kolab_Session_Factory_Configuration( - array( - 'server' => array( - 'mock' => true, - 'basedn' => '', - 'data' => array( - 'dn=user' => array( - 'dn' => 'dn=user', - 'data' => array( - 'uid' => array(''), - 'mail' => array('user@example.org'), - 'userPassword' => array(''), - 'objectClass' => array('top', 'kolabInetOrgPerson'), - ) - ) - ) - ) - ) - ); - $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 deleted file mode 100644 index 910dc434e..000000000 --- a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/ConstructorTest.php +++ /dev/null @@ -1,72 +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 constructor based factory. - * - * Copyright 2009-2010 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Session - * @author Gunnar Wrobel - * @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_ConstructorTest extends Horde_Kolab_Session_SessionTestCase -{ - public function setUp() - { - parent::setUp(); - $this->setupFactoryMocks(); - } - - public function testMethodGetserverHasResultHordekolabserver() - { - $factory = new Horde_Kolab_Session_Factory_Constructor( - $this->server, $this->session_auth, array(), $this->session_storage - ); - $this->assertType('Horde_Kolab_Server_Composite', $factory->getServer()); - } - - public function testMethodGetsessionauthHasResultHordekolabsessionauth() - { - $factory = new Horde_Kolab_Session_Factory_Constructor( - $this->server, $this->session_auth, array(), $this->session_storage - ); - $this->assertType('Horde_Kolab_Session_Auth_Interface', $factory->getSessionAuth()); - } - - public function testMethodGetsessionconfigurationHasResultArray() - { - $factory = new Horde_Kolab_Session_Factory_Constructor( - $this->server, $this->session_auth, array(), $this->session_storage - ); - $this->assertType('array', $factory->getSessionConfiguration()); - } - - public function testMethodGetsessionstorageHasResultHordekolabsessionstorage() - { - $factory = new Horde_Kolab_Session_Factory_Constructor( - $this->server, $this->session_auth, array(), $this->session_storage - ); - $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 deleted file mode 100644 index 52aa83d91..000000000 --- a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/Decorator/AnonymousTest.php +++ /dev/null @@ -1,165 +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-2010 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Session - * @author Gunnar Wrobel - * @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 deleted file mode 100644 index a81d6ce25..000000000 --- a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/Decorator/LoggedTest.php +++ /dev/null @@ -1,189 +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-2010 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Session - * @author Gunnar Wrobel - * @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 deleted file mode 100644 index a56a6b5c7..000000000 --- a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/DefaultTest.php +++ /dev/null @@ -1,77 +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 default factory. - * - * Copyright 2009-2010 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Session - * @author Gunnar Wrobel - * @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_DefaultTest extends Horde_Kolab_Session_SessionTestCase -{ - public function testMethodGetserverHasResultHordekolabserver() - { - $server = $this->getMock('Horde_Kolab_Server_Composite_Interface'); - $server_factory = $this->getMock('Horde_Kolab_Server_Factory_Interface'); - $server_factory->expects($this->once()) - ->method('getComposite') - ->will($this->returnValue($server)); - $factory = new Horde_Kolab_Session_Factory_Default( - array('server' => array()), - $server_factory - ); - $this->assertType( - 'Horde_Kolab_Server_Composite_Interface', $factory->getServer() - ); - } - - public function testMethodGetsessionauthHasResultHordekolabsessionauth() - { - $factory = new Horde_Kolab_Session_Factory_Default( - array('server' => array()), - $this->getMock('Horde_Kolab_Server_Factory_Interface') - ); - $this->assertType('Horde_Kolab_Session_Auth_Interface', $factory->getSessionAuth()); - } - - public function testMethodGetsessionconfigurationHasResultArray() - { - $factory = new Horde_Kolab_Session_Factory_Default( - array('server' => array()), - $this->getMock('Horde_Kolab_Server_Factory_Interface') - ); - $this->assertType('array', $factory->getSessionConfiguration()); - } - - public function testMethodGetsessionstorageHasResultHordekolabsessionstorage() - { - $factory = new Horde_Kolab_Session_Factory_Default( - array('server' => array()), - $this->getMock('Horde_Kolab_Server_Factory_Interface') - ); - $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 deleted file mode 100644 index dae05f594..000000000 --- a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/InjectorTest.php +++ /dev/null @@ -1,72 +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 injector based factory. - * - * Copyright 2009-2010 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Session - * @author Gunnar Wrobel - * @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_InjectorTest extends Horde_Kolab_Session_SessionTestCase -{ - public function setUp() - { - $this->injector = new Horde_Injector(new Horde_Injector_TopLevel()); - Horde_Kolab_Session_Factory_Injector::setupMockServerFactory($this->injector); - } - - public function testMethodGetserverHasResultHordekolabserver() - { - $factory = new Horde_Kolab_Session_Factory_Injector( - array('server' => array()), $this->injector - ); - $this->assertType('Horde_Kolab_Server_Composite_Interface', $factory->getServer()); - } - - public function testMethodGetsessionauthHasResultHordekolabsessionauth() - { - $factory = new Horde_Kolab_Session_Factory_Injector( - array('server' => array()), $this->injector - ); - $this->assertType('Horde_Kolab_Session_Auth_Interface', $factory->getSessionAuth()); - } - - public function testMethodGetsessionconfigurationHasResultArray() - { - $factory = new Horde_Kolab_Session_Factory_Injector( - array('server' => array()), $this->injector - ); - $this->assertType('array', $factory->getSessionConfiguration()); - } - - public function testMethodGetsessionstorageHasResultHordekolabsessionstorage() - { - $factory = new Horde_Kolab_Session_Factory_Injector( - array('server' => array()), $this->injector - ); - $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/Integration/SingletonTest.php b/framework/Kolab_Session/test/Horde/Kolab/Session/Integration/SingletonTest.php deleted file mode 100644 index d74af653f..000000000 --- a/framework/Kolab_Session/test/Horde/Kolab/Session/Integration/SingletonTest.php +++ /dev/null @@ -1,75 +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 Kolab session singleton pattern. - * - * Copyright 2009-2010 The Horde Project (http://www.horde.org/) - * - * See the enclosed file COPYING for license information (LGPL). If you - * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. - * - * @category Kolab - * @package Kolab_Session - * @author Gunnar Wrobel - * @license http://www.fsf.org/copyleft/lgpl.html LGPL - * @link http://pear.horde.org/index.php?package=Kolab_Session - */ -class Horde_Kolab_Session_Integration_SingletonTest extends Horde_Kolab_Session_SessionTestCase -{ - public function setUp() - { - global $conf; - - /** Provide a minimal configuration for the server */ - $conf['kolab']['ldap']['basedn'] = 'dc=test'; - $conf['kolab']['ldap']['mock'] = true; - $conf['kolab']['ldap']['data'] = array( - 'dn=user,dc=test' => array( - 'dn' => 'dn=user,dc=test', - 'data' => array( - 'uid' => array('user'), - 'mail' => array('user@example.org'), - 'userPassword' => array('pass'), - 'objectClass' => array('top', 'kolabInetOrgPerson'), - ) - ) - ); - } - - public function testMethodSingletonHasResultHordekolabsession() - { - $this->assertType( - 'Horde_Kolab_Session_Interface', - Horde_Kolab_Session_Singleton::singleton( - 'user', array('password' => 'pass') - ) - ); - } - - public function testMethodSingletonHasResultHordekolabsessionAlwaysTheSameIfTheSessionIsValid() - { - $session1 = Horde_Kolab_Session_Singleton::singleton( - 'user', array('password' => 'pass') - ); - $session2 = Horde_Kolab_Session_Singleton::singleton( - 'user', array('password' => 'pass') - ); - $this->assertSame($session1, $session2); - } -} \ No newline at end of file