Completed
Pull Request — master (#665)
by no
03:38
created

testGivenNull_constructorAssumesEmptyArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace Wikibase\DataModel\Tests;
4
5
use ArrayObject;
6
use DataValues\StringValue;
7
use PHPUnit_Framework_TestCase;
8
use ReflectionClass;
9
use ReflectionMethod;
10
use stdClass;
11
use Wikibase\DataModel\ByPropertyIdArray;
12
use Wikibase\DataModel\Entity\PropertyId;
13
use Wikibase\DataModel\PropertyIdProvider;
14
use Wikibase\DataModel\Snak\PropertyNoValueSnak;
15
use Wikibase\DataModel\Snak\PropertySomeValueSnak;
16
use Wikibase\DataModel\Snak\PropertyValueSnak;
17
use Wikibase\DataModel\Snak\Snak;
18
use Wikibase\DataModel\Statement\Statement;
19
20
/**
21
 * @covers Wikibase\DataModel\ByPropertyIdArray
22
 *
23
 * @group Wikibase
24
 * @group WikibaseDataModel
25
 * @group ByPropertyIdArrayTest
26
 *
27
 * @license GPL-2.0+
28
 * @author Jeroen De Dauw < [email protected] >
29
 * @author H. Snater < [email protected] >
30
 */
31
class ByPropertyIdArrayTest extends PHPUnit_Framework_TestCase {
32
33
	public function testGivenNull_constructorAssumesEmptyArray() {
34
		$indexedArray = new ByPropertyIdArray( null );
0 ignored issues
show
Deprecated Code introduced by
The class Wikibase\DataModel\ByPropertyIdArray has been deprecated with message: since 5.0, use a DataModel Service instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
35
36
		$this->assertSame( 0, $indexedArray->count() );
37
	}
38
39
	public function testGivenNonTraversableObject_constructorDoesNotCastObjectToArray() {
40
		$object = new stdClass();
41
		$object->property = true;
42
43
		$this->setExpectedException( 'InvalidArgumentException' );
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
44
		new ByPropertyIdArray( $object );
0 ignored issues
show
Documentation introduced by
$object is of type object<stdClass>, but the function expects a array<integer,object<Wik...bject<Traversable>|null.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Deprecated Code introduced by
The class Wikibase\DataModel\ByPropertyIdArray has been deprecated with message: since 5.0, use a DataModel Service instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
45
	}
46
47
	public function testArrayObjectNotConstructedFromObject() {
48
		$statement1 = new Statement( new PropertyNoValueSnak( 1 ) );
49
		$statement1->setGuid( '1' );
50
		$statement2 = new Statement( new PropertyNoValueSnak( 2 ) );
51
		$statement2->setGuid( '2' );
52
53
		$object = new ArrayObject();
54
		$object->append( $statement1 );
55
56
		$byPropertyIdArray = new ByPropertyIdArray( $object );
0 ignored issues
show
Deprecated Code introduced by
The class Wikibase\DataModel\ByPropertyIdArray has been deprecated with message: since 5.0, use a DataModel Service instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
57
		// According to the documentation append() "cannot be called when the ArrayObject was
58
		// constructed from an object." This test makes sure it was not constructed from an object.
59
		$byPropertyIdArray->append( $statement2 );
60
61
		$this->assertCount( 2, $byPropertyIdArray );
62
	}
63
64
	/**
65
	 * Returns an accessible ReflectionMethod of ByPropertyIdArray.
66
	 *
67
	 * @param string $methodName
68
	 * @return ReflectionMethod
69
	 */
70
	protected static function getMethod( $methodName ) {
71
		$class = new ReflectionClass( 'Wikibase\DataModel\ByPropertyIdArray' );
72
		$method = $class->getMethod( $methodName );
73
		$method->setAccessible( true );
74
		return $method;
75
	}
76
77
	public function listProvider() {
78
		$lists = array();
79
80
		$snaks = array(
81
			new PropertyNoValueSnak( new PropertyId( 'P42' ) ),
82
			new PropertySomeValueSnak( new PropertyId( 'P42' ) ),
83
			new PropertySomeValueSnak( new PropertyId( 'P10' ) ),
84
			new PropertyValueSnak( new PropertyId( 'P10' ), new StringValue( 'ohi' ) ),
85
			new PropertySomeValueSnak( new PropertyId( 'P1' ) ),
86
		);
87
88
		$lists[] = $snaks;
89
90
		$lists[] = array_map(
91
			function( Snak $snak ) {
92
				return new Statement( $snak );
93
			},
94
			$snaks
95
		);
96
97
		$argLists = array();
98
99
		foreach ( $lists as $list ) {
100
			$argLists[] = array( $list );
101
		}
102
103
		return $argLists;
104
	}
105
106
	/**
107
	 * @return Statement[]
108
	 */
109
	protected function statementsProvider() {
110
		$snaks = array(
111
			new PropertyNoValueSnak( new PropertyId( 'P1' ) ),
112
			new PropertySomeValueSnak( new PropertyId( 'P1' ) ),
113
			new PropertyValueSnak( new PropertyId( 'P2' ), new StringValue( 'a' ) ),
114
			new PropertyValueSnak( new PropertyId( 'P2' ), new StringValue( 'b' ) ),
115
			new PropertyValueSnak( new PropertyId( 'P2' ), new StringValue( 'c' ) ),
116
			new PropertySomeValueSnak( new PropertyId( 'P3' ) ),
117
		);
118
119
		return array_map(
120
			function( Snak $snak ) {
121
				return new Statement( $snak );
122
			},
123
			$snaks
124
		);
125
	}
126
127
	/**
128
	 * @dataProvider listProvider
129
	 * @param PropertyIdProvider[] $objects
130
	 */
131
	public function testGetIds( array $objects ) {
132
		$indexedArray = new ByPropertyIdArray( $objects );
0 ignored issues
show
Deprecated Code introduced by
The class Wikibase\DataModel\ByPropertyIdArray has been deprecated with message: since 5.0, use a DataModel Service instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
133
134
		$expected = array();
135
136
		foreach ( $objects as $object ) {
137
			$expected[] = $object->getPropertyId();
138
		}
139
140
		$expected = array_unique( $expected );
141
142
		$indexedArray->buildIndex();
143
144
		$this->assertEquals(
145
			array_values( $expected ),
146
			array_values( $indexedArray->getPropertyIds() )
147
		);
148
	}
149
150
	/**
151
	 * @dataProvider listProvider
152
	 * @param PropertyIdProvider[] $objects
153
	 */
154
	public function testGetById( array $objects ) {
155
		$indexedArray = new ByPropertyIdArray( $objects );
0 ignored issues
show
Deprecated Code introduced by
The class Wikibase\DataModel\ByPropertyIdArray has been deprecated with message: since 5.0, use a DataModel Service instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
156
157
		$ids = array();
158
159
		foreach ( $objects as $object ) {
160
			$ids[] = $object->getPropertyId();
161
		}
162
163
		$ids = array_unique( $ids );
164
165
		$indexedArray->buildIndex();
166
167
		$allObtainedObjects = array();
168
169
		foreach ( $ids as $id ) {
170
			foreach ( $indexedArray->getByPropertyId( $id ) as $obtainedObject ) {
171
				$allObtainedObjects[] = $obtainedObject;
172
				$this->assertEquals( $id, $obtainedObject->getPropertyId() );
173
			}
174
		}
175
176
		$this->assertEquals(
177
			array_values( $objects ),
178
			array_values( $allObtainedObjects )
179
		);
180
	}
181
182
	/**
183
	 * @dataProvider listProvider
184
	 * @param PropertyIdProvider[] $objects
185
	 */
186
	public function testRemoveObject( array $objects ) {
187
		$lastIndex = count( $objects ) - 1;
188
		$indexedArray = new ByPropertyIdArray( $objects );
0 ignored issues
show
Deprecated Code introduced by
The class Wikibase\DataModel\ByPropertyIdArray has been deprecated with message: since 5.0, use a DataModel Service instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
189
		$indexedArray->buildIndex();
190
191
		$removeObject = self::getMethod( 'removeObject' );
192
193
		$removeObject->invokeArgs( $indexedArray, array( $objects[0] ) );
194
		$removeObject->invokeArgs( $indexedArray, array( $objects[$lastIndex] ) );
195
196
		$this->assertFalse(
197
			in_array( $objects[0], $indexedArray->getByPropertyId( $objects[0]->getPropertyId() ) )
198
		);
199
200
		$this->assertFalse( in_array(
201
			$objects[$lastIndex],
202
			$indexedArray->getByPropertyId( $objects[1]->getPropertyId() )
203
		) );
204
205
		$this->assertFalse( in_array( $objects[0], $indexedArray->toFlatArray() ) );
206
		$this->assertFalse( in_array( $objects[$lastIndex], $indexedArray->toFlatArray() ) );
207
	}
208
209
	public function testGetByNotSetIdThrowsException() {
210
		$indexedArray = new ByPropertyIdArray();
0 ignored issues
show
Deprecated Code introduced by
The class Wikibase\DataModel\ByPropertyIdArray has been deprecated with message: since 5.0, use a DataModel Service instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
211
		$indexedArray->buildIndex();
212
213
		$this->setExpectedException( 'OutOfBoundsException' );
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
214
215
		$indexedArray->getByPropertyId( PropertyId::newFromNumber( 9000 ) );
216
	}
217
218
	public function testNotBuildExceptionIsThrownForByPropertyId() {
219
		$indexedArray = new ByPropertyIdArray();
0 ignored issues
show
Deprecated Code introduced by
The class Wikibase\DataModel\ByPropertyIdArray has been deprecated with message: since 5.0, use a DataModel Service instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
220
221
		$this->setExpectedException( 'RuntimeException' );
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
222
		$indexedArray->getByPropertyId( PropertyId::newFromNumber( 9000 ) );
223
	}
224
225
	public function testNotBuildExceptionIsThrownForGetPropertyIds() {
226
		$indexedArray = new ByPropertyIdArray();
0 ignored issues
show
Deprecated Code introduced by
The class Wikibase\DataModel\ByPropertyIdArray has been deprecated with message: since 5.0, use a DataModel Service instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
227
228
		$this->setExpectedException( 'RuntimeException' );
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
229
		$indexedArray->getPropertyIds();
230
	}
231
232
	/**
233
	 * @dataProvider listProvider
234
	 */
235
	public function testGetFlatArrayIndexOfObject( array $objects ) {
236
		$indexedArray = new ByPropertyIdArray( $objects );
0 ignored issues
show
Deprecated Code introduced by
The class Wikibase\DataModel\ByPropertyIdArray has been deprecated with message: since 5.0, use a DataModel Service instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
237
		$indexedArray->buildIndex();
238
239
		$indicesSource = array();
240
		$indicesDestination = array();
241
242
		$i = 0;
243
		foreach ( $objects as $object ) {
244
			$indicesSource[$i++] = $object;
245
			$indicesDestination[$indexedArray->getFlatArrayIndexOfObject( $object )] = $object;
246
		}
247
248
		$this->assertEquals( $indicesSource, $indicesDestination );
249
	}
250
251
	/**
252
	 * @dataProvider listProvider
253
	 */
254
	public function testToFlatArray( array $objects ) {
255
		$indexedArray = new ByPropertyIdArray( $objects );
0 ignored issues
show
Deprecated Code introduced by
The class Wikibase\DataModel\ByPropertyIdArray has been deprecated with message: since 5.0, use a DataModel Service instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
256
		$indexedArray->buildIndex();
257
258
		$this->assertEquals( $objects, $indexedArray->toFlatArray() );
259
	}
260
261
	public function moveProvider() {
262
		$c = $this->statementsProvider();
263
		$argLists = array();
264
265
		$argLists[] = array( $c, $c[0], 0, $c );
266
		$argLists[] = array( $c, $c[0], 1, array( $c[1], $c[0], $c[2], $c[3], $c[4], $c[5] ) );
267
		$argLists[] = array( $c, $c[0], 2, array( $c[1], $c[0], $c[2], $c[3], $c[4], $c[5] ) );
268
		$argLists[] = array( $c, $c[0], 3, array( $c[2], $c[3], $c[4], $c[1], $c[0], $c[5] ) );
269
		$argLists[] = array( $c, $c[0], 4, array( $c[2], $c[3], $c[4], $c[1], $c[0], $c[5] ) );
270
		$argLists[] = array( $c, $c[0], 5, array( $c[2], $c[3], $c[4], $c[1], $c[0], $c[5] ) );
271
		$argLists[] = array( $c, $c[0], 6, array( $c[2], $c[3], $c[4], $c[5], $c[1], $c[0] ) );
272
273
		$argLists[] = array( $c, $c[1], 0, array( $c[1], $c[0], $c[2], $c[3], $c[4], $c[5] ) );
274
		$argLists[] = array( $c, $c[1], 1, $c );
275
		$argLists[] = array( $c, $c[1], 2, $c );
276
		$argLists[] = array( $c, $c[1], 3, array( $c[2], $c[3], $c[4], $c[0], $c[1], $c[5] ) );
277
		$argLists[] = array( $c, $c[1], 4, array( $c[2], $c[3], $c[4], $c[0], $c[1], $c[5] ) );
278
		$argLists[] = array( $c, $c[1], 5, array( $c[2], $c[3], $c[4], $c[0], $c[1], $c[5] ) );
279
		$argLists[] = array( $c, $c[1], 6, array( $c[2], $c[3], $c[4], $c[5], $c[0], $c[1] ) );
280
281
		$argLists[] = array( $c, $c[2], 0, array( $c[2], $c[3], $c[4], $c[0], $c[1], $c[5] ) );
282
		$argLists[] = array( $c, $c[2], 1, $c );
283
		$argLists[] = array( $c, $c[2], 2, $c );
284
		$argLists[] = array( $c, $c[2], 3, array( $c[0], $c[1], $c[3], $c[2], $c[4], $c[5] ) );
285
		$argLists[] = array( $c, $c[2], 4, array( $c[0], $c[1], $c[3], $c[4], $c[2], $c[5] ) );
286
		$argLists[] = array( $c, $c[2], 5, array( $c[0], $c[1], $c[3], $c[4], $c[2], $c[5] ) );
287
		$argLists[] = array( $c, $c[2], 6, array( $c[0], $c[1], $c[5], $c[3], $c[4], $c[2] ) );
288
289
		$argLists[] = array( $c, $c[3], 0, array( $c[3], $c[2], $c[4], $c[0], $c[1], $c[5] ) );
290
		$argLists[] = array( $c, $c[3], 1, array( $c[0], $c[1], $c[3], $c[2], $c[4], $c[5] ) );
291
		$argLists[] = array( $c, $c[3], 2, array( $c[0], $c[1], $c[3], $c[2], $c[4], $c[5] ) );
292
		$argLists[] = array( $c, $c[3], 3, $c );
293
		$argLists[] = array( $c, $c[3], 4, array( $c[0], $c[1], $c[2], $c[4], $c[3], $c[5] ) );
294
		$argLists[] = array( $c, $c[3], 5, array( $c[0], $c[1], $c[2], $c[4], $c[3], $c[5] ) );
295
		$argLists[] = array( $c, $c[3], 6, array( $c[0], $c[1], $c[5], $c[2], $c[4], $c[3] ) );
296
297
		$argLists[] = array( $c, $c[4], 0, array( $c[4], $c[2], $c[3], $c[0], $c[1], $c[5] ) );
298
		$argLists[] = array( $c, $c[4], 1, array( $c[0], $c[1], $c[4], $c[2], $c[3], $c[5] ) );
299
		$argLists[] = array( $c, $c[4], 2, array( $c[0], $c[1], $c[4], $c[2], $c[3], $c[5] ) );
300
		$argLists[] = array( $c, $c[4], 3, array( $c[0], $c[1], $c[2], $c[4], $c[3], $c[5] ) );
301
		$argLists[] = array( $c, $c[4], 4, $c );
302
		$argLists[] = array( $c, $c[4], 5, $c );
303
		$argLists[] = array( $c, $c[4], 6, array( $c[0], $c[1], $c[5], $c[2], $c[3], $c[4] ) );
304
305
		$argLists[] = array( $c, $c[5], 0, array( $c[5], $c[0], $c[1], $c[2], $c[3], $c[4] ) );
306
		$argLists[] = array( $c, $c[5], 1, array( $c[0], $c[1], $c[5], $c[2], $c[3], $c[4] ) );
307
		$argLists[] = array( $c, $c[5], 2, array( $c[0], $c[1], $c[5], $c[2], $c[3], $c[4] ) );
308
		$argLists[] = array( $c, $c[5], 3, $c );
309
		$argLists[] = array( $c, $c[5], 4, $c );
310
		$argLists[] = array( $c, $c[5], 5, $c );
311
		$argLists[] = array( $c, $c[5], 6, $c );
312
313
		return $argLists;
314
	}
315
316
	/**
317
	 * @dataProvider moveProvider
318
	 */
319
	public function testMoveObjectToIndex(
320
		array $objectsSource,
321
		PropertyIdProvider $object,
322
		$toIndex,
323
		array $objectsDestination
324
	) {
325
		$indexedArray = new ByPropertyIdArray( $objectsSource );
0 ignored issues
show
Deprecated Code introduced by
The class Wikibase\DataModel\ByPropertyIdArray has been deprecated with message: since 5.0, use a DataModel Service instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
326
		$indexedArray->buildIndex();
327
328
		$indexedArray->moveObjectToIndex( $object, $toIndex );
329
330
		// Not using $indexedArray->toFlatArray() here to test whether native array has been
331
		// exchanged:
332
		$reindexedArray = array();
333
		foreach ( $indexedArray as $o ) {
334
			$reindexedArray[] = $o;
335
		}
336
337
		$this->assertEquals( $objectsDestination, $reindexedArray );
338
	}
339
340
	public function testMoveThrowingOutOfBoundsExceptionIfObjectNotPresent() {
341
		$statements = $this->statementsProvider();
342
		$indexedArray = new ByPropertyIdArray( $statements );
0 ignored issues
show
Deprecated Code introduced by
The class Wikibase\DataModel\ByPropertyIdArray has been deprecated with message: since 5.0, use a DataModel Service instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
343
		$indexedArray->buildIndex();
344
345
		$this->setExpectedException( 'OutOfBoundsException' );
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
346
347
		$indexedArray->moveObjectToIndex( new Statement( new PropertyNoValueSnak( new PropertyId( 'P9999' ) ) ), 0 );
348
	}
349
350
	public function testMoveThrowingOutOfBoundsExceptionOnInvalidIndex() {
351
		$statements = $this->statementsProvider();
352
		$indexedArray = new ByPropertyIdArray( $statements );
0 ignored issues
show
Deprecated Code introduced by
The class Wikibase\DataModel\ByPropertyIdArray has been deprecated with message: since 5.0, use a DataModel Service instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
353
		$indexedArray->buildIndex();
354
355
		$this->setExpectedException( 'OutOfBoundsException' );
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::setExpectedException() has been deprecated with message: Method deprecated since Release 5.2.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
356
357
		$indexedArray->moveObjectToIndex( $statements[0], 9999 );
358
	}
359
360
	public function addProvider() {
361
		$c = $this->statementsProvider();
362
363
		$argLists = array();
364
365
		$argLists[] = array( array(), $c[0], null, array( $c[0] ) );
366
		$argLists[] = array( array(), $c[0], 1, array( $c[0] ) );
367
		$argLists[] = array( array( $c[0] ), $c[2], 0, array( $c[2], $c[0] ) );
368
		$argLists[] = array( array( $c[2], $c[1] ), $c[0], 0, array( $c[0], $c[1], $c[2] ) );
369
		$argLists[] = array(
370
			array( $c[0], $c[1], $c[3] ),
371
			$c[5],
372
			1,
373
			array( $c[0], $c[1], $c[5], $c[3] )
374
		);
375
		$argLists[] = array(
376
			array( $c[0], $c[1], $c[5], $c[3] ),
377
			$c[2],
378
			2,
379
			array( $c[0], $c[1], $c[2], $c[3], $c[5] )
380
		);
381
		$argLists[] = array(
382
			array( $c[0], $c[1], $c[2], $c[3], $c[5] ),
383
			$c[4],
384
			null,
385
			array( $c[0], $c[1], $c[2], $c[3], $c[4], $c[5] )
386
		);
387
388
		return $argLists;
389
	}
390
391
	/**
392
	 * @dataProvider addProvider
393
	 */
394
	public function testAddObjectAtIndex(
395
		array $objectsSource,
396
		PropertyIdProvider $object,
397
		$index,
398
		array $objectsDestination
399
	) {
400
		$indexedArray = new ByPropertyIdArray( $objectsSource );
0 ignored issues
show
Deprecated Code introduced by
The class Wikibase\DataModel\ByPropertyIdArray has been deprecated with message: since 5.0, use a DataModel Service instead

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
401
		$indexedArray->buildIndex();
402
403
		$indexedArray->addObjectAtIndex( $object, $index );
404
405
		$this->assertEquals( $objectsDestination, $indexedArray->toFlatArray() );
406
	}
407
408
}
409