MediaWiki  1.27.2
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 }
static provideArrays()
Provider for testing wfArrayPlus2d.
GlobalFunctions wfArrayPlus2d.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
testWfArrayPlus2d($baseArray, $newValues, $expected, $testName)
provideArrays
wfArrayPlus2d(array $baseArray, array $newValues)
Merges two (possibly) 2 dimensional arrays into the target array ($baseArray).