MediaWiki REL1_31
wfArrayPlus2dTest.php
Go to the documentation of this file.
1<?php
10 public function testWfArrayPlus2d( $baseArray, $newValues, $expected, $testName ) {
11 $this->assertEquals(
12 $expected,
13 wfArrayPlus2d( $baseArray, $newValues ),
14 $testName
15 );
16 }
17
23 public static function provideArrays() {
24 return [
25 // target array, new values array, expected result
26 [
27 [ 0 => '1dArray' ],
28 [ 1 => '1dArray' ],
29 [ 0 => '1dArray', 1 => '1dArray' ],
30 "Test simple union of two arrays with different keys",
31 ],
32 [
33 [
34 0 => [ 0 => '2dArray' ],
35 ],
36 [
37 0 => [ 1 => '2dArray' ],
38 ],
39 [
40 0 => [ 0 => '2dArray', 1 => '2dArray' ],
41 ],
42 "Test union of 2d arrays with different keys in the value array",
43 ],
44 [
45 [
46 0 => [ 0 => '2dArray' ],
47 ],
48 [
49 0 => [ 0 => '1dArray' ],
50 ],
51 [
52 0 => [ 0 => '2dArray' ],
53 ],
54 "Test union of 2d arrays with same keys in the value array",
55 ],
56 [
57 [
58 0 => [ 0 => [ 0 => '3dArray' ] ],
59 ],
60 [
61 0 => [ 0 => [ 1 => '2dArray' ] ],
62 ],
63 [
64 0 => [ 0 => [ 0 => '3dArray' ] ],
65 ],
66 "Test union of 3d array with different keys",
67 ],
68 [
69 [
70 0 => [ 0 => [ 0 => '3dArray' ] ],
71 ],
72 [
73 0 => [ 1 => [ 0 => '2dArray' ] ],
74 ],
75 [
76 0 => [ 0 => [ 0 => '3dArray' ], 1 => [ 0 => '2dArray' ] ],
77 ],
78 "Test union of 3d array with different keys in the value array",
79 ],
80 [
81 [
82 0 => [ 0 => [ 0 => '3dArray' ] ],
83 ],
84 [
85 0 => [ 0 => [ 0 => '2dArray' ] ],
86 ],
87 [
88 0 => [ 0 => [ 0 => '3dArray' ] ],
89 ],
90 "Test union of 3d array with same keys in the value array",
91 ],
92 ];
93 }
94}
wfArrayPlus2d(array $baseArray, array $newValues)
Merges two (possibly) 2 dimensional arrays into the target array ($baseArray).
GlobalFunctions wfArrayPlus2d.
testWfArrayPlus2d( $baseArray, $newValues, $expected, $testName)
provideArrays
static provideArrays()
Provider for testing wfArrayPlus2d.