diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/KolabAdmin/Unit/BaseTest.php | 53 |
1 files changed, 51 insertions, 2 deletions
diff --git a/test/KolabAdmin/Unit/BaseTest.php b/test/KolabAdmin/Unit/BaseTest.php index 9ee2d41..d75f49b 100644 --- a/test/KolabAdmin/Unit/BaseTest.php +++ b/test/KolabAdmin/Unit/BaseTest.php @@ -36,14 +36,63 @@ class KolabAdmin_Unit_BaseTest extends PHPUnit_Framework_TestCase { $_SESSION = array(); require '/kolab/etc/kolab/session_vars.php'; + $this->ldap = new KolabLdap(); + $this->ldap->bind( + 'cn=manager,cn=internal,' . $_SESSION['base_dn'], + 'test' + ); + $this->cleanup = array(); + } + + public function tearDown() + { + foreach ($this->cleanup as $dn) { + if (!$this->ldap->deleteObject($dn, true)) { + throw new Exception('Deleting ' . $dn . ' failed!'); + } + } } public function testCountmailReturnsZeroOnNonExistantMail() { - $ldap = new KolabLdap(); $this->assertEquals( 0, - $ldap->countMail($_SESSION['base_dn'], 'certainly@does@not@exist') + $this->ldap->countMail( + $_SESSION['base_dn'], + 'certainly@does@not@exist' + ) + ); + } + + public function testAddingObjectIsSuccessful() + { + $this->_add($this->_getTestUser()); + } + + private function _add($object) + { + if ($this->ldap->add($object['dn'], $object['attributes'])) { + $this->cleanup[] = $object['dn']; + } else { + throw new Exception('Adding ' . $object['dn'] . ' failed!'); + } + } + + private function _getTestUser($id = null) + { + return array( + 'dn' => 'cn=KolabAdmin TestUser' . $id . ',' . $_SESSION['base_dn'], + 'attributes' => array( + 'objectClass' => array( + 'top', 'inetOrgPerson', 'kolabInetOrgPerson' + ), + 'userPassword' => 'test', + 'sn' => 'TestUser' . $id, + 'cn' => 'KolabAdmin TestUser' . $id, + 'givenName' => 'KolabAdmin', + 'mail' => 'kolabadmin.test.' . $id . $_SESSION['base_dn'], + 'uid' => 'kolabadmin.test.' . $id, + ) ); } } |