Fix the API for connecting the session with a user.
authorGunnar Wrobel <p@rdus.de>
Tue, 16 Mar 2010 09:22:54 +0000 (10:22 +0100)
committerGunnar Wrobel <wrobel@temple.(none)>
Tue, 16 Mar 2010 10:18:29 +0000 (11:18 +0100)
19 files changed:
framework/Kolab_Session/lib/Horde/Kolab/Session/Base.php
framework/Kolab_Session/lib/Horde/Kolab/Session/Decorator/Anonymous.php
framework/Kolab_Session/lib/Horde/Kolab/Session/Decorator/Logged.php
framework/Kolab_Session/lib/Horde/Kolab/Session/Decorator/Stored.php
framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Base.php
framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Configuration.php
framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Constructor.php
framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Decorator/Anonymous.php
framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Decorator/Logged.php
framework/Kolab_Session/lib/Horde/Kolab/Session/Factory/Interface.php
framework/Kolab_Session/lib/Horde/Kolab/Session/Interface.php
framework/Kolab_Session/test/Horde/Kolab/Session/Class/BaseTest.php
framework/Kolab_Session/test/Horde/Kolab/Session/Class/Decorator/AnonymousTest.php
framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/BaseTest.php
framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/ConfigurationTest.php
framework/Kolab_Session/test/Horde/Kolab/Session/Class/Factory/ConstructorTest.php
framework/Kolab_Session/test/Horde/Kolab/Session/Integration/AnonymousTest.php
framework/Kolab_Session/test/Horde/Kolab/Session/Integration/ValidTest.php
framework/Kolab_Session/test/Horde/Kolab/Session/SessionTestCase.php

index 43e377e..66d5e88 100644 (file)
@@ -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 {
index bc75fc1..a1d389b 100644 (file)
@@ -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);
         }
     }
 
index 88ffbe9..9fa045a 100644 (file)
@@ -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\".",
index bcb610c..55c1286 100644 (file)
@@ -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;
     }
 
index 1ef2457..412dfbd 100644 (file)
@@ -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;
     }
 }
index 2e3bc33..1c00556 100644 (file)
@@ -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();
     }
 }
index f06f2f4..be70c1c 100644 (file)
@@ -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
index 7e8acdd..f49e528 100644 (file)
@@ -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();
     }
 }
index 7f2b996..17b7c51 100644 (file)
@@ -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();
     }
 }
index dafba2c..c9b757c 100644 (file)
@@ -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();
 }
index 2210096..3ece671 100644 (file)
@@ -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.
index 0b0b7c7..cd690ac 100644 (file)
@@ -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());
     }
 
index 3c8cdca..9c2ff31 100644 (file)
@@ -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'
         );
index b69bc73..464b574 100644 (file)
@@ -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
         );
index 7cccfc7..2b8d628 100644 (file)
@@ -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()
         );
     }
index 6d56406..910dc43 100644 (file)
@@ -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()
index 9de69e3..97f4bb2 100644 (file)
@@ -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'
index 8b79156..3e53eaa 100644 (file)
@@ -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'));
     }
index e7c958b..4449802 100644 (file)
@@ -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'),