@@ -541,4 +541,50 @@ public function testWhenNoPreferredStatements_getBestStatementsReturnsOnlyNormal
541541 );
542542 }
543543
544+ public function testGivenNotPresentStatement_getIndexByGuidReturnsFalse () {
545+ $ statements = new StatementList ();
546+
547+ $ this ->assertFalse ( $ statements ->getIndexByGuid ( $ this ->getStatement ( 1 , 'kittens ' ) ) );
548+ }
549+
550+ public function testGivenPresentStatement_getIndexByGuidReturnsItsIndex () {
551+ $ statements = new StatementList ( array (
552+ $ this ->getStatement ( 43 , 'kittens43 ' ),
553+ $ this ->getStatement ( 42 , 'kittens42 ' ),
554+ $ this ->getStatement ( 41 , 'kittens41 ' ),
555+ ) );
556+
557+ $ this ->assertSame (
558+ 1 ,
559+ $ statements ->getIndexByGuid ( $ this ->getStatement ( 42 , 'kittens42 ' ) )
560+ );
561+ }
562+
563+ public function testGivenDoublyPresentStatement_getIndexByGuidReturnsTheFirstIndex () {
564+ $ statements = new StatementList ( array (
565+ $ this ->getStatement ( 43 , 'kittens43 ' ),
566+ $ this ->getStatement ( 42 , 'kittens42 ' ),
567+ $ this ->getStatement ( 41 , 'kittens41 ' ),
568+ $ this ->getStatement ( 42 , 'kittens42 ' ),
569+ ) );
570+
571+ $ this ->assertSame (
572+ 1 ,
573+ $ statements ->getIndexByGuid ( $ this ->getStatement ( 42 , 'kittens42 ' ) )
574+ );
575+ }
576+
577+ public function testGivenDifferentStatementWithSameGuid_getIndexByGuidReturnsItsIndex () {
578+ $ statements = new StatementList ( array (
579+ $ this ->getStatement ( 1 , 'kittens43 ' ),
580+ $ this ->getStatement ( 2 , 'kittens42 ' ),
581+ $ this ->getStatement ( 3 , 'kittens41 ' ),
582+ ) );
583+
584+ $ this ->assertSame (
585+ 2 ,
586+ $ statements ->getIndexByGuid ( $ this ->getStatement ( 42 , 'kittens41 ' ) )
587+ );
588+ }
589+
544590}
0 commit comments