From aa32fba612d8e6c3399fb4c3a3661682edc3a54e Mon Sep 17 00:00:00 2001 From: Gunnar Wrobel Date: Thu, 8 Apr 2010 14:50:19 +0200 Subject: [PATCH] Always fetch single attributes. --- .../Kolab_Session/lib/Horde/Kolab/Session/Base.php | 8 +- .../test/Horde/Kolab/Session/Class/BaseTest.php | 89 +++++++++------------- .../Kolab/Session/Integration/AnonymousTest.php | 5 +- .../Horde/Kolab/Session/Integration/ValidTest.php | 20 +---- 4 files changed, 46 insertions(+), 76 deletions(-) diff --git a/framework/Kolab_Session/lib/Horde/Kolab/Session/Base.php b/framework/Kolab_Session/lib/Horde/Kolab/Session/Base.php index c53b5978d..7f5b67c38 100644 --- a/framework/Kolab_Session/lib/Horde/Kolab/Session/Base.php +++ b/framework/Kolab_Session/lib/Horde/Kolab/Session/Base.php @@ -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']; 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 3b22ad4d7..d19d6f43a 100644 --- a/framework/Kolab_Session/test/Horde/Kolab/Session/Class/BaseTest.php +++ b/framework/Kolab_Session/test/Horde/Kolab/Session/Class/BaseTest.php @@ -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()) 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 97f4bb20a..a3e2c74fc 100644 --- a/framework/Kolab_Session/test/Horde/Kolab/Session/Integration/AnonymousTest.php +++ b/framework/Kolab_Session/test/Horde/Kolab/Session/Integration/AnonymousTest.php @@ -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(); 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 3e53eaaf7..897379236 100644 --- a/framework/Kolab_Session/test/Horde/Kolab/Session/Integration/ValidTest.php +++ b/framework/Kolab_Session/test/Horde/Kolab/Session/Integration/ValidTest.php @@ -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(); -- 2.11.0