@@ -58,7 +58,7 @@ public static function isProperSubsetOf(
58
58
$ allowExtra ,
59
59
$ isOrdered
60
60
) {
61
-
61
+
62
62
if ($ leftTree == null ) {
63
63
return true ;
64
64
}
@@ -123,7 +123,7 @@ public static function isProperSubsetOf(
123
123
}
124
124
return true ;
125
125
}
126
-
126
+
127
127
/**
128
128
* Recursively check whether the left JSON object is a proper subset of the right JSON object
129
129
* @param array $leftObject Left JSON object as string
@@ -140,7 +140,7 @@ public static function isJsonObjectProperSubsetOf(
140
140
$ allowExtra ,
141
141
$ isOrdered
142
142
) {
143
-
143
+
144
144
return static ::isProperSubsetOf (
145
145
APIHelper::deserialize ($ leftObject ),
146
146
APIHelper::deserialize ($ rightObject ),
@@ -149,7 +149,7 @@ public static function isJsonObjectProperSubsetOf(
149
149
$ isOrdered
150
150
);
151
151
}
152
-
152
+
153
153
/**
154
154
* Check if left array of objects is a subset of right array
155
155
* @param array $leftObject Left array as a JSON string
@@ -166,11 +166,11 @@ public static function isArrayOfStringifiedJsonObjectsProperSubsetOf(
166
166
$ allowExtra ,
167
167
$ isOrdered
168
168
) {
169
-
169
+
170
170
// Deserialize left and right objects from their respective strings
171
171
$ left = APIHelper::deserialize ($ leftObject );
172
172
$ right = APIHelper::deserialize ($ rightObject );
173
-
173
+
174
174
return static ::isArrayOfJsonObjectsProperSubsetOf (
175
175
$ left ,
176
176
$ right ,
@@ -196,27 +196,27 @@ public static function isArrayOfJsonObjectsProperSubsetOf(
196
196
$ allowExtra ,
197
197
$ isOrdered
198
198
) {
199
-
199
+
200
200
// Return false if size different and checking was strict
201
201
if (!$ allowExtra && count ($ left ) != count ($ right )) {
202
202
return false ;
203
203
}
204
-
204
+
205
205
// Create list iterators
206
206
$ leftIter = (new \ArrayObject ($ left ))->getIterator ();
207
207
$ rightIter = (new \ArrayObject ($ right ))->getIterator ();
208
-
208
+
209
209
// Iterate left list and check if each value is present in the right list
210
210
while ($ leftIter ->valid ()) {
211
211
$ leftIter ->next ();
212
212
$ leftTree = $ leftIter ->current ();
213
213
$ found = false ;
214
-
214
+
215
215
// If order is not required, then search right array from beginning
216
216
if (!$ isOrdered ) {
217
217
$ rightIter ->rewind ();
218
218
}
219
-
219
+
220
220
// Check each right element to see if left is a subset
221
221
while ($ rightIter ->valid ()) {
222
222
$ rightIter ->next ();
@@ -231,15 +231,15 @@ public static function isArrayOfJsonObjectsProperSubsetOf(
231
231
break ;
232
232
}
233
233
}
234
-
234
+
235
235
if (!$ found ) {
236
236
return false ;
237
237
}
238
238
}
239
-
239
+
240
240
return true ;
241
241
}
242
-
242
+
243
243
/**
244
244
* Check whether the a list is a subset of another list
245
245
* @param array $leftList Expected List
@@ -254,7 +254,7 @@ public static function isListProperSubsetOf(
254
254
$ allowExtra ,
255
255
$ isOrdered
256
256
) {
257
-
257
+
258
258
if ($ isOrdered && !$ allowExtra ) {
259
259
return $ leftList === $ rightList ;
260
260
} elseif ($ isOrdered && $ allowExtra ) {
@@ -267,7 +267,7 @@ public static function isListProperSubsetOf(
267
267
}
268
268
return true ;
269
269
}
270
-
270
+
271
271
/**
272
272
* Recursively check whether the left headers map is a proper subset of
273
273
* the right headers map. Header keys & values are compared case-insensitive.
@@ -282,7 +282,7 @@ public static function areHeadersProperSubsetOf(
282
282
array $ rightTree ,
283
283
$ checkValues
284
284
) {
285
-
285
+
286
286
// Http headers are case-insensitive
287
287
$ l = array_change_key_case ($ leftTree );
288
288
$ r = array_change_key_case ($ rightTree );
@@ -345,4 +345,10 @@ public static function getJsonMapper()
345
345
return $ mapper ;
346
346
}
347
347
348
+ public static function getAuthorizationFromEnvironment ()
349
+ {
350
+ Configuration::$ basicAuthUserName = getenv ('MessageMediaApiTestsKey ' );
351
+ Configuration::$ basicAuthPassword = getenv ('MessageMediaApiTestsSecret ' );
352
+ }
353
+
348
354
}
0 commit comments