Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
[ZF-9564]
Browse files Browse the repository at this point in the history
fixed behavior when updating and adding entries that have multiple values on an RDN attribute
updated test-suite to test behavior

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@22163 44c647ce-9c0f-0410-b52a-842ac1e357ba
  • Loading branch information
sgehrig committed May 14, 2010
1 parent 2d41fa5 commit 37761a1
Showing 1 changed file with 123 additions and 0 deletions.
123 changes: 123 additions & 0 deletions test/CrudTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,4 +383,127 @@ public function testRemoveObjectClass()
$this->fail($e->getMessage());
}
}

/**
* @group ZF-9564
*/
public function testAddingEntryWithMissingRdnAttribute() {
$dn = $this->_createDn('ou=TestCreated,');
$data = array(
'objectClass' => array('organizationalUnit')
);
try {
$this->_getLdap()->add($dn, $data);
$entry = $this->_getLdap()->getEntry($dn);
$this->_getLdap()->delete($dn);
$this->assertEquals(array('TestCreated'), $entry['ou']);

} catch (Zend_Ldap_Exception $e) {
if ($this->_getLdap()->exists($dn)) {
$this->_getLdap()->delete($dn);
}
$this->fail($e->getMessage());
}
}

/**
* @group ZF-9564
*/
public function testAddingEntryWithMissingRdnAttributeValue() {
$dn = $this->_createDn('ou=TestCreated,');
$data = array(
'ou' => array('SecondOu'),
'objectClass' => array('organizationalUnit')
);
try {
$this->_getLdap()->add($dn, $data);
$entry = $this->_getLdap()->getEntry($dn);
$this->_getLdap()->delete($dn);
$this->assertEquals(array('TestCreated', 'SecondOu'), $entry['ou']);

} catch (Zend_Ldap_Exception $e) {
if ($this->_getLdap()->exists($dn)) {
$this->_getLdap()->delete($dn);
}
$this->fail($e->getMessage());
}
}

/**
* @group ZF-9564
*/
public function testAddingEntryThatHasMultipleValuesOnRdnAttribute() {
$dn = $this->_createDn('ou=TestCreated,');
$data = array(
'ou' => array('TestCreated', 'SecondOu'),
'objectClass' => array('organizationalUnit')
);
try {
$this->_getLdap()->add($dn, $data);
$entry = $this->_getLdap()->getEntry($dn);
$this->_getLdap()->delete($dn);
$this->assertEquals(array('TestCreated', 'SecondOu'), $entry['ou']);

} catch (Zend_Ldap_Exception $e) {
if ($this->_getLdap()->exists($dn)) {
$this->_getLdap()->delete($dn);
}
$this->fail($e->getMessage());
}
}

/**
* @group ZF-9564
*/
public function testUpdatingEntryWithAttributeThatIsAnRdnAttribute() {
$dn = $this->_createDn('ou=TestCreated,');
$data = array(
'ou' => array('TestCreated'),
'objectClass' => array('organizationalUnit')
);
try {
$this->_getLdap()->add($dn, $data);
$entry = $this->_getLdap()->getEntry($dn);

$data = array('ou' => array_merge($entry['ou'], array('SecondOu')));
$this->_getLdap()->update($dn, $data);
$entry = $this->_getLdap()->getEntry($dn);
$this->_getLdap()->delete($dn);
$this->assertEquals(array('TestCreated', 'SecondOu'), $entry['ou']);

} catch (Zend_Ldap_Exception $e) {
if ($this->_getLdap()->exists($dn)) {
$this->_getLdap()->delete($dn);
}
$this->fail($e->getMessage());
}
}

/**
* @group ZF-9564
*/
public function testUpdatingEntryWithRdnAttributeValueMissingInData() {
$dn = $this->_createDn('ou=TestCreated,');
$data = array(
'ou' => array('TestCreated'),
'objectClass' => array('organizationalUnit')
);
try {
$this->_getLdap()->add($dn, $data);
$entry = $this->_getLdap()->getEntry($dn);

$data = array('ou' => 'SecondOu');
$this->_getLdap()->update($dn, $data);
$entry = $this->_getLdap()->getEntry($dn);
$this->_getLdap()->delete($dn);
$this->assertEquals(array('TestCreated', 'SecondOu'), $entry['ou']);

} catch (Zend_Ldap_Exception $e) {
if ($this->_getLdap()->exists($dn)) {
$this->_getLdap()->delete($dn);
}
$this->fail($e->getMessage());
}

}
}

0 comments on commit 37761a1

Please sign in to comment.