22
33namespace spec \LaraPackage \RandomId ;
44
5- use LaraPackage \RandomId \Contracts \Retriever ;
6- use App \Contracts \Uri \Parser ;
75use PhpSpec \ObjectBehavior ;
6+ use PrometheusApi \Utilities \Contracts \Uri \Parser ;
87use Prophecy \Argument ;
98
109class HelperSpec extends ObjectBehavior
1110{
12- function it_gets_random_id_using_config ( \ App \ Contracts \ Config \ ApiVersion $ config )
11+ function it_gets_random_id_using_an_override ( )
1312 {
1413 $ resource = '/attributes/{random_id} ' ;
15- $ version = 4 ;
16- $ return = [8 ];
17- $ this ->configExpectation ($ config , $ resource , 4 , $ return );
18- $ this ->getRandomIdsForUri ($ resource , $ version )->shouldReturn ($ return );
14+ $ id = 8 ;
15+ $ return = [$ id ];
16+ $ idOverrideClosure = function ($ uri , $ idPlaceholder ) use ($ resource , $ id ) {
17+ return [$ id ];
18+ };
19+
20+
21+ $ this ->getRandomIdsForUri ($ resource , $ idOverrideClosure )->shouldReturn ($ return );
1922 }
2023
2124 function it_gets_random_ids_for_a_resource (Parser $ parser , \LaraPackage \RandomId \Contracts \Retriever $ idRetriever )
@@ -30,7 +33,7 @@ function it_gets_random_ids_for_a_resource(Parser $parser, \LaraPackage\RandomId
3033 $ parser ->idEntities ($ resource , $ idPlaceholder )->shouldBeCalled ()->willReturn ($ idEntities );
3134 $ parser ->entities ($ resource , $ idPlaceholder )->shouldBeCalled ()->willReturn ($ entities );
3235 $ idRetriever ->getRandomIds ($ entities , $ idEntities )->shouldBeCalled ()->willReturn ($ expected );
33- $ this ->getRandomIdsForUri ($ resource, 4 )->shouldReturn ($ expected );
36+ $ this ->getRandomIdsForUri ($ resource )->shouldReturn ($ expected );
3437 }
3538
3639 function it_gets_random_ids_for_the_last_entity (Parser $ parser , \LaraPackage \RandomId \Contracts \Retriever $ idRetriever )
@@ -68,7 +71,7 @@ function it_gets_random_ids_for_the_last_entity_not_in_pivot(Parser $parser, \La
6871
6972 function it_is_initializable ()
7073 {
71- $ this ->shouldHaveType ('LaraPackage\IdRetriever \Helper ' );
74+ $ this ->shouldHaveType ('LaraPackage\RandomId \Helper ' );
7275 }
7376
7477 function it_puts_random_ids_into_the_payload ()
@@ -90,13 +93,8 @@ function it_puts_the_supplied_ids_into_a_resource(Parser $parser)
9093 $ this ->putIdsInUri ($ resource , $ ids )->shouldReturn ($ expected );
9194 }
9295
93- function let (Parser $ parser , \LaraPackage \RandomId \Contracts \Retriever $ idRetriever , \App \Contracts \Config \ApiVersion $ config )
94- {
95- $ this ->beConstructedWith ($ parser , $ idRetriever , $ config );
96- }
97-
98- protected function configExpectation (\App \Contracts \Config \ApiVersion $ config , $ resource , $ version , $ return )
96+ function let (Parser $ parser , \LaraPackage \RandomId \Contracts \Retriever $ idRetriever )
9997 {
100- $ config -> resourceIdMap ( $ resource , $ version )-> shouldBeCalled ()-> willReturn ( $ return );
98+ $ this -> beConstructedWith ( $ parser , $ idRetriever );
10199 }
102100}
0 commit comments