From da31d26df43c101f4e829714659f63cbc1acc8c8 Mon Sep 17 00:00:00 2001 From: Gunnar Wrobel
Date: Thu, 5 Nov 2009 22:07:08 +0100 Subject: [PATCH] Adapt to the interface change in Kolab_Session. --- framework/Auth/lib/Horde/Auth/Kolab.php | 3 +-- .../Auth/test/Horde/Auth/Kolab/Class/KolabTest.php | 31 +++++++--------------- .../test/Horde/Auth/Kolab/Integration/AuthTest.php | 4 +++ 3 files changed, 14 insertions(+), 24 deletions(-) diff --git a/framework/Auth/lib/Horde/Auth/Kolab.php b/framework/Auth/lib/Horde/Auth/Kolab.php index a2280f9fb..a000b0992 100644 --- a/framework/Auth/lib/Horde/Auth/Kolab.php +++ b/framework/Auth/lib/Horde/Auth/Kolab.php @@ -84,8 +84,7 @@ class Horde_Auth_Kolab extends Horde_Auth_Base $userId, $credentials ); } else { - $this->_session = $this->_factory->getSession($userId); - $this->_session->connect($credentials); + $this->_session = $this->_factory->getSession($userId, $credentials); } } return $this->_session; diff --git a/framework/Auth/test/Horde/Auth/Kolab/Class/KolabTest.php b/framework/Auth/test/Horde/Auth/Kolab/Class/KolabTest.php index 8e1e20f6c..7af675961 100644 --- a/framework/Auth/test/Horde/Auth/Kolab/Class/KolabTest.php +++ b/framework/Auth/test/Horde/Auth/Kolab/Class/KolabTest.php @@ -41,6 +41,10 @@ class Horde_Auth_Kolab_Class_KolabTest extends PHPUnit_Framework_TestCase $this->session = $this->getMock('Horde_Kolab_Session'); $this->factory = $this->getMock('Horde_Kolab_Session_Factory'); + + if (!defined('HORDE_BASE')) { + define('HORDE_BASE', '/nowhere'); + } } public function testMethodSetsessionHasParameterSession() @@ -65,11 +69,8 @@ class Horde_Auth_Kolab_Class_KolabTest extends PHPUnit_Framework_TestCase $auth->setSessionFactory($this->factory); $this->factory->expects($this->once()) ->method('getSession') - ->with('user') + ->with('user', array('password' => 'test')) ->will($this->returnValue($this->session)); - $this->session->expects($this->once()) - ->method('connect') - ->with(array('password' => 'test')); $this->assertType( 'Horde_Kolab_Session', $auth->getSession('user', array('password' => 'test')) @@ -82,11 +83,8 @@ class Horde_Auth_Kolab_Class_KolabTest extends PHPUnit_Framework_TestCase $auth->setSessionFactory($this->factory); $this->factory->expects($this->once()) ->method('getSession') - ->with('user') + ->with('user', array('password' => 'test')) ->will($this->returnValue($this->session)); - $this->session->expects($this->once()) - ->method('connect') - ->with(array('password' => 'test')); $this->assertTrue( $auth->authenticate('user', array('password' => 'test'), false) ); @@ -98,12 +96,9 @@ class Horde_Auth_Kolab_Class_KolabTest extends PHPUnit_Framework_TestCase $auth->setSessionFactory($this->factory); $this->factory->expects($this->once()) ->method('getSession') - ->with('user') + ->with('user', array('password' => 'test')) ->will($this->returnValue($this->session)); $this->session->expects($this->once()) - ->method('connect') - ->with(array('password' => 'test')); - $this->session->expects($this->once()) ->method('getMail') ->will($this->returnValue('mail@example.org')); /* Untestable with the way the Auth driver is currently structured */ @@ -116,11 +111,7 @@ class Horde_Auth_Kolab_Class_KolabTest extends PHPUnit_Framework_TestCase $auth->setSessionFactory($this->factory); $this->factory->expects($this->once()) ->method('getSession') - ->with('user') - ->will($this->returnValue($this->session)); - $this->session->expects($this->once()) - ->method('connect') - ->with(array('password' => 'test')) + ->with('user', array('password' => 'test')) ->will($this->throwException(new Horde_Kolab_Session_Exception('Error'))); $auth->authenticate('user', array('password' => 'test'), false); $this->assertEquals(Horde_Auth::REASON_FAILED, Horde_Auth::getAuthError()); @@ -132,11 +123,7 @@ class Horde_Auth_Kolab_Class_KolabTest extends PHPUnit_Framework_TestCase $auth->setSessionFactory($this->factory); $this->factory->expects($this->once()) ->method('getSession') - ->with('user') - ->will($this->returnValue($this->session)); - $this->session->expects($this->once()) - ->method('connect') - ->with(array('password' => 'test')) + ->with('user', array('password' => 'test')) ->will($this->throwException(new Horde_Kolab_Session_Exception_Badlogin('Error'))); $auth->authenticate('user', array('password' => 'test'), false); $this->assertEquals(Horde_Auth::REASON_BADLOGIN, Horde_Auth::getAuthError()); diff --git a/framework/Auth/test/Horde/Auth/Kolab/Integration/AuthTest.php b/framework/Auth/test/Horde/Auth/Kolab/Integration/AuthTest.php index c536679b7..085c534a0 100644 --- a/framework/Auth/test/Horde/Auth/Kolab/Integration/AuthTest.php +++ b/framework/Auth/test/Horde/Auth/Kolab/Integration/AuthTest.php @@ -57,6 +57,10 @@ class Horde_Auth_Kolab_Integration_AuthTest extends PHPUnit_Framework_TestCase ) ); $this->factory = new Horde_Kolab_Session_Factory_Configuration($config); + + if (!defined('HORDE_BASE')) { + define('HORDE_BASE', '/nowhere'); + } } public function testKolabLoginViaUid() -- 2.11.0