@@ -165,6 +165,7 @@ public function orderByPropertyProvider() {
165165 $ id1 = new PropertyId ( 'P1 ' );
166166 $ id2 = new PropertyId ( 'P2 ' );
167167 $ id3 = new PropertyId ( 'P3 ' );
168+ $ id4 = new PropertyId ( 'P4 ' );
168169
169170 /**
170171 * List of test data containing snaks to initialize SnakList objects. The first list of
@@ -238,6 +239,27 @@ public function orderByPropertyProvider() {
238239 ],
239240 [ 'P1 ' ]
240241 ],
242+ 'Multiple IDs in order ' => [
243+ [
244+ new PropertyValueSnak ( $ id1 , new StringValue ( 'a ' ) ),
245+ new PropertyValueSnak ( $ id2 , new StringValue ( 'b ' ) ),
246+ new PropertyValueSnak ( $ id1 , new StringValue ( 'c ' ) ),
247+ new PropertyValueSnak ( $ id3 , new StringValue ( 'd ' ) ),
248+ new PropertyValueSnak ( $ id4 , new StringValue ( 'e ' ) ),
249+ new PropertyValueSnak ( $ id2 , new StringValue ( 'f ' ) ),
250+ new PropertyValueSnak ( $ id4 , new StringValue ( 'g ' ) ),
251+ ],
252+ [
253+ new PropertyValueSnak ( $ id2 , new StringValue ( 'b ' ) ),
254+ new PropertyValueSnak ( $ id2 , new StringValue ( 'f ' ) ),
255+ new PropertyValueSnak ( $ id3 , new StringValue ( 'd ' ) ),
256+ new PropertyValueSnak ( $ id1 , new StringValue ( 'a ' ) ),
257+ new PropertyValueSnak ( $ id1 , new StringValue ( 'c ' ) ),
258+ new PropertyValueSnak ( $ id4 , new StringValue ( 'e ' ) ),
259+ new PropertyValueSnak ( $ id4 , new StringValue ( 'g ' ) ),
260+ ],
261+ [ 'P2 ' , 'P3 ' , 'P1 ' ]
262+ ],
241263 ];
242264
243265 $ arguments = [];
@@ -272,6 +294,16 @@ public function testOrderByProperty( SnakList $snakList, SnakList $expected, arr
272294 } else {
273295 $ this ->assertNotSame ( $ initialSnakList ->getHash (), $ snakList ->getHash () );
274296 }
297+
298+ /** @var Snak $snak */
299+ foreach ( $ snakList as $ snak ) {
300+ $ hash = $ snak ->getHash ();
301+ $ this ->assertSame (
302+ $ hash ,
303+ $ snakList ->getSnak ( $ hash )->getHash (),
304+ 'Reordering must not mess up the lists internal state '
305+ );
306+ }
275307 }
276308
277309 public function testComparableInterface () {
0 commit comments