@@ -567,57 +567,46 @@ public function testWhenNoPreferredStatements_getBestStatementsReturnsOnlyNormal
567567 );
568568 }
569569
570- public function testGivenNotPresentStatement_getIndexByGuidReturnsFalse () {
570+ public function testGivenNotPresentStatement_getFirstStatementByGuidReturnsNull () {
571571 $ statements = new StatementList ();
572572
573- $ this ->assertFalse ( $ statements ->getIndexByGuid ( 'kittens ' ) );
573+ $ this ->assertNull ( $ statements ->getFirstStatementByGuid ( 'kittens ' ) );
574574 }
575575
576- public function testGivenPresentStatement_getIndexByGuidReturnsItsIndex () {
577- $ statements = new StatementList ( array (
578- $ this ->getStatement ( 43 , 'kittens43 ' ),
579- $ this ->getStatement ( 42 , 'kittens42 ' ),
580- $ this ->getStatement ( 41 , 'kittens41 ' ),
581- ) );
576+ public function testGivenPresentStatement_getFirstStatementByGuidReturnsStatement () {
577+ $ statement1 = $ this ->getStatement ( 1 , 'guid1 ' );
578+ $ statement2 = $ this ->getStatement ( 2 , 'guid2 ' );
579+ $ statement3 = $ this ->getStatement ( 3 , 'guid3 ' );
580+ $ statements = new StatementList ( $ statement1 , $ statement2 , $ statement3 );
582581
583- $ this ->assertSame (
584- 1 ,
585- $ statements ->getIndexByGuid ( 'kittens42 ' )
586- );
582+ $ actual = $ statements ->getFirstStatementByGuid ( 'guid2 ' );
583+ $ this ->assertSame ( $ statement2 , $ actual );
587584 }
588585
589- public function testGivenDoublyPresentStatement_getIndexByGuidReturnsTheFirstIndex () {
590- $ statements = new StatementList ( array (
591- $ this ->getStatement ( 43 , 'kittens43 ' ),
592- $ this ->getStatement ( 42 , 'kittens42 ' ),
593- $ this ->getStatement ( 41 , 'kittens41 ' ),
594- $ this ->getStatement ( 42 , 'kittens42 ' ),
595- ) );
586+ public function testGivenDoublyPresentStatement_getFirstStatementByGuidReturnsFirstMatch () {
587+ $ statement1 = $ this ->getStatement ( 1 , 'guid1 ' );
588+ $ statement2 = $ this ->getStatement ( 2 , 'guid2 ' );
589+ $ statement3 = $ this ->getStatement ( 3 , 'guid3 ' );
590+ $ statement4 = $ this ->getStatement ( 2 , 'guid2 ' );
591+ $ statements = new StatementList ( $ statement1 , $ statement2 , $ statement3 , $ statement4 );
596592
597- $ this ->assertSame (
598- 1 ,
599- $ statements ->getIndexByGuid ( 'kittens42 ' )
600- );
593+ $ actual = $ statements ->getFirstStatementByGuid ( 'guid2 ' );
594+ $ this ->assertSame ( $ statement2 , $ actual );
601595 }
602596
603- public function testGivenDifferentStatementWithSameGuid_getIndexByGuidReturnsItsIndex () {
604- $ statements = new StatementList ( array (
605- $ this ->getStatement ( 1 , 'kittens43 ' ),
606- $ this ->getStatement ( 2 , 'kittens42 ' ),
607- $ this ->getStatement ( 3 , 'kittens41 ' ),
608- ) );
597+ public function testGivenStatementsWithNoGuid_getFirstStatementByGuidReturnsFirstMatch () {
598+ $ statement1 = $ this ->getStatement ( 1 , null );
599+ $ statement2 = $ this ->getStatement ( 2 , null );
600+ $ statements = new StatementList ( $ statement1 , $ statement2 );
609601
610- $ this ->assertSame (
611- 2 ,
612- $ statements ->getIndexByGuid ( 'kittens41 ' )
613- );
602+ $ actual = $ statements ->getFirstStatementByGuid ( null );
603+ $ this ->assertSame ( $ statement1 , $ actual );
614604 }
615605
616- public function testGivenInvalidGuid_getIndexByGuidThrowsException () {
606+ public function testGivenInvalidGuid_getFirstStatementByGuidReturnsNull () {
617607 $ statements = new StatementList ();
618608
619- $ this ->setExpectedException ( 'InvalidArgumentException ' );
620- $ statements ->getIndexByGuid ( false );
609+ $ this ->assertNull ( $ statements ->getFirstStatementByGuid ( false ) );
621610 }
622611
623612}
0 commit comments