*/
class Horde_Kolab_Session_Class_BaseTest extends Horde_Kolab_Session_SessionTestCase
{
+ public function setUp()
+ {
+ $this->user = $this->getMock(
+ 'Horde_Kolab_Server_Object_Hash', array(), array(), '', false, false
+ );
+ }
+
public function testMethodConstructHasParameterStringUserid()
{
$session = new Horde_Kolab_Session_Base(
public function testMethodConnectHasParameterArrayCredentials()
{
- $user = $this->getMock('Horde_Kolab_Server_Object_Interface');
+ $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($user));
+ ->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
'', $composite, array()
);
public function testMethodConnectHasPostconditionThatTheUserMailAddressIsKnown()
{
- $user = $this->getMock('Horde_Kolab_Server_Object_Interface');
- $user->expects($this->exactly(5))
- ->method('getExternal')
+ $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($user));
+ ->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
'', $composite, array()
);
public function testMethodConnectHasPostconditionThatTheUserUidIsKnown()
{
- $user = $this->getMock('Horde_Kolab_Server_Object_Interface');
- $user->expects($this->exactly(5))
+ $this->user->expects($this->exactly(4))
->method('getExternal')
->will($this->returnValue('uid'));
$composite = $this->_getMockedComposite();
$composite->objects->expects($this->once())
->method('fetch')
- ->will($this->returnValue($user));
+ ->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
'', $composite, array()
);
public function testMethodConnectHasPostconditionThatTheUserNameIsKnown()
{
- $user = $this->getMock('Horde_Kolab_Server_Object_Interface');
- $user->expects($this->exactly(5))
+ $this->user->expects($this->exactly(4))
->method('getExternal')
->will($this->returnValue('name'));
$composite = $this->_getMockedComposite();
$composite->objects->expects($this->once())
->method('fetch')
- ->will($this->returnValue($user));
+ ->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
'', $composite, array()
);
public function testMethodConnectHasPostconditionThatTheUsersImapHostIsKnown()
{
- $user = $this->getMock('Horde_Kolab_Server_Object_Interface');
- $user->expects($this->exactly(5))
+ $this->user->expects($this->exactly(4))
->method('getExternal')
->will($this->returnValue('home.example.org'));
$composite = $this->_getMockedComposite();
$composite->objects->expects($this->once())
->method('fetch')
- ->will($this->returnValue($user));
+ ->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
'userid', $composite, array()
);
public function testMethodConnectHasPostconditionThatTheUsersFreebusyHostIsKnown()
{
- $user = $this->getMock('Horde_Kolab_Server_Object_Interface');
- $user->expects($this->exactly(5))
+ $this->user->expects($this->exactly(4))
->method('getExternal')
->will($this->returnValue('freebusy.example.org'));
$composite = $this->_getMockedComposite();
$composite->objects->expects($this->once())
->method('fetch')
- ->will($this->returnValue($user));
+ ->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
'userid', $composite,
array('freebusy' => array('url_format' => 'https://%s/fb'))
public function testMethodConnectThrowsExceptionIfTheConnectionFailed()
{
- $user = $this->getMock('Horde_Kolab_Server_Object_Interface');
$composite = $this->_getMockedComposite();
$composite->server->expects($this->exactly(1))
->method('connectGuid')
}
}
+ public function testMethodConnectThrowsExceptionIfTheCredentialsWereInvalid()
+ {
+ $composite = $this->_getMockedComposite();
+ $composite->server->expects($this->exactly(1))
+ ->method('connectGuid')
+ ->will($this->throwException(new Horde_Kolab_Server_Exception_Bindfailed('Error')));
+ $session = new Horde_Kolab_Session_Base(
+ 'user', $composite, array()
+ );
+ try {
+ $session->connect(array('password' => 'pass'));
+ } catch (Horde_Kolab_Session_Exception_Badlogin $e) {
+ $this->assertEquals('Error', $e->getMessage());
+ }
+ }
+
public function testMethodSleepHasResultArrayThePropertiesToSerialize()
{
$session = new Horde_Kolab_Session_Base(
public function testMethodGetmailHasResultStringTheMailOfTheConnectedUser()
{
- $user = $this->getMock('Horde_Kolab_Server_Object_Interface');
- $user->expects($this->exactly(5))
+ $this->user->expects($this->exactly(4))
->method('getExternal')
->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
+ $this->user->expects($this->exactly(1))
+ ->method('getSingle')
+ ->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
$composite = $this->_getMockedComposite();
$composite->objects->expects($this->once())
->method('fetch')
- ->will($this->returnValue($user));
+ ->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
'userid', $composite, array()
);
public function testMethodGetuidHasResultStringTheUidOfTheConnectedUser()
{
- $user = $this->getMock('Horde_Kolab_Server_Object_Interface');
- $user->expects($this->exactly(5))
+ $this->user->expects($this->exactly(4))
->method('getExternal')
->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
$composite = $this->_getMockedComposite();
$composite->objects->expects($this->once())
->method('fetch')
- ->will($this->returnValue($user));
+ ->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
'userid', $composite, array()
);
public function testMethodGetnameHasResultStringTheNameOfTheConnectedUser()
{
- $user = $this->getMock('Horde_Kolab_Server_Object_Interface');
- $user->expects($this->exactly(5))
+ $this->user->expects($this->exactly(4))
->method('getExternal')
->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
$composite = $this->_getMockedComposite();
$composite->objects->expects($this->once())
->method('fetch')
- ->will($this->returnValue($user));
+ ->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
'userid', $composite, array()
);
public function testMethodGetfreebusyserverHasResultStringTheUsersFreebusyServerConverterdToACompleteUrlUsingParametersIfAvailable()
{
- $user = $this->getMock('Horde_Kolab_Server_Object_Interface');
- $user->expects($this->exactly(5))
+ $this->user->expects($this->exactly(4))
->method('getExternal')
->will($this->returnValue('freebusy.example.org'));
$composite = $this->_getMockedComposite();
$composite->objects->expects($this->once())
->method('fetch')
- ->will($this->returnValue($user));
+ ->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
'userid', $composite,
array('freebusy' => array('url_format' => 'https://%s/fb'))
public function testMethodGetfreebusyserverHasResultStringTheUsersFreebusyServerConverterdToACompleteUrlUsingFreebusyIfAvailable()
{
- $user = $this->getMock('Horde_Kolab_Server_Object_Interface');
- $user->expects($this->exactly(5))
+ $this->user->expects($this->exactly(4))
->method('getExternal')
->will($this->returnValue('freebusy.example.org'));
$composite = $this->_getMockedComposite();
$composite->objects->expects($this->once())
->method('fetch')
- ->will($this->returnValue($user));
+ ->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
'userid', $composite, array()
);
public function testMethodGetfreebusyserverHasResultStringTheConfiguredServerIfAvailable()
{
- $user = $this->getMock('Horde_Kolab_Server_Object_Interface');
- $user->expects($this->exactly(5))
+ $this->user->expects($this->exactly(4))
->method('getExternal')
->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
$composite = $this->_getMockedComposite();
$composite->objects->expects($this->once())
->method('fetch')
- ->will($this->returnValue($user));
+ ->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
'userid', $composite,
array('freebusy' => array('url' => 'https://freebusy2.example.org/fb'))
public function testMethodGetfreebusyserverHasResultStringTheUsersHomeServerConverterdToACompleteUrlUsingParametersIfAvailable()
{
- $user = $this->getMock('Horde_Kolab_Server_Object_Interface');
- $user->expects($this->exactly(5))
+ $this->user->expects($this->exactly(4))
->method('getExternal')
->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
$composite = $this->_getMockedComposite();
$composite->objects->expects($this->once())
->method('fetch')
- ->will($this->returnValue($user));
+ ->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
'userid', $composite,
array('freebusy' => array('url_format' => 'https://%s/fb'))
public function testMethodGetfreebusyserverHasResultStringTheUsersHomeServerConverterdToACompleteUrlUsingFreebusyIfAvailable()
{
- $user = $this->getMock('Horde_Kolab_Server_Object_Interface');
- $user->expects($this->exactly(5))
+ $this->user->expects($this->exactly(4))
->method('getExternal')
->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
$composite = $this->_getMockedComposite();
$composite->objects->expects($this->once())
->method('fetch')
- ->will($this->returnValue($user));
+ ->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
'userid', $composite, array()
);
public function testMethodGetfreebusyserverHasResultStringLocalhostConvertedToACompleteUrlUsingParametersIfAvailable()
{
- $user = $this->getMock('Horde_Kolab_Server_Object_Interface');
- $user->expects($this->exactly(5))
+ $this->user->expects($this->exactly(4))
->method('getExternal')
->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
$composite = $this->_getMockedComposite();
$composite->objects->expects($this->once())
->method('fetch')
- ->will($this->returnValue($user));
+ ->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
'userid', $composite,
array('freebusy' => array('url_format' => 'https://%s/fb'))
public function testMethodGetfreebusyserverHasResultStringLocalhostConvertedToACompleteUrlUsingFreebusy()
{
- $user = $this->getMock('Horde_Kolab_Server_Object_Interface');
- $user->expects($this->exactly(5))
+ $this->user->expects($this->exactly(4))
->method('getExternal')
->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
$composite = $this->_getMockedComposite();
$composite->objects->expects($this->once())
->method('fetch')
- ->will($this->returnValue($user));
+ ->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
'userid', $composite, array()
);
public function testMethodGetimapserverHasResultStringTheUsersHomeServerIfAvailable()
{
- $user = $this->getMock('Horde_Kolab_Server_Object_Interface');
- $user->expects($this->exactly(5))
+ $this->user->expects($this->exactly(4))
->method('getExternal')
->will($this->returnValue('home.example.org'));
$composite = $this->_getMockedComposite();
$composite->objects->expects($this->once())
->method('fetch')
- ->will($this->returnValue($user));
+ ->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
'userid', $composite, array()
);
public function testMethodGetimapserverHasResultStringTheConfiguredServerIfAvailable()
{
- $user = $this->getMock('Horde_Kolab_Server_Object_Interface');
- $user->expects($this->exactly(5))
+ $this->user->expects($this->exactly(4))
->method('getExternal')
->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
$composite = $this->_getMockedComposite();
$composite->objects->expects($this->once())
->method('fetch')
- ->will($this->returnValue($user));
+ ->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
'userid', $composite,
array('imap' => array('server' => 'imap.example.org'))
public function testMethodGetimapserverHasResultStringLocalhostIfNoAlternative()
{
- $user = $this->getMock('Horde_Kolab_Server_Object_Interface');
- $user->expects($this->exactly(5))
+ $this->user->expects($this->exactly(4))
->method('getExternal')
->will($this->throwException(new Horde_Kolab_Server_Exception_Novalue()));
$composite = $this->_getMockedComposite();
$composite->objects->expects($this->once())
->method('fetch')
- ->will($this->returnValue($user));
+ ->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
'userid', $composite, array()
);
*/
class Horde_Kolab_Session_Integration_ValidTest extends Horde_Kolab_Session_SessionTestCase
{
+ public function setUp()
+ {
+ $this->user = $this->getMock(
+ 'Horde_Kolab_Server_Object_Hash', array(), array(), '', false, false
+ );
+ }
+
public function testMethodIsvalidHasResultBooleanTrueIfTheSessionIsNotConnectedAndTheCurrentUserIsAnonymous()
{
$auth = $this->getMock('Horde_Kolab_Session_Auth');
$auth->expects($this->once())
->method('getCurrentUser')
->will($this->returnValue('somebody@example.org'));
- $user = $this->getMock('Horde_Kolab_Server_Object_Interface');
- $user->expects($this->exactly(5))
+ $this->user->expects($this->exactly(4))
->method('getExternal')
+ ->will($this->returnValue(array('mail@example.org')));
+ $this->user->expects($this->exactly(1))
+ ->method('getSingle')
->will($this->returnValue('mail@example.org'));
$composite = $this->_getMockedComposite();
$composite->objects->expects($this->once())
->method('fetch')
- ->will($this->returnValue($user));
+ ->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
'', $composite, array()
);
$auth->expects($this->once())
->method('getCurrentUser')
->will($this->returnValue('mail@example.org'));
- $user = $this->getMock('Horde_Kolab_Server_Object_Interface');
- $user->expects($this->exactly(5))
+ $this->user->expects($this->exactly(4))
->method('getExternal')
+ ->will($this->returnValue(array('mail@example.org')));
+ $this->user->expects($this->exactly(1))
+ ->method('getSingle')
->will($this->returnValue('mail@example.org'));
$composite = $this->_getMockedComposite();
$composite->objects->expects($this->once())
->method('fetch')
- ->will($this->returnValue($user));
+ ->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
'', $composite, array()
);
$auth->expects($this->once())
->method('getCurrentUser')
->will($this->returnValue('mail@example.org'));
- $user = $this->getMock('Horde_Kolab_Server_Object_Interface');
- $user->expects($this->exactly(5))
+ $this->user->expects($this->exactly(4))
->method('getExternal')
+ ->will($this->returnValue(array('mail@example.org')));
+ $this->user->expects($this->exactly(1))
+ ->method('getSingle')
->will($this->returnValue('mail@example.org'));
$composite = $this->_getMockedComposite();
$composite->objects->expects($this->once())
->method('fetch')
- ->will($this->returnValue($user));
+ ->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
'', $composite, array()
);
$auth->expects($this->once())
->method('getCurrentUser')
->will($this->returnValue('mail@example.org'));
- $user = $this->getMock('Horde_Kolab_Server_Object_Interface');
- $user->expects($this->exactly(5))
+ $this->user->expects($this->exactly(4))
->method('getExternal')
+ ->will($this->returnValue(array('mail@example.org')));
+ $this->user->expects($this->exactly(1))
+ ->method('getSingle')
->will($this->returnValue('mail@example.org'));
$composite = $this->_getMockedComposite();
$composite->objects->expects($this->once())
->method('fetch')
- ->will($this->returnValue($user));
+ ->will($this->returnValue($this->user));
$session = new Horde_Kolab_Session_Base(
'', $composite, array()
);