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

Commit 216ecec

Browse files
committed
Merge branch 'hotfix/44'
Closes #44 Closes #17
2 parents 926745a + 65d10f4 commit 216ecec

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ All notable changes to this project will be documented in this file, in reverse
1818

1919
### Fixed
2020

21+
- [#17](https://github.com/zendframework/zend-ldap/issues/17) Fixes HHVM builds
22+
- [#44](https://github.com/zendframework/zend-ldap/pull/40) Fixes broken builds
23+
in PHP7 due to faulty sorting-test
2124
- [#40](https://github.com/zendframework/zend-ldap/pull/40) Fixes connection test
2225
that failed due to different failure messages in PHP5 and 7
2326

test/SortTest.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,17 @@ public function testCustomSorting()
107107

108108
$iterator = new DefaultIterator($this->getLdap(), $search);
109109
$sortFunction = function ($a, $b) use ($lSorted) {
110-
if (array_search($a, $lSorted) % 2 === 0) {
110+
// Sort values by the number of "1" in their binary representation
111+
// and when that is equals by their position in the alphabet.
112+
$f = strlen(str_replace('0', '', decbin(bin2hex($a)))) -
113+
strlen(str_replace('0', '', decbin(bin2hex($b))));
114+
if ($f < 0) {
111115
return -1;
116+
} elseif ($f > 0) {
117+
return 1;
112118
}
119+
return strnatcasecmp($a, $b);
113120

114-
return 1;
115121
};
116122
$iterator->setSortFunction($sortFunction);
117123

@@ -125,20 +131,20 @@ public function testCustomSorting()
125131

126132
$this->assertAttributeEquals([
127133
[
128-
'resource' => $reflectionEntries[4]['resource'],
129-
'sortValue' => 'a',
134+
'resource' => $reflectionEntries[1]['resource'],
135+
'sortValue' => 'd',
130136
], [
131137
'resource' => $reflectionEntries[0]['resource'],
132138
'sortValue' => 'e',
133139
], [
134-
'resource' => $reflectionEntries[2]['resource'],
135-
'sortValue' => 'c',
140+
'resource' => $reflectionEntries[4]['resource'],
141+
'sortValue' => 'a',
136142
], [
137143
'resource' => $reflectionEntries[3]['resource'],
138144
'sortValue' => 'b',
139145
], [
140-
'resource' => $reflectionEntries[1]['resource'],
141-
'sortValue' => 'd',
146+
'resource' => $reflectionEntries[2]['resource'],
147+
'sortValue' => 'c',
142148
],
143149
], 'entries', $iterator);
144150
}

0 commit comments

Comments
 (0)