Always fetch single attributes.
authorGunnar Wrobel <p@rdus.de>
Thu, 8 Apr 2010 12:50:19 +0000 (14:50 +0200)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 8 Apr 2010 19:27:14 +0000 (13:27 -0600)
framework/Kolab_Session/lib/Horde/Kolab/Session/Base.php
framework/Kolab_Session/test/Horde/Kolab/Session/Class/BaseTest.php
framework/Kolab_Session/test/Horde/Kolab/Session/Integration/AnonymousTest.php
framework/Kolab_Session/test/Horde/Kolab/Session/Integration/ValidTest.php

index c53b597..7f5b67c 100644 (file)
@@ -177,7 +177,7 @@ class Horde_Kolab_Session_Base implements Horde_Kolab_Session
         Horde_Kolab_Server_Object_Hash $user
     ) {
         try {
-            $this->_user_uid = $user->getExternal('uid');
+            $this->_user_uid = $user->getSingle('uid');
         } catch (Horde_Kolab_Server_Exception_Novalue $e) {
             $this->_user_uid = $this->_user_id;
         }
@@ -194,7 +194,7 @@ class Horde_Kolab_Session_Base implements Horde_Kolab_Session
         Horde_Kolab_Server_Object_Hash $user
     ) {
         try {
-            $this->_user_name = $user->getExternal('Firstnamelastname');
+            $this->_user_name = $user->getSingle('Firstnamelastname');
         } catch (Horde_Kolab_Server_Exception_Novalue $e) {
             $this->_user_name = $this->_user_id;
         }
@@ -211,7 +211,7 @@ class Horde_Kolab_Session_Base implements Horde_Kolab_Session
         Horde_Kolab_Server_Object_Hash $user
     ) {
         try {
-            $this->_imap_server = $user->getExternal('kolabHomeServer');
+            $this->_imap_server = $user->getSingle('kolabHomeServer');
         } catch (Horde_Kolab_Server_Exception_Novalue $e) {
             if (isset($this->_params['imap']['server'])) {
                 $this->_imap_server = $this->_params['imap']['server'];
@@ -232,7 +232,7 @@ class Horde_Kolab_Session_Base implements Horde_Kolab_Session
         Horde_Kolab_Server_Object_Hash $user
     ) {
         try {
-            $fb_server = $user->getExternal('kolabFreebusyHost');
+            $fb_server = $user->getSingle('kolabFreebusyHost');
         } catch (Horde_Kolab_Server_Exception_Novalue $e) {
             if (isset($this->_params['freebusy']['url'])) {
                 $this->_freebusy_server = $this->_params['freebusy']['url'];
index 3b22ad4..d19d6f4 100644 (file)
@@ -55,12 +55,9 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest
 
     public function testMethodConnectHasParameterStringUserid()
     {
-        $this->user->expects($this->exactly(1))
+        $this->user->expects($this->exactly(5))
             ->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')
@@ -73,12 +70,9 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest
 
     public function testMethodConnectHasParameterArrayCredentials()
     {
-        $this->user->expects($this->exactly(1))
+        $this->user->expects($this->exactly(5))
             ->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')
@@ -91,12 +85,9 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest
 
     public function testMethodConnectHasPostconditionThatTheUserMailAddressIsKnown()
     {
-        $this->user->expects($this->exactly(1))
+        $this->user->expects($this->exactly(5))
             ->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')
@@ -110,8 +101,8 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest
 
     public function testMethodConnectHasPostconditionThatTheUserUidIsKnown()
     {
-        $this->user->expects($this->exactly(4))
-            ->method('getExternal')
+        $this->user->expects($this->exactly(5))
+            ->method('getSingle')
             ->will($this->returnValue('uid'));
         $composite = $this->_getMockedComposite();
         $composite->objects->expects($this->once())
@@ -126,8 +117,8 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest
 
     public function testMethodConnectHasPostconditionThatTheUserNameIsKnown()
     {
-        $this->user->expects($this->exactly(4))
-            ->method('getExternal')
+        $this->user->expects($this->exactly(5))
+            ->method('getSingle')
             ->will($this->returnValue('name'));
         $composite = $this->_getMockedComposite();
         $composite->objects->expects($this->once())
@@ -142,8 +133,8 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest
 
     public function testMethodConnectHasPostconditionThatTheUsersImapHostIsKnown()
     {
-        $this->user->expects($this->exactly(4))
-            ->method('getExternal')
+        $this->user->expects($this->exactly(5))
+            ->method('getSingle')
             ->will($this->returnValue('home.example.org'));
         $composite = $this->_getMockedComposite();
         $composite->objects->expects($this->once())
@@ -158,8 +149,8 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest
 
     public function testMethodConnectHasPostconditionThatTheUsersFreebusyHostIsKnown()
     {
-        $this->user->expects($this->exactly(4))
-            ->method('getExternal')
+        $this->user->expects($this->exactly(5))
+            ->method('getSingle')
             ->will($this->returnValue('freebusy.example.org'));
         $composite = $this->_getMockedComposite();
         $composite->objects->expects($this->once())
@@ -226,12 +217,9 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest
 
     public function testMethodGetidHasResultStringTheIdOfTheUserUserUsedForConnecting()
     {
-        $this->user->expects($this->exactly(1))
+        $this->user->expects($this->exactly(5))
             ->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')
@@ -245,10 +233,7 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest
 
     public function testMethodGetmailHasResultStringTheMailOfTheConnectedUser()
     {
-        $this->user->expects($this->exactly(4))
-            ->method('getExternal')
-            ->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
-        $this->user->expects($this->exactly(1))
+        $this->user->expects($this->exactly(5))
             ->method('getSingle')
             ->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
         $composite = $this->_getMockedComposite();
@@ -264,8 +249,8 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest
 
     public function testMethodGetuidHasResultStringTheUidOfTheConnectedUser()
     {
-        $this->user->expects($this->exactly(4))
-            ->method('getExternal')
+        $this->user->expects($this->exactly(5))
+            ->method('getSingle')
             ->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
         $composite = $this->_getMockedComposite();
         $composite->objects->expects($this->once())
@@ -280,8 +265,8 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest
 
     public function testMethodGetnameHasResultStringTheNameOfTheConnectedUser()
     {
-        $this->user->expects($this->exactly(4))
-            ->method('getExternal')
+        $this->user->expects($this->exactly(5))
+            ->method('getSingle')
             ->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
         $composite = $this->_getMockedComposite();
         $composite->objects->expects($this->once())
@@ -296,8 +281,8 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest
 
     public function testMethodGetfreebusyserverHasResultStringTheUsersFreebusyServerConverterdToACompleteUrlUsingParametersIfAvailable()
     {
-        $this->user->expects($this->exactly(4))
-            ->method('getExternal')
+        $this->user->expects($this->exactly(5))
+            ->method('getSingle')
             ->will($this->returnValue('freebusy.example.org'));
         $composite = $this->_getMockedComposite();
         $composite->objects->expects($this->once())
@@ -313,8 +298,8 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest
 
     public function testMethodGetfreebusyserverHasResultStringTheUsersFreebusyServerConverterdToACompleteUrlUsingFreebusyIfAvailable()
     {
-        $this->user->expects($this->exactly(4))
-            ->method('getExternal')
+        $this->user->expects($this->exactly(5))
+            ->method('getSingle')
             ->will($this->returnValue('freebusy.example.org'));
         $composite = $this->_getMockedComposite();
         $composite->objects->expects($this->once())
@@ -329,8 +314,8 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest
 
     public function testMethodGetfreebusyserverHasResultStringTheConfiguredServerIfAvailable()
     {
-        $this->user->expects($this->exactly(4))
-            ->method('getExternal')
+        $this->user->expects($this->exactly(5))
+            ->method('getSingle')
             ->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
         $composite = $this->_getMockedComposite();
         $composite->objects->expects($this->once())
@@ -346,8 +331,8 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest
 
     public function testMethodGetfreebusyserverHasResultStringTheUsersHomeServerConverterdToACompleteUrlUsingParametersIfAvailable()
     {
-        $this->user->expects($this->exactly(4))
-            ->method('getExternal')
+        $this->user->expects($this->exactly(5))
+            ->method('getSingle')
             ->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
         $composite = $this->_getMockedComposite();
         $composite->objects->expects($this->once())
@@ -363,8 +348,8 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest
 
     public function testMethodGetfreebusyserverHasResultStringTheUsersHomeServerConverterdToACompleteUrlUsingFreebusyIfAvailable()
     {
-        $this->user->expects($this->exactly(4))
-            ->method('getExternal')
+        $this->user->expects($this->exactly(5))
+            ->method('getSingle')
             ->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
         $composite = $this->_getMockedComposite();
         $composite->objects->expects($this->once())
@@ -379,8 +364,8 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest
 
     public function testMethodGetfreebusyserverHasResultStringLocalhostConvertedToACompleteUrlUsingParametersIfAvailable()
     {
-        $this->user->expects($this->exactly(4))
-            ->method('getExternal')
+        $this->user->expects($this->exactly(5))
+            ->method('getSingle')
             ->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
         $composite = $this->_getMockedComposite();
         $composite->objects->expects($this->once())
@@ -396,8 +381,8 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest
 
     public function testMethodGetfreebusyserverHasResultStringLocalhostConvertedToACompleteUrlUsingFreebusy()
     {
-        $this->user->expects($this->exactly(4))
-            ->method('getExternal')
+        $this->user->expects($this->exactly(5))
+            ->method('getSingle')
             ->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
         $composite = $this->_getMockedComposite();
         $composite->objects->expects($this->once())
@@ -412,8 +397,8 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest
 
     public function testMethodGetimapserverHasResultStringTheUsersHomeServerIfAvailable()
     {
-        $this->user->expects($this->exactly(4))
-            ->method('getExternal')
+        $this->user->expects($this->exactly(5))
+            ->method('getSingle')
             ->will($this->returnValue('home.example.org'));
         $composite = $this->_getMockedComposite();
         $composite->objects->expects($this->once())
@@ -428,8 +413,8 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest
 
     public function testMethodGetimapserverHasResultStringTheConfiguredServerIfAvailable()
     {
-        $this->user->expects($this->exactly(4))
-            ->method('getExternal')
+        $this->user->expects($this->exactly(5))
+            ->method('getSingle')
             ->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
         $composite = $this->_getMockedComposite();
         $composite->objects->expects($this->once())
@@ -445,8 +430,8 @@ class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTest
 
     public function testMethodGetimapserverHasResultStringLocalhostIfNoAlternative()
     {
-        $this->user->expects($this->exactly(4))
-            ->method('getExternal')
+        $this->user->expects($this->exactly(5))
+            ->method('getSingle')
             ->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
         $composite = $this->_getMockedComposite();
         $composite->objects->expects($this->once())
index 97f4bb2..a3e2c74 100644 (file)
@@ -39,10 +39,7 @@ class Horde_Kolab_Session_Integration_AnonymousTest extends Horde_Kolab_Session_
         $user = $this->getMock(
             'Horde_Kolab_Server_Object_Hash', array(), array(), '', false, false
         );
-        $user->expects($this->exactly(4))
-            ->method('getExternal')
-            ->will($this->returnValue(array('anonymous@example.org')));
-        $user->expects($this->exactly(1))
+        $user->expects($this->exactly(5))
             ->method('getSingle')
             ->will($this->returnValue('anonymous@example.org'));
         $composite = $this->_getMockedComposite();
index 3e53eaa..8973792 100644 (file)
@@ -73,10 +73,7 @@ class Horde_Kolab_Session_Integration_ValidTest extends Horde_Kolab_Session_Sess
         $auth->expects($this->once())
             ->method('getCurrentUser')
             ->will($this->returnValue('somebody@example.org'));
-        $this->user->expects($this->exactly(4))
-            ->method('getExternal')
-            ->will($this->returnValue(array('mail@example.org')));
-        $this->user->expects($this->exactly(1))
+        $this->user->expects($this->exactly(5))
             ->method('getSingle')
             ->will($this->returnValue('mail@example.org'));
         $composite = $this->_getMockedComposite();
@@ -97,10 +94,7 @@ class Horde_Kolab_Session_Integration_ValidTest extends Horde_Kolab_Session_Sess
         $auth->expects($this->once())
             ->method('getCurrentUser')
             ->will($this->returnValue('mail@example.org'));
-        $this->user->expects($this->exactly(4))
-            ->method('getExternal')
-            ->will($this->returnValue(array('mail@example.org')));
-        $this->user->expects($this->exactly(1))
+        $this->user->expects($this->exactly(5))
             ->method('getSingle')
             ->will($this->returnValue('mail@example.org'));
         $composite = $this->_getMockedComposite();
@@ -121,10 +115,7 @@ class Horde_Kolab_Session_Integration_ValidTest extends Horde_Kolab_Session_Sess
         $auth->expects($this->once())
             ->method('getCurrentUser')
             ->will($this->returnValue('mail@example.org'));
-        $this->user->expects($this->exactly(4))
-            ->method('getExternal')
-            ->will($this->returnValue(array('mail@example.org')));
-        $this->user->expects($this->exactly(1))
+        $this->user->expects($this->exactly(5))
             ->method('getSingle')
             ->will($this->returnValue('mail@example.org'));
         $composite = $this->_getMockedComposite();
@@ -145,10 +136,7 @@ class Horde_Kolab_Session_Integration_ValidTest extends Horde_Kolab_Session_Sess
         $auth->expects($this->once())
             ->method('getCurrentUser')
             ->will($this->returnValue('mail@example.org'));
-        $this->user->expects($this->exactly(4))
-            ->method('getExternal')
-            ->will($this->returnValue(array('mail@example.org')));
-        $this->user->expects($this->exactly(1))
+        $this->user->expects($this->exactly(5))
             ->method('getSingle')
             ->will($this->returnValue('mail@example.org'));
         $composite = $this->_getMockedComposite();