Skip to content

Commit 27b57b8

Browse files
committed
test: Fix getting returned sharees when there are several results
Signed-off-by: Daniel Calviño Sánchez <[email protected]>
1 parent a164ab8 commit 27b57b8

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

build/integration/features/bootstrap/Sharing.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,37 @@ public function getArrayOfShareesResponded(ResponseInterface $response, $shareeT
732732
$shareeType = substr($shareeType, 6);
733733
}
734734

735+
// "simplexml_load_string" creates a SimpleXMLElement object for each
736+
// XML element with child elements. In turn, each child is indexed by
737+
// its tag in the SimpleXMLElement object. However, when there are
738+
// several child XML elements with the same tag, an array with all the
739+
// children with the same tag is indexed instead. Therefore, when the
740+
// XML contains
741+
// <XXX>
742+
// <element>
743+
// <label>...</label>
744+
// <value>...</value>
745+
// </element>
746+
// </XXX>
747+
// the "$elements[$shareeType]" variable contains an "element" key which
748+
// in turn contains "label" and "value" keys, but when the XML contains
749+
// <XXX>
750+
// <element>
751+
// <label>...</label>
752+
// <value>...</value>
753+
// </element>
754+
// <element>
755+
// <label>...</label>
756+
// <value>...</value>
757+
// </element>
758+
// </XXX>
759+
// the "$elements[$shareeType]" variable contains an "element" key which
760+
// in turn contains "0" and "1" keys, and in turn each one contains
761+
// "label" and "value" keys.
762+
if (array_key_exists('element', $elements[$shareeType]) && is_int(array_keys($elements[$shareeType]['element'])[0])) {
763+
$elements[$shareeType] = $elements[$shareeType]['element'];
764+
}
765+
735766
$sharees = [];
736767
foreach ($elements[$shareeType] as $element) {
737768
$sharee = [$element['label'], $element['value']['shareType'], $element['value']['shareWith']];

build/integration/sharees_features/sharees.feature

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Feature: sharees
88
And user "Sharee1" exists
99
And group "ShareeGroup" exists
1010
And user "test" belongs to group "ShareeGroup"
11+
And user "Sharee2" exists
1112

1213
Scenario: Search without exact match
1314
Given As an "test"
@@ -19,6 +20,7 @@ Feature: sharees
1920
And "exact users" sharees returned is empty
2021
And "users" sharees returned are
2122
| Sharee1 | 0 | Sharee1 | Sharee1 |
23+
| Sharee2 | 0 | Sharee2 | Sharee2 |
2224
And "exact groups" sharees returned is empty
2325
And "groups" sharees returned are
2426
| ShareeGroup | 1 | ShareeGroup |
@@ -35,6 +37,7 @@ Feature: sharees
3537
And "exact users" sharees returned is empty
3638
And "users" sharees returned are
3739
| Sharee1 | 0 | Sharee1 | Sharee1 |
40+
| Sharee2 | 0 | Sharee2 | Sharee2 |
3841
And "exact groups" sharees returned is empty
3942
And "groups" sharees returned are
4043
| ShareeGroup | 1 | ShareeGroup |
@@ -255,6 +258,7 @@ Feature: sharees
255258
And "exact users" sharees returned is empty
256259
And "users" sharees returned are
257260
| Sharee1 | 0 | Sharee1 | Sharee1 |
261+
| Sharee2 | 0 | Sharee2 | Sharee2 |
258262
And "exact groups" sharees returned is empty
259263
And "groups" sharees returned is empty
260264
And "exact remotes" sharees returned is empty

0 commit comments

Comments
 (0)