File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -224,6 +224,24 @@ public function testAddReferenceAtIndexIgnoresIdenticalObjects() {
224224 $ this ->assertCount ( 1 , $ list );
225225 }
226226
227+ public function testAddReferenceAtIndexMovesIdenticalObjects () {
228+ $ list = new ReferenceList ();
229+ $ list ->addNewReference ( new PropertyNoValueSnak ( 1 ) );
230+ $ reference = new Reference ( array ( new PropertyNoValueSnak ( 2 ) ) );
231+ $ list ->addReference ( $ reference );
232+ $ this ->assertSame ( 1 , $ list ->indexOf ( $ reference ), 'pre condition ' );
233+
234+ $ list ->addReference ( $ reference , 0 );
235+
236+ $ this ->assertCount ( 2 , $ list , 'not added ' );
237+ $ this ->assertSame ( 0 , $ list ->indexOf ( $ reference ), 'can decrease index ' );
238+
239+ $ list ->addReference ( $ reference , 2 );
240+
241+ $ this ->assertCount ( 2 , $ list , 'not added ' );
242+ $ this ->assertSame ( 0 , $ list ->indexOf ( $ reference ), 'can not increase index ' );
243+ }
244+
227245 public function testAddReferenceAtIndexZero () {
228246 $ reference1 = new Reference ( array ( new PropertyNoValueSnak ( 1 ) ) );
229247 $ reference2 = new Reference ( array ( new PropertyNoValueSnak ( 2 ) ) );
You can’t perform that action at this time.
0 commit comments