File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change 33namespace spec \Scriptotek \Alma \Conf ;
44
55use PhpSpec \ObjectBehavior ;
6+ use Prophecy \Argument ;
67use Scriptotek \Alma \Client as AlmaClient ;
78use Scriptotek \Alma \Conf \Job ;
89use spec \Scriptotek \Alma \SpecHelper ;
@@ -12,8 +13,6 @@ class JobsSpec extends ObjectBehavior
1213 public function let (AlmaClient $ client )
1314 {
1415 $ this ->beConstructedWith ($ client );
15- $ client ->getJSON ('/conf/jobs ' )
16- ->willReturn (SpecHelper::getDummyData ('jobs_response.json ' ));
1716 }
1817
1918 public function it_provides_a_lazy_interface_to_job_objects (AlmaClient $ client )
@@ -27,8 +26,12 @@ public function it_provides_a_lazy_interface_to_job_objects(AlmaClient $client)
2726 $ job ->job_id ->shouldBe ($ job_id );
2827 }
2928
30- public function it_provides_jobs ()
29+ public function it_provides_jobs (AlmaClient $ client )
3130 {
31+ $ client ->getJSON (Argument::containingString ('/conf/jobs? ' ))
32+ ->shouldBeCalled ()
33+ ->willReturn (SpecHelper::getDummyData ('jobs_response.json ' ));
34+
3235 $ this ->all ()->shouldBeArray ();
3336 $ this ->all ()[0 ]->shouldBeAnInstanceOf (Job::class);
3437 }
Original file line number Diff line number Diff line change @@ -24,10 +24,16 @@ protected function fetchBatch()
2424 return ;
2525 }
2626
27- $ response = $ this -> client -> getJSON ( $ this ->url ('' , [
27+ $ url = $ this ->url ('' , [
2828 'offset ' => $ this ->offset ,
2929 'limit ' => $ this ->limit ,
30- ]));
30+ ]);
31+
32+ $ response = $ this ->client ->getJSON ($ url );
33+
34+ if (is_null ($ response )) {
35+ throw new \RuntimeException ("Empty response from URL: $ url " );
36+ }
3137
3238 return $ this ->onData ($ response );
3339 }
You can’t perform that action at this time.
0 commit comments