diff --git a/src/Attribute.php b/src/Attribute.php index a9469f44d..1da5ed321 100644 --- a/src/Attribute.php +++ b/src/Attribute.php @@ -20,6 +20,8 @@ namespace Zend\Ldap; +use DateTime; + /** * Zend\Ldap\Attribute is a collection of LDAP attribute related functions. * @@ -195,89 +197,27 @@ public static function removeFromAttribute(array &$data, $attribName, $value) */ private static function valueToLdap($value) { - if (is_string($value)) { - return $value; - } - else if (is_int($value) || is_float($value)) { - return (string)$value; - } - else if (is_bool($value)) { - return ($value === true) ? 'TRUE' : 'FALSE'; - } - else if (is_object($value) || is_array($value)) { - return serialize($value); - } - else if (is_resource($value) && get_resource_type($value) === 'stream') { - return stream_get_contents($value); - } - else { - return null; - } + return Converter\Converter::toLdap($value); } /** * @param string $value - * @return string|boolean + * @return mixed */ private static function valueFromLdap($value) { - $value = (string)$value; - if ($value === 'TRUE') { - return true; - } - else if ($value === 'FALSE') { - return false; - } - else { + try { + $return = Converter\Converter::fromLdap($value, Converter\Converter::STANDARD, false); + if ($return instanceof DateTime) { + return Converter\Converter::toLdapDateTime($return, false); + } else { + return $return; + } + } catch (Exception\InvalidArgumentException $e) { return $value; } } - /** - * Converts a PHP data type into its LDAP representation - * - * @param mixed $value - * @return string|null - null if the PHP data type cannot be converted. - */ - public static function convertToLdapValue($value) - { - return self::valueToLdap($value); - } - - /** - * Converts an LDAP value into its PHP data type - * - * @param string $value - * @return mixed - */ - public static function convertFromLdapValue($value) - { - return self::valueFromLdap($value); - } - - /** - * Converts a timestamp into its LDAP date/time representation - * - * @param integer $value - * @param boolean $utc - * @return string|null - null if the value cannot be converted. - */ - public static function convertToLdapDateTimeValue($value, $utc = false) - { - return self::valueToLdapDateTime($value, $utc); - } - - /** - * Converts LDAP date/time representation into a timestamp - * - * @param string $value - * @return integer|null - null if the value cannot be converted. - */ - public static function convertFromLdapDateTimeValue($value) - { - return self::valueFromLdapDateTime($value); - } - /** * Sets a LDAP password. * @@ -390,17 +330,13 @@ public static function setDateTimeAttribute( * @param boolean $utc * @return string|null */ - private static function valueToLDAPDateTime($value, $utc) + private static function valueToLdapDateTime($value, $utc) { if (is_int($value)) { - if ($utc === true) { - return gmdate('YmdHis', $value) . 'Z'; - } else { - return date('YmdHisO', $value); - } - } else { - return null; + return Converter\Converter::toLdapDateTime($value, $utc); } + + return null; } /** @@ -416,49 +352,35 @@ public static function getDateTimeAttribute(array $data, $attribName, $index = n $values = self::getAttribute($data, $attribName, $index); if (is_array($values)) { for ($i = 0; $i < count($values); $i++) { - $newVal = self::valueFromLDAPDateTime($values[$i]); + $newVal = self::valueFromLdapDateTime($values[$i]); if ($newVal !== null) { $values[$i] = $newVal; } } } else { - $newVal = self::valueFromLDAPDateTime($values); + $newVal = self::valueFromLdapDateTime($values); if ($newVal !== null) { $values = $newVal; } } + return $values; } /** - * @param string $value + * @param string|DateTime $value * @return integer|null */ - private static function valueFromLDAPDateTime($value) + private static function valueFromLdapDateTime($value) { - $matches = array(); - if (preg_match('/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(?:\.0)?([+-]\d{4}|Z)$/', $value, $matches)) { - $year = $matches[1]; - $month = $matches[2]; - $day = $matches[3]; - $hour = $matches[4]; - $minute = $matches[5]; - $second = $matches[6]; - $timezone = $matches[7]; - $date = gmmktime($hour, $minute, $second, $month, $day, $year); - if ($timezone !== 'Z') { - $tzDirection = substr($timezone, 0, 1); - $tzOffsetHour = substr($timezone, 1, 2); - $tzOffsetMinute = substr($timezone, 3, 2); - $tzOffset = ($tzOffsetHour * 60 * 60) + ($tzOffsetMinute * 60); - if ($tzDirection == '+') { - $date -= $tzOffset; - } else if ($tzDirection == '-') { - $date += $tzOffset; - } + if ($value instanceof DateTime) { + return $value->format('U'); + } else if (is_string($value)) { + try { + return Converter\Converter::fromLdapDateTime($value, false)->format('U'); + } catch (Converter\Exception\InvalidArgumentException $e) { + return null; } - - return $date; } return null; diff --git a/src/Converter.php b/src/Converter.php deleted file mode 100644 index 8639c3ad1..000000000 --- a/src/Converter.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @link http://pear.php.net/package/Net_LDAP2 - * @author Benedikt Hallinger - * - * @param string $string String to convert - * @return string - */ - public static function ascToHex32($string) - { - for ($i = 0; $i < strlen($string); $i++) { - $char = substr($string, $i, 1); - if (ord($char) < 32) { - $hex = dechex(ord($char)); - if (strlen($hex) == 1) { - $hex = '0' . $hex; - } - $string = str_replace($char, '\\' . $hex, $string); - } - } - return $string; - } - - /** - * Converts all Hex expressions ("\HEX") to their original ASCII characters - * - * @see Net_LDAP2_Util::hex2asc() from Benedikt Hallinger , - * heavily based on work from DavidSmith@byu.net - * @link http://pear.php.net/package/Net_LDAP2 - * @author Benedikt Hallinger , heavily based on work from DavidSmith@byu.net - * - * @param string $string String to convert - * @return string - */ - public static function hex32ToAsc($string) - { - $string = preg_replace('/\\\([0-9A-Fa-f]{2})/e', "''.chr(hexdec('\\1')).''", $string); - return $string; - } -} diff --git a/src/Converter/Converter.php b/src/Converter/Converter.php new file mode 100644 index 000000000..569814d6f --- /dev/null +++ b/src/Converter/Converter.php @@ -0,0 +1,409 @@ + + * @link http://pear.php.net/package/Net_LDAP2 + * @author Benedikt Hallinger + * + * @param string $string String to convert + * @return string + */ + public static function ascToHex32($string) + { + for ($i = 0; $i < strlen($string); $i++) { + $char = substr($string, $i, 1); + if (ord($char) < 32) { + $hex = dechex(ord($char)); + if (strlen($hex) == 1) { + $hex = '0' . $hex; + } + $string = str_replace($char, '\\' . $hex, $string); + } + } + return $string; + } + + /** + * Converts all Hex expressions ("\HEX") to their original ASCII characters + * + * @see Net_LDAP2_Util::hex2asc() from Benedikt Hallinger , + * heavily based on work from DavidSmith@byu.net + * @link http://pear.php.net/package/Net_LDAP2 + * @author Benedikt Hallinger , heavily based on work from DavidSmith@byu.net + * + * @param string $string String to convert + * @return string + */ + public static function hex32ToAsc($string) + { + $string = preg_replace('/\\\([0-9A-Fa-f]{2})/e', "''.chr(hexdec('\\1')).''", $string); + return $string; + } + + + /** + * Convert any value to an LDAP-compatible value. + * + * By setting the $type-parameter the conversion of a certain + * type can be forced + * + * @todo write more tests + * + * @param mixed $value The value to convert + * @param int $type The conversion type to use + * @return string|null + * @throws Exception\ConverterException + */ + public static function toLdap($value, $type = self::STANDARD) + { + try { + switch ($type) { + case self::BOOLEAN: + return self::toldapBoolean($value); + break; + case self::GENERALIZED_TIME: + return self::toLdapDatetime($value); + break; + default: + if (is_string($value)) { + return $value; + } else if (is_int($value) || is_float($value)) { + return (string)$value; + } else if (is_bool($value)) { + return self::toldapBoolean($value); + } else if (is_object($value)) { + if ($value instanceof DateTime) { + return self::toLdapDatetime($value); + } else if ($value instanceof Date) { + return self::toLdapDatetime($value); + } else { + return self::toLdapSerialize($value); + } + } else if (is_array($value)) { + return self::toLdapSerialize($value); + } else if (is_resource($value) && get_resource_type($value) === 'stream') { + return stream_get_contents($value); + } else { + return null; + } + break; + } + } catch (\Exception $e) { + throw new Exception\ConverterException($e->getMessage(), $e->getCode(), $e); + } + } + + /** + * Converts a date-entity to an LDAP-compatible date-string + * + * The date-entity $date can be either a timestamp, a + * DateTime Object, a string that is parseable by strtotime() or a Zend\Date\Date + * Object. + * + * @param integer|string|DateTime|Date $date The date-entity + * @param boolean $asUtc Whether to return the LDAP-compatible date-string as UTC or as local value + * @return string + * @throws Exception\InvalidArgumentException + */ + public static function toLdapDateTime($date, $asUtc = true) + { + if (!($date instanceof DateTime)) { + if (is_int($date)) { + $date = new DateTime('@' . $date); + $date->setTimezone(new DateTimeZone(date_default_timezone_get())); + } else if (is_string($date)) { + $date = new DateTime($date); + } else if ($date instanceof Date) { + $date = new DateTime($date->get(Date::ISO_8601)); + } else { + throw new Exception\InvalidArgumentException('Parameter $date is not of the expected type'); + } + } + $timezone = $date->format('O'); + if (true === $asUtc) { + $date->setTimezone(new DateTimeZone('UTC')); + $timezone = 'Z'; + } + if ('+0000' === $timezone) { + $timezone = 'Z'; + } + return $date->format('YmdHis') . $timezone; + } + + /** + * Convert a boolean value to an LDAP-compatible string + * + * This converts a boolean value of TRUE, an integer-value of 1 and a + * case-insensitive string 'true' to an LDAP-compatible 'TRUE'. All other + * other values are converted to an LDAP-compatible 'FALSE'. + * + * @param boolean|integer|string $value The boolean value to encode + * @return string + */ + public static function toLdapBoolean($value) + { + $return = 'FALSE'; + if (!is_scalar($value)) { + return $return; + } + if (true === $value || 'true' === strtolower($value) || 1 === $value) { + $return = 'TRUE'; + } + return $return; + } + + /** + * Serialize any value for storage in LDAP + * + * @param mixed $value The value to serialize + * @return string + */ + public static function toLdapSerialize($value) + { + return serialize($value); + } + + /** + * Convert an LDAP-compatible value to a corresponding PHP-value. + * + * By setting the $type-parameter the conversion of a certain + * type can be forced. + * + * @see Converter::STANDARD + * @see Converter::BOOLEAN + * @see Converter::GENERALIZED_TIME + * @param string $value The value to convert + * @param int $type The conversion type to use + * @param boolean $dateTimeAsUtc Return DateTime values in UTC timezone + * @return mixed + */ + public static function fromLdap($value, $type = self::STANDARD, $dateTimeAsUtc = true) + { + switch ($type) { + case self::BOOLEAN: + return self::fromldapBoolean($value); + break; + case self::GENERALIZED_TIME: + return self::fromLdapDateTime($value); + break; + default: + if (is_numeric($value)) { + // prevent numeric values to be treated as date/time + return $value; + } else if ('TRUE' === $value || 'FALSE' === $value) { + return self::fromLdapBoolean($value); + } + if (preg_match('/^\d{4}[\d\+\-Z\.]*$/', $value)) { + return self::fromLdapDateTime($value, $dateTimeAsUtc); + } + try { + return self::fromLdapUnserialize($value); + } catch (Exception\UnexpectedValueException $e) { + // Do nothing + } + break; + } + + return $value; + } + + /** + * Convert an LDAP-Generalized-Time-entry into a DateTime-Object + * + * CAVEAT: The DateTime-Object returned will always be set to UTC-Timezone. + * + * @param string $date The generalized-Time + * @param boolean $asUtc Return the DateTime with UTC timezone + * @return DateTime + * @throws Exception\InvalidArgumentException if a non-parseable-format is given + */ + public static function fromLdapDateTime($date, $asUtc = true) + { + $datepart = array(); + if (!preg_match('/^(\d{4})/', $date, $datepart)) { + throw new Exception\InvalidArgumentException('Invalid date format found'); + } + + if ($datepart[1] < 4) { + throw new Exception\InvalidArgumentException('Invalid date format found (too short)'); + } + + $time = array( + // The year is mandatory! + 'year' => $datepart[1], + 'month' => 1, + 'day' => 1, + 'hour' => 0, + 'minute' => 0, + 'second' => 0, + 'offdir' => '+', + 'offsethours' => 0, + 'offsetminutes' => 0 + ); + + $length = strlen($date); + + // Check for month. + if ($length >= 6) { + $month = substr($date, 4, 2); + if ($month < 1 || $month > 12) { + throw new Exception\InvalidArgumentException('Invalid date format found (invalid month)'); + } + $time['month'] = $month; + } + + // Check for day + if ($length >= 8) { + $day = substr($date, 6, 2); + if ($day < 1 || $day > 31) { + throw new Exception\InvalidArgumentException('Invalid date format found (invalid day)'); + } + $time['day'] = $day; + } + + // Check for Hour + if ($length >= 10) { + $hour = substr($date, 8, 2); + if ($hour < 0 || $hour > 23) { + throw new Exception\InvalidArgumentException('Invalid date format found (invalid hour)'); + } + $time['hour'] = $hour; + } + + // Check for minute + if ($length >= 12) { + $minute = substr($date, 10, 2); + if ($minute < 0 || $minute > 59) { + throw new Exception\InvalidArgumentException('Invalid date format found (invalid minute)'); + } + $time['minute'] = $minute; + } + + // Check for seconds + if ($length >= 14) { + $second = substr($date, 12, 2); + if ($second < 0 || $second > 59) { + throw new Exception\InvalidArgumentException('Invalid date format found (invalid second)'); + } + $time['second'] = $second; + } + + // Set Offset + $offsetRegEx = '/([Z\-\+])(\d{2}\'?){0,1}(\d{2}\'?){0,1}$/'; + $off = array(); + if (preg_match($offsetRegEx, $date, $off)) { + $offset = $off[1]; + if ($offset == '+' || $offset == '-') { + $time['offdir'] = $offset; + // we have an offset, so lets calculate it. + if (isset($off[2])) { + $offsetHours = substr($off[2], 0, 2); + if ($offsetHours < 0 || $offsetHours > 12) { + throw new Exception\InvalidArgumentException('Invalid date format found (invalid offset hour)'); + } + $time['offsethours'] = $offsetHours; + } + if (isset($off[3])) { + $offsetMinutes = substr($off[3], 0, 2); + if ($offsetMinutes < 0 || $offsetMinutes > 59) { + throw new Exception\InvalidArgumentException('Invalid date format found (invalid offset minute)'); + } + $time['offsetminutes'] = $offsetMinutes; + } + } + } + + // Raw-Data is present, so lets create a DateTime-Object from it. + $offset = $time['offdir'] + . str_pad($time['offsethours'], 2, '0', STR_PAD_LEFT) + . str_pad($time['offsetminutes'], 2, '0', STR_PAD_LEFT); + $timestring = $time['year'] . '-' + . str_pad($time['month'], 2, '0', STR_PAD_LEFT) . '-' + . str_pad($time['day'], 2, '0', STR_PAD_LEFT) . ' ' + . str_pad($time['hour'], 2, '0', STR_PAD_LEFT) . ':' + . str_pad($time['minute'], 2, '0', STR_PAD_LEFT) . ':' + . str_pad($time['second'], 2, '0', STR_PAD_LEFT) + . $time['offdir'] + . str_pad($time['offsethours'], 2, '0', STR_PAD_LEFT) + . str_pad($time['offsetminutes'], 2, '0', STR_PAD_LEFT); + $date = new DateTime($timestring); + if ($asUtc) { + $date->setTimezone(new DateTimeZone('UTC')); + } + return $date; + } + + /** + * Convert an LDAP-compatible boolean value into a PHP-compatible one + * + * @param string $value The value to convert + * @return boolean + * @throws Exception\InvalidArgumentException + */ + public static function fromLdapBoolean($value) + { + if ('TRUE' === $value) { + return true; + } else if ('FALSE' === $value) { + return false; + } else { + throw new Exception\InvalidArgumentException('The given value is not a boolean value'); + } + } + + /** + * Unserialize a serialized value to return the corresponding object + * + * @param string $value The value to convert + * @return mixed + * @throws Exception\UnexpectedValueException + */ + public static function fromLdapUnserialize($value) + { + $v = @unserialize($value); + if (false === $v && $value != 'b:0;') { + throw new Exception\UnexpectedValueException('The given value could not be unserialized'); + } + return $v; + } +} diff --git a/src/Converter/Exception/ConverterException.php b/src/Converter/Exception/ConverterException.php new file mode 100644 index 000000000..46896135d --- /dev/null +++ b/src/Converter/Exception/ConverterException.php @@ -0,0 +1,31 @@ +', ';', '#', '=',), array('\\\\', '\,', '\+', '\"', '\<', '\>', '\;', '\#', '\='), $val ); - $val = Converter::ascToHex32($val); + $val = Converter\Converter::ascToHex32($val); // Convert all leading and trailing spaces to sequences of \20. if (preg_match('/^(\s*)(.+?)(\s*)$/', $val, $matches)) { @@ -539,7 +539,7 @@ public static function unescapeValue($values = array()) array('\\\\', '\,', '\+', '\"', '\<', '\>', '\;', '\#', '\='), array('\\', ',', '+', '"', '<', '>', ';', '#', '=',), $val ); - $values[$key] = Converter::hex32ToAsc($val); + $values[$key] = Converter\Converter::hex32ToAsc($val); } return (count($values) == 1) ? $values[0] : $values; } diff --git a/src/Filter/AbstractFilter.php b/src/Filter/AbstractFilter.php index ac679bb27..11ae6fef6 100644 --- a/src/Filter/AbstractFilter.php +++ b/src/Filter/AbstractFilter.php @@ -21,7 +21,7 @@ namespace Zend\Ldap\Filter; -use Zend\Ldap; +use Zend\Ldap\Converter\Converter; /** * Zend\Ldap\Filter\AbstractFilter provides a base implementation for filters. @@ -110,7 +110,7 @@ public static function escapeValue($values = array()) // Escaping of filter meta characters $val = str_replace(array('\\', '*', '(', ')'), array('\5c', '\2a', '\28', '\29'), $val); // ASCII < 32 escaping - $val = Ldap\Converter::ascToHex32($val); + $val = Converter::ascToHex32($val); if (null === $val) { $val = '\0'; // apply escaped "null" if string is empty } @@ -137,7 +137,7 @@ public static function unescapeValue($values = array()) } foreach ($values as $key => $value) { // Translate hex code into ascii - $values[$key] = Ldap\Converter::hex32ToAsc($value); + $values[$key] = Converter::hex32ToAsc($value); } return (count($values) == 1) ? $values[0] : $values; } diff --git a/src/Ldap.php b/src/Ldap.php index abd994a08..4b1dbb844 100644 --- a/src/Ldap.php +++ b/src/Ldap.php @@ -846,6 +846,8 @@ public function bind($username = null, $password = null) * - attributes * - sort * - collectionClass + * - sizelimit + * - timelimit * * @param string|Filter\AbstractFilter|array $filter * @param string|Dn|null $basedn @@ -853,12 +855,13 @@ public function bind($username = null, $password = null) * @param array $attributes * @param string|null $sort * @param string|null $collectionClass + * @param integer $sizelimit + * @param integer $timelimit * @return Collection * @throws Exception\LdapException */ - public function search( - $filter, $basedn = null, $scope = self::SEARCH_SCOPE_SUB, - array $attributes = array(), $sort = null, $collectionClass = null + public function search($filter, $basedn = null, $scope = self::SEARCH_SCOPE_SUB, array $attributes = array(), + $sort = null, $collectionClass = null, $sizelimit = 0, $timelimit = 0 ) { if (is_array($filter)) { @@ -879,6 +882,10 @@ public function search( case 'collectionclass': $collectionClass = $value; break; + case 'sizelimit': + case 'timelimit': + $$key = (int)$value; + break; } } } @@ -895,14 +902,14 @@ public function search( switch ($scope) { case self::SEARCH_SCOPE_ONE: - $search = @ldap_list($this->getResource(), $basedn, $filter, $attributes); + $search = @ldap_list($this->getResource(), $basedn, $filter, $attributes, 0, $sizelimit, $timelimit); break; case self::SEARCH_SCOPE_BASE: - $search = @ldap_read($this->getResource(), $basedn, $filter, $attributes); + $search = @ldap_read($this->getResource(), $basedn, $filter, $attributes, 0, $sizelimit, $timelimit); break; case self::SEARCH_SCOPE_SUB: default: - $search = @ldap_search($this->getResource(), $basedn, $filter, $attributes); + $search = @ldap_search($this->getResource(), $basedn, $filter, $attributes, 0, $sizelimit, $timelimit); break; } @@ -1007,6 +1014,8 @@ public function exists($dn) * - attributes * - sort * - reverseSort + * - sizelimit + * - timelimit * * @param string|Filter\AbstractFilter|array $filter * @param string|Dn|null $basedn @@ -1014,13 +1023,15 @@ public function exists($dn) * @param array $attributes * @param string|null $sort * @param boolean $reverseSort + * @param integer $sizelimit + * @param integer $timelimit * @return array * @throws Exception\LdapException */ - public function searchEntries( - $filter, $basedn = null, $scope = self::SEARCH_SCOPE_SUB, - array $attributes = array(), $sort = null, $reverseSort = false - ) { + public function searchEntries($filter, $basedn = null, $scope = self::SEARCH_SCOPE_SUB, + array $attributes = array(), $sort = null, $reverseSort = false, $sizelimit = 0, + $timelimit = 0) + { if (is_array($filter)) { $filter = array_change_key_case($filter, CASE_LOWER); if (isset($filter['collectionclass'])) { @@ -1031,7 +1042,7 @@ public function searchEntries( unset($filter['reversesort']); } } - $result = $this->search($filter, $basedn, $scope, $attributes, $sort); + $result = $this->search($filter, $basedn, $scope, $attributes, $sort, null, $sizelimit, $timelimit); $items = $result->toArray(); if ((bool)$reverseSort === true) { $items = array_reverse($items, false); diff --git a/src/Node.php b/src/Node.php index 7fb968e18..9f0628b44 100644 --- a/src/Node.php +++ b/src/Node.php @@ -21,6 +21,8 @@ namespace Zend\Ldap; +use Zend\EventManager\EventManager; + /** * Zend\Ldap\Node provides an object oriented view into a LDAP node. * @@ -58,8 +60,8 @@ class Node extends Node\AbstractNode implements \Iterator, \RecursiveIterator * * @var boolean */ - protected $delete; + /** * Holds the connection to the LDAP server if in connected mode. * @@ -70,7 +72,7 @@ class Node extends Node\AbstractNode implements \Iterator, \RecursiveIterator /** * Holds an array of the current node's children. * - * @var array + * @var Node[] */ protected $children; @@ -81,6 +83,9 @@ class Node extends Node\AbstractNode implements \Iterator, \RecursiveIterator */ private $iteratorRewind = false; + /** @var EventManager */ + protected $events; + /** * Constructor. * @@ -200,6 +205,24 @@ public function isAttached() return ($this->ldap !== null); } + /** + * Trigger an event + * + * @param string $event Event name + * @param array|\ArrayAccess $argv Array of arguments; typically, should be associative + */ + protected function triggerEvent($event, $argv = array()) + { + if (null === $this->events) { + if (class_exists('\Zend\EventManager\EventManager')) { + $this->events = new EventManager(__CLASS__); + } else { + return; + } + } + $this->events->trigger($event, $this, $argv); + } + /** * @param array $data * @param boolean $fromDataSource @@ -298,12 +321,17 @@ public static function fromArray(array $data, $fromDataSource = false) /** * Ensures that teh RDN attributes are correctly set. * + * @param boolean $overwrite True to overwrite the RDN attributes * @return void */ - protected function ensureRdnAttributeValues() + protected function ensureRdnAttributeValues($overwrite = false) { foreach ($this->getRdnArray() as $key => $value) { - Attribute::setAttribute($this->currentData, $key, $value, false); + if (!array_key_exists($key, $this->currentData) || $overwrite) { + Attribute::setAttribute($this->currentData, $key, $value, false); + } else if (!in_array($value, $this->currentData[$key])) { + Attribute::setAttribute($this->currentData, $key, $value, true); + } } } @@ -391,6 +419,14 @@ public function willBeMoved() * @param Ldap $ldap * @return Node Provides a fluid interface * @throws Exception\LdapException + * @trigger pre-delete + * @trigger post-delete + * @trigger pre-add + * @trigger post-add + * @trigger pre-rename + * @trigger post-rename + * @trigger pre-update + * @trigger post-update */ public function update(Ldap $ldap = null) { @@ -404,20 +440,26 @@ public function update(Ldap $ldap = null) if ($this->willBeDeleted()) { if ($ldap->exists($this->dn)) { + $this->triggerEvent('pre-delete'); $ldap->delete($this->dn); + $this->triggerEvent('post-delete'); } return $this; } if ($this->isNew()) { + $this->triggerEvent('pre-add'); $data = $this->getData(); $ldap->add($this->_getDn(), $data); $this->loadData($data, true); + $this->triggerEvent('post-add'); + return $this; } $changedData = $this->getChangedData(); if ($this->willBeMoved()) { + $this->triggerEvent('pre-rename'); $recursive = $this->hasChildren(); $ldap->rename($this->dn, $this->newDn, $recursive, false); foreach ($this->newDn->getRdn() as $key => $value) { @@ -427,9 +469,12 @@ public function update(Ldap $ldap = null) } $this->dn = $this->newDn; $this->newDn = null; + $this->triggerEvent('post-rename'); } if (count($changedData) > 0) { + $this->triggerEvent('pre-update'); $ldap->update($this->_getDn(), $changedData); + $this->triggerEvent('post-update'); } $this->originalData = $this->currentData; @@ -479,7 +524,7 @@ public function setDn($newDn) } else { $this->newDn = Dn::factory($newDn); } - $this->ensureRdnAttributeValues(); + $this->ensureRdnAttributeValues(true); return $this; } diff --git a/src/Node/AbstractNode.php b/src/Node/AbstractNode.php index 4e58aa031..e218f124b 100644 --- a/src/Node/AbstractNode.php +++ b/src/Node/AbstractNode.php @@ -35,11 +35,12 @@ */ abstract class AbstractNode implements \ArrayAccess, \Countable { - protected static $systemAttributes=array('createtimestamp', 'creatorsname', - 'entrycsn', 'entrydn', 'entryuuid', 'hassubordinates', 'modifiersname', - 'modifytimestamp', 'structuralobjectclass', 'subschemasubentry', - 'distinguishedname', 'instancetype', 'name', 'objectcategory', 'objectguid', - 'usnchanged', 'usncreated', 'whenchanged', 'whencreated'); + protected static $systemAttributes = array('createtimestamp', 'creatorsname', + 'entrycsn', 'entrydn', 'entryuuid', 'hassubordinates', 'modifiersname', + 'modifytimestamp', 'structuralobjectclass', 'subschemasubentry', + 'distinguishedname', 'instancetype', 'name', 'objectcategory', + 'objectguid', + 'usnchanged', 'usncreated', 'whenchanged', 'whencreated'); /** * Holds the node's DN. @@ -330,8 +331,7 @@ public function getAttribute($name, $index = null) { if ($name == 'dn') { return $this->getDnString(); - } - else { + } else { return Ldap\Attribute::getAttribute($this->currentData, $name, $index); } } diff --git a/src/Node/Collection.php b/src/Node/Collection.php index 3cdabfdbb..e488ead20 100644 --- a/src/Node/Collection.php +++ b/src/Node/Collection.php @@ -24,7 +24,7 @@ use Zend\Ldap; /** - * Zend\Ldap\Node\Collection provides a collecion of nodes. + * Zend\Ldap\Node\Collection provides a collection of nodes. * * @category Zend * @package Zend_Ldap diff --git a/src/Node/RootDse/ActiveDirectory.php b/src/Node/RootDse/ActiveDirectory.php index d88b6a643..003e9e98e 100644 --- a/src/Node/RootDse/ActiveDirectory.php +++ b/src/Node/RootDse/ActiveDirectory.php @@ -21,8 +21,8 @@ namespace Zend\Ldap\Node\RootDse; -use Zend\Ldap, - Zend\Ldap\Node; +use Zend\Ldap; +use Zend\Ldap\Node; /** * Zend\Ldap\Node\RootDse\ActiveDirectory provides a simple data-container for diff --git a/src/Node/Schema/OpenLdap.php b/src/Node/Schema/OpenLdap.php index 8feaca818..9a438f7aa 100644 --- a/src/Node/Schema/OpenLdap.php +++ b/src/Node/Schema/OpenLdap.php @@ -21,8 +21,9 @@ namespace Zend\Ldap\Node\Schema; -use Zend\Ldap, - Zend\Ldap\Node; +use Zend\Ldap; +use Zend\Ldap\Converter; +use Zend\Ldap\Node; /** * Zend\Ldap\Node\Schema\OpenLDAP provides a simple data-container for the Schema node of @@ -461,12 +462,12 @@ protected function parseLdapSchemaSyntax(array &$data, array $tokens) break; } if ($tmp != '$') { - $data[$token][] = Ldap\Attribute::convertFromLdapValue($tmp); + $data[$token][] = Converter\Converter::fromLdap($tmp); } $tmp = array_shift($tokens); } } else { - $data[$token] = Ldap\Attribute::convertFromLdapValue($data[$token]); + $data[$token] = Converter\Converter::fromLdap($data[$token]); } // create a array if the value should be multivalued but was not if (in_array($token, $multiValue) && !is_array($data[$token])) { diff --git a/test/AttributeTest.php b/test/AttributeTest.php index 2e6219a59..4cb40876f 100644 --- a/test/AttributeTest.php +++ b/test/AttributeTest.php @@ -35,7 +35,16 @@ class AttributeTest extends \PHPUnit_Framework_TestCase { protected function assertLocalDateTimeString($timestamp, $value) { - $this->assertEquals(date('YmdHisO', $timestamp), $value); + $tsValue = date('YmdHisO', $timestamp); + + if(date('O', strtotime('20120101'))) { + // Local timezone is +0000 when DST is off. Zend_Ldap converts + // +0000 to "Z" (see Zend\Ldap\Converter\Converter:toLdapDateTime()), so + // take account of that here + $tsValue = str_replace('+0000', 'Z', $tsValue); + } + + $this->assertEquals($tsValue, $value); } protected function assertUtcDateTimeString($localTimestamp, $value) @@ -393,33 +402,6 @@ public function testRemoveAttributeValueInteger() $this->assertNotContains('4', $data['test']); } - public function testConvertFromLDAPValue() - { - $this->assertEquals(true, Attribute::convertFromLDAPValue('TRUE')); - $this->assertEquals(false, Attribute::convertFromLDAPValue('FALSE')); - } - - public function testConvertToLDAPValue() - { - $this->assertEquals('string', Attribute::convertToLDAPValue('string')); - $this->assertEquals('1', Attribute::convertToLDAPValue(1)); - $this->assertEquals('TRUE', Attribute::convertToLDAPValue(true)); - } - - public function testConvertFromLDAPDateTimeValue() - { - $ldap = '20080625123030+0200'; - $this->assertEquals(gmmktime(10, 30, 30, 6, 25, 2008), - Attribute::convertFromLDAPDateTimeValue($ldap) - ); - } - - public function testConvertToLDAPDateTimeValue() - { - $ts = mktime(12, 30, 30, 6, 25, 2008); - $this->assertLocalDateTimeString($ts, Attribute::convertToLDAPDateTimeValue($ts)); - } - public function testRemoveDuplicates() { $data = array( diff --git a/test/BindTest.php b/test/BindTest.php index 65fbf4d94..fcbf8f42a 100644 --- a/test/BindTest.php +++ b/test/BindTest.php @@ -21,8 +21,8 @@ namespace ZendTest\Ldap; -use Zend\Ldap, - Zend\Ldap\Exception; +use Zend\Ldap; +use Zend\Ldap\Exception; /* Note: The ldap_connect function does not actually try to connect. This * is why many tests attempt to bind with invalid credentials. If the diff --git a/test/CanonTest.php b/test/CanonTest.php index 6e0635a3c..385ac9842 100644 --- a/test/CanonTest.php +++ b/test/CanonTest.php @@ -21,8 +21,8 @@ namespace ZendTest\Ldap; -use Zend\Ldap, - Zend\Ldap\Exception; +use Zend\Ldap; +use Zend\Ldap\Exception; /* Note: The ldap_connect function does not actually try to connect. This * is why many tests attempt to bind with invalid credentials. If the diff --git a/test/ChangePasswordTest.php b/test/ChangePasswordTest.php index 2849dc6ee..b9c0637ba 100644 --- a/test/ChangePasswordTest.php +++ b/test/ChangePasswordTest.php @@ -21,9 +21,9 @@ namespace ZendTest\Ldap; -use Zend\Ldap, - Zend\Ldap\Exception, - Zend\Ldap\Node; +use Zend\Ldap; +use Zend\Ldap\Exception; +use Zend\Ldap\Node; /** * @category Zend diff --git a/test/ConnectTest.php b/test/ConnectTest.php index e6ab4a4f4..ccc412304 100644 --- a/test/ConnectTest.php +++ b/test/ConnectTest.php @@ -21,8 +21,8 @@ namespace ZendTest\Ldap; -use Zend\Ldap, - Zend\Ldap\Exception; +use Zend\Ldap; +use Zend\Ldap\Exception; /* Note: The ldap_connect function does not actually try to connect. This * is why many tests attempt to bind with invalid credentials. If the diff --git a/test/Converter/ConverterTest.php b/test/Converter/ConverterTest.php new file mode 100644 index 000000000..212e06ee2 --- /dev/null +++ b/test/Converter/ConverterTest.php @@ -0,0 +1,264 @@ +?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`' . + 'abcdefghijklmnopqrstuvwxyz{|}~'; + $str = ''; + for ($i = 0; $i < 127; $i++) { + $str .= chr($i); + } + $this->assertEquals($expected, Converter::ascToHex32($str)); + } + + public function testHex2asc() + { + $expected = ''; + for ($i = 0; $i < 127; $i++) { + $expected .= chr($i); + } + + $str = '\00\01\02\03\04\05\06\07\08\09\0a\0b\0c\0d\0e\0f\10\11\12\13\14\15\16\17\18\19\1a\1b' . + '\1c\1d\1e\1f !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefg' . + 'hijklmnopqrstuvwxyz{|}~'; + $this->assertEquals($expected, Converter::hex32ToAsc($str)); + } + + /** + * @dataProvider toLdapDateTimeProvider + */ + public function testToLdapDateTime($convert, $expect) + { + $result = Converter::toLdapDatetime($convert['date'], $convert['utc']); + $this->assertEquals($expect, $result); + } + + public function toLdapDateTimeProvider() + { + $tz = new DateTimeZone('UTC'); + return array( + array(array('date'=> 0, + 'utc' => true), '19700101000000Z'), + array(array('date'=> new DateTime('2010-05-12 13:14:45+0300', $tz), + 'utc' => false), '20100512131445+0300'), + array(array('date'=> new DateTime('2010-05-12 13:14:45+0300', $tz), + 'utc' => true), '20100512101445Z'), + array(array('date'=> '2010-05-12 13:14:45+0300', + 'utc' => false), '20100512131445+0300'), + array(array('date'=> '2010-05-12 13:14:45+0300', + 'utc' => true), '20100512101445Z'), + array(array('date'=> new Date('2010-05-12T13:14:45+0300', Date::ISO_8601), + 'utc' => true), '20100512101445Z'), + array(array('date'=> new Date('2010-05-12T13:14:45+0300', Date::ISO_8601), + 'utc' => false), '20100512131445+0300'), + array(array('date'=> new Date('0', Date::TIMESTAMP), + 'utc' => true), '19700101000000Z'), + ); + } + + /** + * @dataProvider toLdapBooleanProvider + */ + public function testToLdapBoolean($expect, $convert) + { + $this->assertEquals($expect, Converter::toldapBoolean($convert)); + } + + public function toLdapBooleanProvider() + { + return array( + array('TRUE', true), + array('TRUE', 1), + array('TRUE', 'true'), + array('FALSE', 'false'), + array('FALSE', false), + array('FALSE', array('true')), + array('FALSE', array('false')), + ); + } + + /** + * @dataProvider toLdapSerializeProvider + */ + public function testToLdapSerialize($expect, $convert) + { + $this->assertEquals($expect, Converter::toLdapSerialize($convert)); + } + + public function toLdapSerializeProvider() + { + return array( + array('N;', null), + array('i:1;', 1), + array('O:8:"DateTime":3:{s:4:"date";s:19:"1970-01-01 00:00:00";s:13:"timezone_type";i:1;s:8:"timezone";s:6:"+00:00";}', + new DateTime('@0')), + array('a:3:{i:0;s:4:"test";i:1;i:1;s:3:"foo";s:3:"bar";}', array('test', 1, + 'foo'=> 'bar')), + ); + } + + /** + * @dataProvider toLdapProvider + */ + public function testToLdap($expect, $convert) + { + $this->assertEquals($expect, Converter::toLdap($convert['value'], $convert['type'])); + } + + public function toLdapProvider() + { + return array( + array(null, array('value' => null, + 'type' => 0)), + array('19700101000000Z', array('value'=> 0, + 'type' => 2)), + array('0', array('value'=> 0, + 'type' => 0)), + array('FALSE', array('value'=> 0, + 'type' => 1)), + array('19700101000000Z', array('value'=> new Date('1970-01-01T00:00:00+0000', Date::ISO_8601), + 'type' => 0)), + + ); + } + + /** + * @dataProvider fromLdapUnserializeProvider + */ + public function testFromLdapUnserialize($expect, $convert) + { + $this->assertEquals($expect, Converter::fromLdapUnserialize($convert)); + } + + public function testFromLdapUnserializeThrowsException() + { + $this->setExpectedException('UnexpectedValueException'); + Converter::fromLdapUnserialize('--'); + } + + public function fromLdapUnserializeProvider() + { + return array( + array(null, 'N;'), + array(1, 'i:1;'), + array(false, 'b:0;'), + ); + } + + public function testFromLdapBoolean() + { + $this->assertTrue(Converter::fromLdapBoolean('TRUE')); + $this->assertFalse(Converter::fromLdapBoolean('FALSE')); + $this->setExpectedException('InvalidArgumentException'); + Converter::fromLdapBoolean('test'); + } + + /** + * @dataProvider fromLdapDateTimeProvider + */ + public function testFromLdapDateTime($expected, $convert, $utc) + { + if (true === $utc) { + $expected->setTimezone(new DateTimeZone('UTC')); + } + $this->assertEquals($expected, Converter::fromLdapDatetime($convert, $utc)); + } + + public function fromLdapDateTimeProvider() + { + return array( + array(new DateTime('2010-12-24 08:00:23+0300'), '20101224080023+0300', false), + array(new DateTime('2010-12-24 08:00:23+0300'), '20101224080023+03\'00\'', false), + array(new DateTime('2010-12-24 08:00:23+0000'), '20101224080023', false), + array(new DateTime('2010-12-24 08:00:00+0000'), '201012240800', false), + array(new DateTime('2010-12-24 08:00:00+0000'), '2010122408', false), + array(new DateTime('2010-12-24 00:00:00+0000'), '20101224', false), + array(new DateTime('2010-12-01 00:00:00+0000'), '201012', false), + array(new DateTime('2010-01-01 00:00:00+0000'), '2010', false), + array(new DateTime('2010-04-03 12:23:34+0000'), '20100403122334', true), + ); + } + + /** + * @expectedException InvalidArgumentException + * @dataProvider fromLdapDateTimeException + */ + public function testFromLdapDateTimeThrowsException($value) + { + Converter::fromLdapDatetime($value); + } + + public static function fromLdapDateTimeException() + { + return array( + array('foobar'), + array('201'), + array('201013'), + array('20101232'), + array('2010123124'), + array('201012312360'), + array('20101231235960'), + array('20101231235959+13'), + array('20101231235959+1160'), + ); + } + + /** + * @dataProvider fromLdapProvider + */ + public function testFromLdap($expect, $value, $type, $dateTimeAsUtc) + { + $this->assertSame($expect, Converter::fromLdap($value, $type, $dateTimeAsUtc)); + } + + public function fromLdapProvider() + { + return array( + array('1', '1', 0, true), + array('0', '0', 0, true), + array(true, 'TRUE', 0, true), + array(false, 'FALSE', 0, true), + array('123456789', '123456789', 0, true), + // ZF-11639 + array('+123456789', '+123456789', 0, true), + ); + } +} + diff --git a/test/ConverterTest.php b/test/ConverterTest.php deleted file mode 100644 index ed53cf9a2..000000000 --- a/test/ConverterTest.php +++ /dev/null @@ -1,61 +0,0 @@ -?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`' . - 'abcdefghijklmnopqrstuvwxyz{|}~'; - $str = ''; - for ($i = 0; $i < 127; $i++) { - $str .= chr($i); - } - $this->assertEquals($expected, Ldap\Converter::ascToHex32($str)); - } - - public function testHex2asc() - { - $expected = ''; - for ($i = 0; $i < 127; $i++) { - $expected .= chr($i); - } - - $str = '\00\01\02\03\04\05\06\07\08\09\0a\0b\0c\0d\0e\0f\10\11\12\13\14\15\16\17\18\19\1a\1b' . - '\1c\1d\1e\1f !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefg' . - 'hijklmnopqrstuvwxyz{|}~'; - $this->assertEquals($expected, Ldap\Converter::hex32ToAsc($str)); - } -} - diff --git a/test/CrudTest.php b/test/CrudTest.php index 29f68f4b3..78b37e437 100644 --- a/test/CrudTest.php +++ b/test/CrudTest.php @@ -21,8 +21,8 @@ namespace ZendTest\Ldap; -use Zend\Ldap, - Zend\Ldap\Exception; +use Zend\Ldap; +use Zend\Ldap\Exception; /** * @category Zend diff --git a/test/FilterTest.php b/test/FilterTest.php index b7fdad6d1..cf0a754a8 100644 --- a/test/FilterTest.php +++ b/test/FilterTest.php @@ -21,8 +21,8 @@ namespace ZendTest\Ldap; -use Zend\Ldap, - Zend\Ldap\Filter; +use Zend\Ldap; +use Zend\Ldap\Filter; /** * @category Zend diff --git a/test/Ldif/SimpleDecoderTest.php b/test/Ldif/SimpleDecoderTest.php index e37472364..cc77b8fa6 100644 --- a/test/Ldif/SimpleDecoderTest.php +++ b/test/Ldif/SimpleDecoderTest.php @@ -21,8 +21,8 @@ namespace ZendTest\Ldap\Ldif; -use Zend\Ldap\Ldif, - ZendTest\Ldap as TestLdap; +use Zend\Ldap\Ldif; +use ZendTest\Ldap as TestLdap; /** * @category Zend diff --git a/test/Ldif/SimpleEncoderTest.php b/test/Ldif/SimpleEncoderTest.php index 8769d0219..c76a343ee 100644 --- a/test/Ldif/SimpleEncoderTest.php +++ b/test/Ldif/SimpleEncoderTest.php @@ -21,8 +21,8 @@ namespace ZendTest\Ldap\Ldif; -use Zend\Ldap\Ldif, - ZendTest\Ldap as TestLdap; +use Zend\Ldap\Ldif; +use ZendTest\Ldap as TestLdap; /** * @category Zend diff --git a/test/Node/ChildrenIterationTest.php b/test/Node/ChildrenIterationTest.php index 758e3eaa0..88ed330a1 100644 --- a/test/Node/ChildrenIterationTest.php +++ b/test/Node/ChildrenIterationTest.php @@ -21,8 +21,8 @@ namespace ZendTest\Ldap\Node; -use Zend\Ldap, - ZendTest\Ldap as TestLdap; +use Zend\Ldap; +use ZendTest\Ldap as TestLdap; /** * @category Zend diff --git a/test/Node/OfflineTest.php b/test/Node/OfflineTest.php index 74ad749e3..9271dc0b5 100644 --- a/test/Node/OfflineTest.php +++ b/test/Node/OfflineTest.php @@ -21,8 +21,8 @@ namespace ZendTest\Ldap\Node; -use Zend\Ldap, - ZendTest\Ldap as TestLdap; +use Zend\Ldap; +use ZendTest\Ldap as TestLdap; /** * @category Zend @@ -31,13 +31,22 @@ * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License * @group Zend_Ldap - * @group Zend_Ldap_Node + * @group Ldap\Node */ class OfflineTest extends TestLdap\AbstractTestCase { protected function assertLocalDateTimeString($timestamp, $value) { - $this->assertEquals(date('YmdHisO', $timestamp), $value); + $tsValue = date('YmdHisO', $timestamp); + + if(date('O', strtotime('20120101'))) { + // Local timezone is +0000 when DST is off. Zend_Ldap converts + // +0000 to "Z" (see Zend\Ldap\Converter\Converter:toLdapDateTime()), so + // take account of that here + $tsValue = str_replace('+0000', 'Z', $tsValue); + } + + $this->assertEquals($tsValue, $value); } protected function assertUtcDateTimeString($localTimestamp, $value) @@ -177,11 +186,11 @@ public function testToJson() { $node = $this->createTestNode(); $this->assertEquals('{"dn":"cn=name,dc=example,dc=org",' . - '"boolean":[true,false],' . - '"cn":["name"],' . - '"empty":[],' . - '"host":["a","b","c"],' . - '"objectclass":["account","top"]}', $node->toJson() + '"boolean":[true,false],' . + '"cn":["name"],' . + '"empty":[],' . + '"host":["a","b","c"],' . + '"objectclass":["account","top"]}', $node->toJson() ); } @@ -596,4 +605,73 @@ public function testRemoveFromAttributeMultipleArray() $node->removeFromAttribute('test', array('value1', 'value3')); $this->assertEquals(array('value2'), $node->test); } + + /** + * ZF-11611 + */ + public function testRdnAttributesHandleMultiValuedAttribute() + { + $data = array( + 'dn' => 'cn=funkygroup,ou=Groupes,dc=domain,dc=local', + 'objectClass' => array( + 'groupOfNames', + 'top', + ), + 'cn' => array( + 'The Funkygroup', + 'funkygroup', + ), + 'member' => 'uid=john-doe,ou=Users,dc=domain,dc=local', + ); + + $node = Ldap\Node::fromArray($data, true); + $changedData = $node->getChangedData(); + $this->assertEmpty($changedData); + } + + /** + * ZF-11611 + */ + public function testRdnAttributesHandleMultiValuedAttribute2() + { + $data = array( + 'dn' => 'cn=funkygroup,ou=Groupes,dc=domain,dc=local', + 'objectClass' => array( + 'groupOfNames', + 'top', + ), + 'member' => 'uid=john-doe,ou=Users,dc=domain,dc=local', + ); + + $node = Ldap\Node::fromArray($data, true); + $cn = $node->getAttribute('cn'); + $this->assertEquals(array( + 0 => 'funkygroup' + ), $cn); + } + + /** + * ZF-11611 + */ + public function testRdnAttributesHandleMultiValuedAttribute3() + { + $data = array( + 'dn' => 'cn=funkygroup,ou=Groupes,dc=domain,dc=local', + 'objectClass' => array( + 'groupOfNames', + 'top', + ), + 'cn' => array( + 0 => 'The Funkygroup' + ), + 'member' => 'uid=john-doe,ou=Users,dc=domain,dc=local', + ); + + $node = Ldap\Node::fromArray($data, true); + $cn = $node->getAttribute('cn'); + $this->assertEquals(array( + 0 => 'The Funkygroup', + 1 => 'funkygroup', + ), $cn); + } } diff --git a/test/Node/OnlineTest.php b/test/Node/OnlineTest.php index 0d99f1e7c..f3ad5a4de 100644 --- a/test/Node/OnlineTest.php +++ b/test/Node/OnlineTest.php @@ -21,9 +21,9 @@ namespace ZendTest\Ldap\Node; -use Zend\Ldap, - Zend\Ldap\Exception, - ZendTest\Ldap as TestLdap; +use Zend\Ldap; +use Zend\Ldap\Exception; +use ZendTest\Ldap as TestLdap; /** * @category Zend diff --git a/test/Node/RootDseTest.php b/test/Node/RootDseTest.php index 49de73fec..fe4a47fb7 100644 --- a/test/Node/RootDseTest.php +++ b/test/Node/RootDseTest.php @@ -21,8 +21,8 @@ namespace ZendTest\Ldap\Node; -use Zend\Ldap\Node, - ZendTest\Ldap as TestLdap; +use Zend\Ldap\Node; +use ZendTest\Ldap as TestLdap; /** * @category Zend diff --git a/test/Node/SchemaTest.php b/test/Node/SchemaTest.php index 5a5aacd47..ecdb35fdb 100644 --- a/test/Node/SchemaTest.php +++ b/test/Node/SchemaTest.php @@ -21,8 +21,8 @@ namespace ZendTest\Ldap\Node; -use Zend\Ldap\Node, - ZendTest\Ldap as TestLdap; +use Zend\Ldap\Node; +use ZendTest\Ldap as TestLdap; /** * @category Zend diff --git a/test/Node/UpdateTest.php b/test/Node/UpdateTest.php index 312212cb4..91492392d 100644 --- a/test/Node/UpdateTest.php +++ b/test/Node/UpdateTest.php @@ -21,8 +21,8 @@ namespace ZendTest\Ldap\Node; -use Zend\Ldap, - ZendTest\Ldap as TestLdap; +use Zend\Ldap; +use ZendTest\Ldap as TestLdap; /** * @category Zend diff --git a/test/OfflineTest.php b/test/OfflineTest.php index b9b1259c3..ea731a2ca 100644 --- a/test/OfflineTest.php +++ b/test/OfflineTest.php @@ -21,9 +21,9 @@ namespace ZendTest\Ldap; -use Zend\Config, - Zend\Ldap, - Zend\Ldap\Exception; +use Zend\Config; +use Zend\Ldap; +use Zend\Ldap\Exception; /** * @category Zend diff --git a/test/SearchTest.php b/test/SearchTest.php index 4f53ad0e3..c081b9130 100644 --- a/test/SearchTest.php +++ b/test/SearchTest.php @@ -21,9 +21,9 @@ namespace ZendTest\Ldap; -use Zend\Ldap, - Zend\Ldap\Collection, - Zend\Ldap\Exception; +use Zend\Ldap; +use Zend\Ldap\Collection; +use Zend\Ldap\Exception; /** * @category Zend