File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -241,4 +241,11 @@ public function unserialize( $data ) {
241241 $ this ->__construct ( unserialize ( $ data ) );
242242 }
243243
244+ /**
245+ * @return bool
246+ */
247+ public function isEmpty () {
248+ return $ this ->count () === 0 ;
249+ }
250+
244251}
Original file line number Diff line number Diff line change @@ -351,4 +351,26 @@ public function testSerializeRoundtrip() {
351351 $ this ->assertTrue ( $ references ->equals ( unserialize ( $ serialized ) ) );
352352 }
353353
354+ public function testGivenEmptyList_isEmpty () {
355+ $ references = new ReferenceList ();
356+ $ this ->assertTrue ( $ references ->isEmpty () );
357+ }
358+
359+ public function testGivenNonEmptyList_isNotEmpty () {
360+ $ references = new ReferenceList ();
361+ $ references ->addNewReference ( new PropertyNoValueSnak ( 1 ) );
362+
363+ $ this ->assertFalse ( $ references ->isEmpty () );
364+ }
365+
366+ public function testGivenNonEmptyListWithForwardedIterator_isNotEmpty () {
367+ $ references = new ReferenceList ();
368+ $ references ->addNewReference ( new PropertyNoValueSnak ( 1 ) );
369+ $ references ->next ();
370+
371+ $ this ->assertFalse ( $ references ->valid (), 'post condition ' );
372+ $ this ->assertFalse ( $ references ->isEmpty () );
373+ $ this ->assertFalse ( $ references ->valid (), 'pre condition ' );
374+ }
375+
354376}
You can’t perform that action at this time.
0 commit comments