class Horde_Kolab_Server_ServerTest extends PHPUnit_Framework_TestCase
{
/**
+ * The generating a uid for an object.
+ *
+ * @return NULL
+ */
+ public function testGenerateUid()
+ {
+ $ks = &Horde_Kolab_Server::factory('none');
+ $uid = $ks->generateUid('Horde_Kolab_Server_Object', array());
+ $this->assertEquals($uid, '');
+ }
+
+ /**
+ * Test creating the server object.
+ *
+ * @return NULL
+ */
+ public function testCreation()
+ {
+ try {
+ Horde_Kolab_Server::factory('dummy');
+ $this->assertFail('No error!');
+ } catch (Horde_Kolab_Server_Exception $e) {
+ $this->assertEquals($e->getMessage(),
+ 'Server type definition "Horde_Kolab_Server_dummy" missing.');
+ }
+ }
+
+ /**
* The base class provides no abilities for reading data. So it
* should mainly return error. But it should be capable of
* returning a dummy Kolab user object.
$ks = &Horde_Kolab_Server::factory('none');
$user = $ks->fetch('test');
$this->assertEquals('Horde_Kolab_Server_Object_user', get_class($user));
+
+ $ks = &Horde_Kolab_Server::factory('none', array('uid' => 'test'));
+ $user = $ks->fetch();
+ $this->assertEquals('Horde_Kolab_Server_Object_user', get_class($user));
}
/**
*
* @return NULL
*/
- public function testDnFor()
+ public function testUidFor()
{
$ks = &Horde_Kolab_Server::factory('none');
+ $dn = $ks->uidForId('test');
+ $this->assertFalse($dn);
+ $dn = $ks->uidForMail('test');
+ $this->assertFalse($dn);
+ $dn = $ks->uidForAlias('test');
+ $this->assertFalse($dn);
$dn = $ks->uidForIdOrMail('test');
- $this->assertEquals(false, $dn);
+ $this->assertFalse($dn);
+ $dn = $ks->uidForMailOrAlias('test');
+ $this->assertFalse($dn);
$dn = $ks->uidForIdOrMailOrAlias('test');
$this->assertFalse($dn);
+ $dn = $ks->mailForIdOrMail('test');
+ $this->assertFalse($dn);
+ $dn = $ks->addrsForIdOrMail('test');
+ $this->assertEquals($dn, array());
+ $dn = $ks->gidForMail('test');
+ $this->assertFalse($dn);
+ $dn = $ks->memberOfGroupAddress('test', 'test@example.org');
+ $this->assertFalse($dn);
+ $dn = $ks->getGroups('test');
+ $this->assertEquals($dn, array());
+ }
+
+ /**
+ * Test listing objects.
+ *
+ * @return NULL
+ */
+ public function testList()
+ {
+ $ks = &Horde_Kolab_Server::factory('none');
+ $hash = $ks->listHash('Horde_Kolab_Server_Object');
+ $this->assertEquals($hash, array());
+
+ $ks = &Horde_Kolab_Server::factory('none', array('whatever'));
+ $hash = $ks->listHash('Horde_Kolab_Server_Object');
+ $this->assertEquals($hash, array());
}
}
* search criteria.
*
* @param array $criteria The search parameters as array.
- * @param int $restrict A KOLAB_SERVER_RESULT_* result restriction.
+ * @param int $restrict A Horde_Kolab_Server::RESULT_* result restriction.
*
* @return boolean|string|array The UID(s) or false if there was no result.
*
* @throws Horde_Kolab_Server_Exception
*/
public function uidForSearch($criteria,
- $restrict = KOLAB_SERVER_RESULT_SINGLE)
+ $restrict = Horde_Kolab_Server::RESULT_SINGLE)
{
/* In the default class we just return false */
return false;
* search criteria
*
* @param array $criteria The search parameters as array.
- * @param int $restrict A KOLAB_SERVER_RESULT_* result restriction.
+ * @param int $restrict A Horde_Kolab_Server::RESULT_* result restriction.
*
* @return boolean|string|array The GID(s) or false if there was no result.
*
* @throws Horde_Kolab_Server_Exception
*/
public function gidForSearch($criteria,
- $restrict = KOLAB_SERVER_RESULT_SINGLE)
+ $restrict = Horde_Kolab_Server::RESULT_SINGLE)
{
/* In the default class we just return false */
return false;
*
* @param array $criteria The search parameters as array.
* @param array $attrs The attributes to retrieve.
- * @param int $restrict A KOLAB_SERVER_RESULT_* result restriction.
+ * @param int $restrict A Horde_Kolab_Server::RESULT_* result restriction.
*
* @return array The results.
*
* @throws Horde_Kolab_Server_Exception
*/
public function attrsForSearch($criteria, $attrs,
- $restrict = KOLAB_SERVER_RESULT_SINGLE)
+ $restrict = Horde_Kolab_Server::RESULT_SINGLE)
{
/* In the default class we just return an empty array */
return array();
/**
* @scenario
*/
- public function creatingUserWithoutGivenName()
- {
- $this->given('an empty Kolab server')
- ->when('adding an invalid Kolab server object', $this->provideInvalidUserWithoutGivenName())
- ->then('the result should indicate an error with', 'Either the last name or the given name is missing!');
- }
-
- /**
- * @scenario
- */
- public function creatingUserWithoutLastName()
- {
- $this->given('an empty Kolab server')
- ->when('adding an invalid Kolab server object', $this->provideInvalidUserWithoutLastName())
- ->then('the result should indicate an error with', 'Either the last name or the given name is missing!');
- }
-
- /**
- * @scenario
- */
- public function creatingUserWithoutPassword()
- {
- $this->given('an empty Kolab server')
- ->when('adding an invalid Kolab server object', $this->provideInvalidUserWithoutPassword())
- ->then('the result should indicate an error with', 'The value for "userPassword" is missing!');
- }
-
- /**
- * @scenario
- */
- public function creatingUserWithoutPrimaryMail()
- {
- $this->given('an empty Kolab server')
- ->when('adding an invalid Kolab server object', $this->provideInvalidUserWithoutMail())
- ->then('the result should indicate an error with', 'The value for "mail" is missing!');
- }
-
- /**
- * @scenario
- */
public function creatingUserWithoutTypeCreatesStandardUser()
{
$this->given('an empty Kolab server')
$filter = '(&(objectClass=kolabInetOrgPerson)(uid=*)(mail=*)(sn=*))';
$attributes = array(
- KOLAB_ATTR_SN,
- KOLAB_ATTR_CN,
- KOLAB_ATTR_UID,
- KOLAB_ATTR_MAIL,
- KOLAB_ATTR_DELETED,
+ Horde_Kolab_Server_Object::ATTRIBUTE_SN,
+ Horde_Kolab_Server_Object::ATTRIBUTE_CN,
+ Horde_Kolab_Server_Object::ATTRIBUTE_UID,
+ Horde_Kolab_Server_Object::ATTRIBUTE_MAIL,
+ Horde_Kolab_Server_Object::ATTRIBUTE_DELETED,
);
- $sort = KOLAB_ATTR_SN;
+ $sort = Horde_Kolab_Server_Object::ATTRIBUTE_SN;
$result = $server->search($filter);
$this->assertNoError($result);
$this->assertEquals(2, count($result));
$testuser = $server->fetch('cn=Test Test,dc=example,dc=org');
$this->assertNoError($testuser);
$this->assertContains('wrobel@example.org',
- $testuser->get(KOLAB_ATTR_KOLABDELEGATE, false));
+ $testuser->get(Horde_Kolab_Server_Object::ATTRIBUTE_DELEGATE, false));
$this->assertNoError($addrs);
$this->assertContains('wrobel@example.org', $addrs);