44
55use Hashable ;
66use InvalidArgumentException ;
7+ use PHPUnit_Framework_TestCase ;
78use Wikibase \DataModel \Entity \PropertyId ;
89use Wikibase \DataModel \Reference ;
910use Wikibase \DataModel \ReferenceList ;
2122 * @author Jeroen De Dauw < jeroendedauw@gmail.com >
2223 * @author Thiemo Mättig
2324 */
24- class ReferenceListTest extends \ PHPUnit_Framework_TestCase {
25+ class ReferenceListTest extends PHPUnit_Framework_TestCase {
2526
2627 public function instanceProvider () {
2728 $ instances = array ();
@@ -84,9 +85,20 @@ public function invalidConstructorArgumentsProvider() {
8485 );
8586 }
8687
88+ public function testGetIterator_isTraversable () {
89+ $ references = new ReferenceList ();
90+ $ references ->addNewReference ( new PropertyNoValueSnak ( 1 ) );
91+ $ iterator = $ references ->getIterator ();
92+
93+ $ this ->assertInstanceOf ( 'Traversable ' , $ iterator );
94+ $ this ->assertCount ( 1 , $ iterator );
95+ foreach ( $ references as $ reference ) {
96+ $ this ->assertInstanceOf ( 'Wikibase\DataModel\Reference ' , $ reference );
97+ }
98+ }
99+
87100 /**
88101 * @dataProvider instanceProvider
89- * @param ReferenceList $array
90102 */
91103 public function testHasReferenceBeforeRemoveButNotAfter ( ReferenceList $ array ) {
92104 if ( $ array ->count () === 0 ) {
@@ -120,7 +132,6 @@ public function testGivenCloneOfReferenceInList_hasReferenceReturnsTrue() {
120132
121133 /**
122134 * @dataProvider instanceProvider
123- * @param ReferenceList $array
124135 */
125136 public function testRemoveReference ( ReferenceList $ array ) {
126137 $ elementCount = count ( $ array );
@@ -225,7 +236,6 @@ public function testGivenEmptyReferenceAndIndex_addReferenceDoesNotAdd() {
225236
226237 /**
227238 * @dataProvider instanceProvider
228- * @param ReferenceList $array
229239 */
230240 public function testIndexOf ( ReferenceList $ array ) {
231241 $ this ->assertFalse ( $ array ->indexOf ( new Reference () ) );
@@ -248,7 +258,6 @@ public function testIndexOf_falseForMissingReferences() {
248258
249259 /**
250260 * @dataProvider instanceProvider
251- * @param ReferenceList $array
252261 */
253262 public function testEquals ( ReferenceList $ array ) {
254263 $ this ->assertTrue ( $ array ->equals ( $ array ) );
@@ -257,24 +266,21 @@ public function testEquals( ReferenceList $array ) {
257266
258267 /**
259268 * @dataProvider instanceProvider
260- * @param ReferenceList $array
261269 */
262- public function testGetHashReturnsString ( ReferenceList $ array ) {
270+ public function testGetValueHashReturnsString ( ReferenceList $ array ) {
263271 $ this ->assertInternalType ( 'string ' , $ array ->getValueHash () );
264272 }
265273
266274 /**
267275 * @dataProvider instanceProvider
268- * @param ReferenceList $array
269276 */
270- public function testGetHashValueIsTheSameForClone ( ReferenceList $ array ) {
277+ public function testGetValueHashIsTheSameForClone ( ReferenceList $ array ) {
271278 $ copy = unserialize ( serialize ( $ array ) );
272279 $ this ->assertEquals ( $ array ->getValueHash (), $ copy ->getValueHash () );
273280 }
274281
275282 /**
276283 * @dataProvider instanceProvider
277- * @param ReferenceList $references
278284 */
279285 public function testHasReferenceHash ( ReferenceList $ references ) {
280286 $ this ->assertFalse ( $ references ->hasReferenceHash ( '~=[,,_,,]:3 ' ) );
@@ -289,7 +295,6 @@ public function testHasReferenceHash( ReferenceList $references ) {
289295
290296 /**
291297 * @dataProvider instanceProvider
292- * @param ReferenceList $references
293298 */
294299 public function testGetReference ( ReferenceList $ references ) {
295300 $ this ->assertNull ( $ references ->getReference ( '~=[,,_,,]:3 ' ) );
@@ -304,7 +309,6 @@ public function testGetReference( ReferenceList $references ) {
304309
305310 /**
306311 * @dataProvider instanceProvider
307- * @param ReferenceList $references
308312 */
309313 public function testRemoveReferenceHash ( ReferenceList $ references ) {
310314 $ references ->removeReferenceHash ( '~=[,,_,,]:3 ' );
@@ -364,6 +368,11 @@ public function testGivenNoneSnak_addNewReferenceThrowsException() {
364368 $ references ->addNewReference ( new PropertyNoValueSnak ( 1 ), null );
365369 }
366370
371+ public function testSerializationStability () {
372+ $ references = new ReferenceList ();
373+ $ this ->assertSame ( 'a:0:{} ' , $ references ->serialize () );
374+ }
375+
367376 public function testSerializeRoundtrip () {
368377 $ references = new ReferenceList ();
369378
0 commit comments