From 3cbde600ec2d9fe2d5f8cd40c7d4d9dc8c2a75c6 Mon Sep 17 00:00:00 2001 From: Gunnar Wrobel Date: Tue, 16 Mar 2010 10:22:54 +0100 Subject: [PATCH] Fix the API for connecting the session with a user. --- .../Kolab_Session/lib/Horde/Kolab/Session/Base.php | 14 ++- .../Horde/Kolab/Session/Decorator/Anonymous.php | 15 ++- .../lib/Horde/Kolab/Session/Decorator/Logged.php | 9 +- .../lib/Horde/Kolab/Session/Decorator/Stored.php | 9 +- .../lib/Horde/Kolab/Session/Factory/Base.php | 25 ++--- .../Horde/Kolab/Session/Factory/Configuration.php | 25 ++--- .../Horde/Kolab/Session/Factory/Constructor.php | 2 +- .../Kolab/Session/Factory/Decorator/Anonymous.php | 24 ++--- .../Kolab/Session/Factory/Decorator/Logged.php | 17 ++- .../lib/Horde/Kolab/Session/Factory/Interface.php | 17 +-- .../lib/Horde/Kolab/Session/Interface.php | 7 +- .../test/Horde/Kolab/Session/Class/BaseTest.php | 116 ++++++++++++--------- .../Session/Class/Decorator/AnonymousTest.php | 8 +- .../Horde/Kolab/Session/Class/Factory/BaseTest.php | 18 ---- .../Session/Class/Factory/ConfigurationTest.php | 2 +- .../Session/Class/Factory/ConstructorTest.php | 2 +- .../Kolab/Session/Integration/AnonymousTest.php | 2 +- .../Horde/Kolab/Session/Integration/ValidTest.php | 20 ++-- .../test/Horde/Kolab/Session/SessionTestCase.php | 4 +- 19 files changed, 143 insertions(+), 193 deletions(-) diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Base.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Base.php index 43e377e6d..66d5e88a2 100644 --- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Base.php +++ b/framework/Kolab_Session/lib/Horde/Kolab/Session/Base.php @@ -113,18 +113,14 @@ class Horde_Kolab_Session_Base implements Horde_Kolab_Session_Interface /** * Constructor. * - * @param string $user_id The session will be setup for the user - * with this ID. * @param Horde_Kolab_Server $server The connection to the Kolab user * database. * @param array $params Kolab configuration settings. */ public function __construct( - $user_id, - Horde_Kolab_Server_Composite_Interface $server, + Horde_Kolab_Server_Composite $server, array $params ) { - $this->_user_id = $user_id; $this->_server = $server; $this->_params = $params; } @@ -132,15 +128,17 @@ class Horde_Kolab_Session_Base implements 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. + * @param string $user_id The user ID to connect with. + * @param array $credentials An array of login credentials. For Kolab, + * this must contain a "password" entry. * * @return NULL * * @throws Horde_Kolab_Session_Exception If the connection failed. */ - public function connect(array $credentials = null) + public function connect($user_id = null, array $credentials = null) { + $this->_user_id = $user_id; if (isset($credentials['password'])) { $password = $credentials['password']; } else { diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Decorator/Anonymous.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Decorator/Anonymous.php index bc75fc1f0..a1d389b27 100644 --- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Decorator/Anonymous.php +++ b/framework/Kolab_Session/lib/Horde/Kolab/Session/Decorator/Anonymous.php @@ -78,21 +78,20 @@ implements 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. + * @param string $user_id The user ID to connect with. + * @param array $credentials An array of login credentials. For Kolab, + * this must contain a "password" entry. * * @return NULL * * @throws Horde_Kolab_Session_Exception If the connection failed. */ - public function connect(array $credentials = null) + public function connect($user_id = null, 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)); + if ($user_id === null && $credentials === null) { + $this->_session->connect($this->_anonymous_id, array('password' => $this->_anonymous_pass)); } else { - $this->_session->connect($credentials); + $this->_session->connect($user_id, $credentials); } } diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Decorator/Logged.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Decorator/Logged.php index 88ffbe981..9fa045a5a 100644 --- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Decorator/Logged.php +++ b/framework/Kolab_Session/lib/Horde/Kolab/Session/Decorator/Logged.php @@ -62,17 +62,18 @@ implements 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. + * @param string $user_id The user ID to connect with. + * @param array $credentials An array of login credentials. For Kolab, + * this must contain a "password" entry. * * @return NULL * * @throws Horde_Kolab_Session_Exception If the connection failed. */ - public function connect(array $credentials = null) + public function connect($user_id = null, array $credentials = null) { try { - $this->_session->connect($credentials); + $this->_session->connect($user_id, $credentials); $this->_logger->info( sprintf( "Connected Kolab session for \"%s\".", diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Decorator/Stored.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Decorator/Stored.php index bcb610cb8..55c128692 100644 --- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Decorator/Stored.php +++ b/framework/Kolab_Session/lib/Horde/Kolab/Session/Decorator/Stored.php @@ -76,14 +76,15 @@ implements 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. + * @param string $user_id The user ID to connect with. + * @param array $credentials An array of login credentials. For Kolab, + * this must contain a "password" entry. * * @return NULL */ - public function connect(array $credentials = null) + public function connect($user_id = null, array $credentials = null) { - $this->_session->connect($credentials); + $this->_session->connect($user_id, $credentials); $this->_connected = true; } 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 1ef245762..412dfbda0 100644 --- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Base.php +++ b/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Base.php @@ -52,33 +52,27 @@ implements Horde_Kolab_Session_Factory_Interface /** * 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. + * @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, - $user = null + Horde_Kolab_Session_Interface $session ) { return $this->getSessionValidator( $session, $this->getSessionAuth() - )->isValid($user); + )->isValid(); } /** * 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) + public function createSession() { $session = new Horde_Kolab_Session_Base( - $user, $this->getServer(), $this->getSessionConfiguration() ); @@ -94,22 +88,17 @@ implements Horde_Kolab_Session_Factory_Interface * 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) + public function getSession() { $storage = $this->getSessionStorage(); $session = $storage->load(); - if (!empty($session) && $this->validate($session, $user)) { + if (!empty($session) && $this->validate($session)) { return $session; } - $session = $this->createSession($user); - $session->connect($credentials); + $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 index 2e3bc334f..1c00556c0 100644 --- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Configuration.php +++ b/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Configuration.php @@ -146,41 +146,32 @@ implements Horde_Kolab_Session_Factory_Interface /** * 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_Interface $session, $user = null) - { - return $this->_factory->validate($session, $user); + public function validate( + Horde_Kolab_Session_Interface $session + ) { + return $this->_factory->validate($session); } /** * 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) + public function createSession() { - return $this->_factory->createSession($user); + return $this->_factory->createSession(); } /** * 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) + public function getSession() { - return $this->_factory->getSession($user, $credentials); + 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 index f06f2f4d1..be70c1c50 100644 --- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Constructor.php +++ b/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Constructor.php @@ -70,7 +70,7 @@ extends Horde_Kolab_Session_Factory_Base * for the session. */ public function __construct( - Horde_Kolab_Server_Composite_Interface $server, + Horde_Kolab_Server_Composite $server, Horde_Kolab_Session_Auth_Interface $auth, array $config, Horde_Kolab_Session_Storage_Interface $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 index 7e8acddbc..f49e5280c 100644 --- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Decorator/Anonymous.php +++ b/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Decorator/Anonymous.php @@ -111,9 +111,6 @@ 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. */ @@ -128,28 +125,23 @@ implements Horde_Kolab_Session_Factory_Interface * 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 + Horde_Kolab_Session_Interface $session ) { - return $this->_factory->validate($session, $user); + return $this->_factory->validate($session); } /** * 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) + public function createSession() { - $session = $this->_factory->createSession($user); + $session = $this->_factory->createSession(); $session = new Horde_Kolab_Session_Decorator_Anonymous( $session, $this->_anonymous_id, @@ -162,14 +154,10 @@ implements Horde_Kolab_Session_Factory_Interface * 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) + public function getSession() { - return $this->_factory->getSession($user, $credentials); + 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 index 7f2b996de..17b7c5122 100644 --- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Decorator/Logged.php +++ b/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Decorator/Logged.php @@ -120,28 +120,23 @@ implements Horde_Kolab_Session_Factory_Interface * 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 + Horde_Kolab_Session_Interface $session ) { - return $this->_factory->validate($session, $user); + return $this->_factory->validate($session); } /** * 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) + public function createSession() { - $session = $this->_factory->createSession($user); + $session = $this->_factory->createSession(); $session = new Horde_Kolab_Session_Decorator_Logged( $session, $this->_logger ); @@ -158,8 +153,8 @@ implements Horde_Kolab_Session_Factory_Interface * * @return Horde_Kolab_Session_Interface The concrete Kolab session reference. */ - public function getSession($user = null, array $credentials = null) + public function getSession() { - return $this->_factory->getSession($user, $credentials); + return $this->_factory->getSession(); } } diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Interface.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Interface.php index dafba2c7c..c9b757cb5 100644 --- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Interface.php +++ b/framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Interface.php @@ -72,37 +72,26 @@ interface Horde_Kolab_Session_Factory_Interface /** * 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 + Horde_Kolab_Session_Interface $session ); /** * 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); + public function createSession(); /** * 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); + public function getSession(); } diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Interface.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Interface.php index 221009654..3ece671c5 100644 --- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Interface.php +++ b/framework/Kolab_Session/lib/Horde/Kolab/Session/Interface.php @@ -40,14 +40,15 @@ 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. + * @param string $user_id The user ID to connect with. + * @param array $credentials An array of login credentials. For Kolab, + * this must contain a "password" entry. * * @return NULL * * @throws Horde_Kolab_Session_Exception If the connection failed. */ - public function connect(array $credentials = null); + public function connect($user_id = null, array $credentials = null); /** * Return the user id used for connecting the session. diff --git a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/BaseTest.php b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/BaseTest.php index 0b0b7c703..cd690ac48 100644 --- a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/BaseTest.php +++ b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/BaseTest.php @@ -39,25 +39,36 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest ); } - public function testMethodConstructHasParameterStringUserid() + public function testMethodConstructHasParameterServercompositeServer() { $session = new Horde_Kolab_Session_Base( - 'userid', $this->_getComposite(), array() + $this->_getComposite(), array() ); } - public function testMethodConstructHasParameterServercompositeServer() + public function testMethodConstructHasParameterArrayParams() { $session = new Horde_Kolab_Session_Base( - '', $this->_getComposite(), array() + $this->_getComposite(), array('params' => 'params') ); } - public function testMethodConstructHasParameterArrayParams() + public function testMethodConnectHasParameterStringUserid() { + $this->user->expects($this->exactly(1)) + ->method('getSingle') + ->will($this->returnValue('mail@example.org')); + $this->user->expects($this->exactly(4)) + ->method('getExternal') + ->will($this->returnValue(array('mail@example.org'))); + $composite = $this->_getMockedComposite(); + $composite->objects->expects($this->once()) + ->method('fetch') + ->will($this->returnValue($this->user)); $session = new Horde_Kolab_Session_Base( - '', $this->_getComposite(), array('params' => 'params') + $composite, array() ); + $session->connect('userid', array('password' => '')); } public function testMethodConnectHasParameterArrayCredentials() @@ -73,9 +84,9 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest ->method('fetch') ->will($this->returnValue($this->user)); $session = new Horde_Kolab_Session_Base( - '', $composite, array() + $composite, array() ); - $session->connect(array('password' => '')); + $session->connect('', array('password' => '')); } public function testMethodConnectHasPostconditionThatTheUserMailAddressIsKnown() @@ -91,7 +102,7 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest ->method('fetch') ->will($this->returnValue($this->user)); $session = new Horde_Kolab_Session_Base( - '', $composite, array() + $composite, array() ); $session->connect(array('password' => '')); $this->assertEquals('mail@example.org', $session->getMail()); @@ -107,7 +118,7 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest ->method('fetch') ->will($this->returnValue($this->user)); $session = new Horde_Kolab_Session_Base( - '', $composite, array() + $composite, array() ); $session->connect(array('password' => '')); $this->assertEquals('uid', $session->getUid()); @@ -123,7 +134,7 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest ->method('fetch') ->will($this->returnValue($this->user)); $session = new Horde_Kolab_Session_Base( - '', $composite, array() + $composite, array() ); $session->connect(array('password' => '')); $this->assertEquals('name', $session->getName()); @@ -139,9 +150,9 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest ->method('fetch') ->will($this->returnValue($this->user)); $session = new Horde_Kolab_Session_Base( - 'userid', $composite, array() + $composite, array() ); - $session->connect(array('password' => '')); + $session->connect('userid', array('password' => '')); $this->assertEquals('home.example.org', $session->getImapServer()); } @@ -155,10 +166,10 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest ->method('fetch') ->will($this->returnValue($this->user)); $session = new Horde_Kolab_Session_Base( - 'userid', $composite, + $composite, array('freebusy' => array('url_format' => 'https://%s/fb')) ); - $session->connect(array('password' => '')); + $session->connect('userid', array('password' => '')); $this->assertEquals('https://freebusy.example.org/fb', $session->getFreebusyServer()); } @@ -169,10 +180,10 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest ->method('connectGuid') ->will($this->throwException(new Horde_Kolab_Server_Exception('Error'))); $session = new Horde_Kolab_Session_Base( - 'user', $composite, array() + $composite, array() ); try { - $session->connect(array('password' => 'pass')); + $session->connect('user', array('password' => 'pass')); } catch (Horde_Kolab_Session_Exception $e) { $this->assertEquals('Login failed!', $e->getMessage()); } @@ -185,10 +196,10 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest ->method('connectGuid') ->will($this->throwException(new Horde_Kolab_Server_Exception_Bindfailed('Error'))); $session = new Horde_Kolab_Session_Base( - 'user', $composite, array() + $composite, array() ); try { - $session->connect(array('password' => 'pass')); + $session->connect('user', array('password' => 'pass')); } catch (Horde_Kolab_Session_Exception_Badlogin $e) { $this->assertEquals('Invalid credentials!', $e->getMessage()); } @@ -197,7 +208,7 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest public function testMethodSleepHasResultArrayThePropertiesToSerialize() { $session = new Horde_Kolab_Session_Base( - 'user', $this->_getComposite(), array() + $this->_getComposite(), array() ); $this->assertEquals( array( @@ -216,9 +227,20 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest public function testMethodGetidHasResultStringTheIdOfTheUserUserUsedForConnecting() { + $this->user->expects($this->exactly(1)) + ->method('getSingle') + ->will($this->returnValue('mail@example.org')); + $this->user->expects($this->exactly(4)) + ->method('getExternal') + ->will($this->returnValue(array('mail@example.org'))); + $composite = $this->_getMockedComposite(); + $composite->objects->expects($this->once()) + ->method('fetch') + ->will($this->returnValue($this->user)); $session = new Horde_Kolab_Session_Base( - 'userid', $this->_getComposite(), array() + $composite, array() ); + $session->connect('userid', array('password' => 'pass')); $this->assertEquals('userid', $session->getId()); } @@ -235,9 +257,9 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest ->method('fetch') ->will($this->returnValue($this->user)); $session = new Horde_Kolab_Session_Base( - 'userid', $composite, array() + $composite, array() ); - $session->connect(array('password' => '')); + $session->connect('userid', array('password' => '')); $this->assertEquals('userid', $session->getMail()); } @@ -251,9 +273,9 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest ->method('fetch') ->will($this->returnValue($this->user)); $session = new Horde_Kolab_Session_Base( - 'userid', $composite, array() + $composite, array() ); - $session->connect(array('password' => '')); + $session->connect('userid', array('password' => '')); $this->assertEquals('userid', $session->getUid()); } @@ -267,9 +289,9 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest ->method('fetch') ->will($this->returnValue($this->user)); $session = new Horde_Kolab_Session_Base( - 'userid', $composite, array() + $composite, array() ); - $session->connect(array('password' => '')); + $session->connect('userid', array('password' => '')); $this->assertEquals('userid', $session->getName()); } @@ -283,10 +305,10 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest ->method('fetch') ->will($this->returnValue($this->user)); $session = new Horde_Kolab_Session_Base( - 'userid', $composite, + $composite, array('freebusy' => array('url_format' => 'https://%s/fb')) ); - $session->connect(array('password' => '')); + $session->connect('userid', array('password' => '')); $this->assertEquals('https://freebusy.example.org/fb', $session->getFreebusyServer()); } @@ -300,9 +322,9 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest ->method('fetch') ->will($this->returnValue($this->user)); $session = new Horde_Kolab_Session_Base( - 'userid', $composite, array() + $composite, array() ); - $session->connect(array('password' => '')); + $session->connect('userid', array('password' => '')); $this->assertEquals('http://freebusy.example.org/freebusy', $session->getFreebusyServer()); } @@ -316,10 +338,10 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest ->method('fetch') ->will($this->returnValue($this->user)); $session = new Horde_Kolab_Session_Base( - 'userid', $composite, + $composite, array('freebusy' => array('url' => 'https://freebusy2.example.org/fb')) ); - $session->connect(array('password' => '')); + $session->connect('userid', array('password' => '')); $this->assertEquals('https://freebusy2.example.org/fb', $session->getFreebusyServer()); } @@ -333,10 +355,10 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest ->method('fetch') ->will($this->returnValue($this->user)); $session = new Horde_Kolab_Session_Base( - 'userid', $composite, + $composite, array('freebusy' => array('url_format' => 'https://%s/fb')) ); - $session->connect(array('password' => '')); + $session->connect('userid', array('password' => '')); $this->assertEquals('https://localhost/fb', $session->getFreebusyServer()); } @@ -350,9 +372,9 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest ->method('fetch') ->will($this->returnValue($this->user)); $session = new Horde_Kolab_Session_Base( - 'userid', $composite, array() + $composite, array() ); - $session->connect(array('password' => '')); + $session->connect('userid', array('password' => '')); $this->assertEquals('http://localhost/freebusy', $session->getFreebusyServer()); } @@ -366,10 +388,10 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest ->method('fetch') ->will($this->returnValue($this->user)); $session = new Horde_Kolab_Session_Base( - 'userid', $composite, + $composite, array('freebusy' => array('url_format' => 'https://%s/fb')) ); - $session->connect(array('password' => '')); + $session->connect('userid', array('password' => '')); $this->assertEquals('https://localhost/fb', $session->getFreebusyServer()); } @@ -383,9 +405,9 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest ->method('fetch') ->will($this->returnValue($this->user)); $session = new Horde_Kolab_Session_Base( - 'userid', $composite, array() + $composite, array() ); - $session->connect(array('password' => '')); + $session->connect('userid', array('password' => '')); $this->assertEquals('http://localhost/freebusy', $session->getFreebusyServer()); } @@ -399,9 +421,9 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest ->method('fetch') ->will($this->returnValue($this->user)); $session = new Horde_Kolab_Session_Base( - 'userid', $composite, array() + $composite, array() ); - $session->connect(array('password' => '')); + $session->connect('userid', array('password' => '')); $this->assertEquals('home.example.org', $session->getImapServer()); } @@ -415,10 +437,10 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest ->method('fetch') ->will($this->returnValue($this->user)); $session = new Horde_Kolab_Session_Base( - 'userid', $composite, + $composite, array('imap' => array('server' => 'imap.example.org')) ); - $session->connect(array('password' => '')); + $session->connect('userid', array('password' => '')); $this->assertEquals('imap.example.org', $session->getImapServer()); } @@ -432,9 +454,9 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest ->method('fetch') ->will($this->returnValue($this->user)); $session = new Horde_Kolab_Session_Base( - 'userid', $composite, array() + $composite, array() ); - $session->connect(array('password' => '')); + $session->connect('userid', array('password' => '')); $this->assertEquals('localhost', $session->getImapServer()); } 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 index 3c8cdca2e..9c2ff312d 100644 --- a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Decorator/AnonymousTest.php +++ b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/Decorator/AnonymousTest.php @@ -37,14 +37,8 @@ extends Horde_Kolab_Session_SessionTestCase { $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')); + ->with('anonymous', array('password' => 'pass')); $anonymous = new Horde_Kolab_Session_Decorator_Anonymous( $session, 'anonymous', 'pass' ); 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 b69bc7309..464b574d0 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 @@ -106,15 +106,6 @@ class Horde_Kolab_Session_Class_Factory_BaseTest extends Horde_Kolab_Session_Ses $this->session_auth->expects($this->once()) ->method('getCurrentUser') ->will($this->returnValue('new@example.org')); - $this->server->objects->expects($this->once()) - ->method('fetch') - ->will($this->returnValue($this->user)); - $this->user->expects($this->exactly(1)) - ->method('getSingle') - ->will($this->returnValue('mail@example.org')); - $this->user->expects($this->exactly(4)) - ->method('getExternal') - ->will($this->returnValue(array('mail@example.org'))); $factory = new Horde_Kolab_Session_Factory_Constructor( $this->server, $this->session_auth, array(), $this->session_storage ); @@ -126,15 +117,6 @@ class Horde_Kolab_Session_Class_Factory_BaseTest extends Horde_Kolab_Session_Ses $this->session_storage->expects($this->once()) ->method('load') ->will($this->returnValue(false)); - $this->server->objects->expects($this->once()) - ->method('fetch') - ->will($this->returnValue($this->user)); - $this->user->expects($this->exactly(1)) - ->method('getSingle') - ->will($this->returnValue('mail@example.org')); - $this->user->expects($this->exactly(4)) - ->method('getExternal') - ->will($this->returnValue(array('mail@example.org'))); $factory = new Horde_Kolab_Session_Factory_Constructor( $this->server, $this->session_auth, array(), $this->session_storage ); 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 7cccfc7a8..2b8d62823 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 @@ -116,7 +116,7 @@ class Horde_Kolab_Session_Class_Factory_ConfigurationTest extends Horde_Kolab_Se ) ); $this->assertType( - 'Horde_Kolab_Server_Composite_Interface', + 'Horde_Kolab_Server_Composite', $factory->getServer() ); } 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 6d5640621..910dc434e 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 @@ -43,7 +43,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_Server_Composite_Interface', $factory->getServer()); + $this->assertType('Horde_Kolab_Server_Composite', $factory->getServer()); } public function testMethodGetsessionauthHasResultHordekolabsessionauth() 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 9de69e3ad..97f4bb20a 100644 --- a/framework/Kolab_Session/test/Horde/Kolab/Session/Integration/AnonymousTest.php +++ b/framework/Kolab_Session/test/Horde/Kolab/Session/Integration/AnonymousTest.php @@ -50,7 +50,7 @@ class Horde_Kolab_Session_Integration_AnonymousTest extends Horde_Kolab_Session_ ->method('fetch') ->will($this->returnValue($user)); $session = new Horde_Kolab_Session_Base( - '', $composite, array() + $composite, array() ); $anonymous = new Horde_Kolab_Session_Decorator_Anonymous( $session, 'anonymous', '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 8b79156a6..3e53eaaf7 100644 --- a/framework/Kolab_Session/test/Horde/Kolab/Session/Integration/ValidTest.php +++ b/framework/Kolab_Session/test/Horde/Kolab/Session/Integration/ValidTest.php @@ -47,7 +47,7 @@ class Horde_Kolab_Session_Integration_ValidTest extends Horde_Kolab_Session_Sess ->will($this->returnValue('')); $composite = $this->_getMockedComposite(); $session = new Horde_Kolab_Session_Base( - '', $composite, array() + $composite, array() ); $valid = new Horde_Kolab_Session_Valid_Base($session, $auth); $this->assertTrue($valid->isValid()); @@ -61,7 +61,7 @@ class Horde_Kolab_Session_Integration_ValidTest extends Horde_Kolab_Session_Sess ->will($this->returnValue('mail@example.org')); $composite = $this->_getMockedComposite(); $session = new Horde_Kolab_Session_Base( - '', $composite, array() + $composite, array() ); $valid = new Horde_Kolab_Session_Valid_Base($session, $auth); $this->assertFalse($valid->isValid()); @@ -84,9 +84,9 @@ class Horde_Kolab_Session_Integration_ValidTest extends Horde_Kolab_Session_Sess ->method('fetch') ->will($this->returnValue($this->user)); $session = new Horde_Kolab_Session_Base( - '', $composite, array() + $composite, array() ); - $session->connect(array('password' => '')); + $session->connect('', array('password' => '')); $valid = new Horde_Kolab_Session_Valid_Base($session, $auth); $this->assertFalse($valid->isValid()); } @@ -108,9 +108,9 @@ class Horde_Kolab_Session_Integration_ValidTest extends Horde_Kolab_Session_Sess ->method('fetch') ->will($this->returnValue($this->user)); $session = new Horde_Kolab_Session_Base( - '', $composite, array() + $composite, array() ); - $session->connect(array('password' => '')); + $session->connect('', array('password' => '')); $valid = new Horde_Kolab_Session_Valid_Base($session, $auth); $this->assertTrue($valid->isValid()); } @@ -132,9 +132,9 @@ class Horde_Kolab_Session_Integration_ValidTest extends Horde_Kolab_Session_Sess ->method('fetch') ->will($this->returnValue($this->user)); $session = new Horde_Kolab_Session_Base( - '', $composite, array() + $composite, array() ); - $session->connect(array('password' => '')); + $session->connect('', array('password' => '')); $valid = new Horde_Kolab_Session_Valid_Base($session, $auth); $this->assertFalse($valid->isValid('somebody@example.org')); } @@ -156,9 +156,9 @@ class Horde_Kolab_Session_Integration_ValidTest extends Horde_Kolab_Session_Sess ->method('fetch') ->will($this->returnValue($this->user)); $session = new Horde_Kolab_Session_Base( - '', $composite, array() + $composite, array() ); - $session->connect(array('password' => '')); + $session->connect('', array('password' => '')); $valid = new Horde_Kolab_Session_Valid_Base($session, $auth); $this->assertTrue($valid->isValid('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 e7c958bd4..444980299 100644 --- a/framework/Kolab_Session/test/Horde/Kolab/Session/SessionTestCase.php +++ b/framework/Kolab_Session/test/Horde/Kolab/Session/SessionTestCase.php @@ -29,12 +29,12 @@ class Horde_Kolab_Session_SessionTestCase extends PHPUnit_Framework_TestCase { protected function _getComposite() { - return $this->getMock('Horde_Kolab_Server_Composite_Interface'); + return $this->getMock('Horde_Kolab_Server_Composite', array(), array(), '', false, false); } protected function _getMockedComposite() { - return new Horde_Kolab_Server_Composite_Base( + return new Horde_Kolab_Server_Composite( $this->getMock('Horde_Kolab_Server_Interface'), $this->getMock('Horde_Kolab_Server_Objects_Interface'), $this->getMock('Horde_Kolab_Server_Structure_Interface'), -- 2.11.0