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 3
3
namespace spec \Scriptotek \Alma \Conf ;
4
4
5
5
use PhpSpec \ObjectBehavior ;
6
+ use Prophecy \Argument ;
6
7
use Scriptotek \Alma \Client as AlmaClient ;
7
8
use Scriptotek \Alma \Conf \Job ;
8
9
use spec \Scriptotek \Alma \SpecHelper ;
@@ -12,8 +13,6 @@ class JobsSpec extends ObjectBehavior
12
13
public function let (AlmaClient $ client )
13
14
{
14
15
$ this ->beConstructedWith ($ client );
15
- $ client ->getJSON ('/conf/jobs ' )
16
- ->willReturn (SpecHelper::getDummyData ('jobs_response.json ' ));
17
16
}
18
17
19
18
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)
27
26
$ job ->job_id ->shouldBe ($ job_id );
28
27
}
29
28
30
- public function it_provides_jobs ()
29
+ public function it_provides_jobs (AlmaClient $ client )
31
30
{
31
+ $ client ->getJSON (Argument::containingString ('/conf/jobs? ' ))
32
+ ->shouldBeCalled ()
33
+ ->willReturn (SpecHelper::getDummyData ('jobs_response.json ' ));
34
+
32
35
$ this ->all ()->shouldBeArray ();
33
36
$ this ->all ()[0 ]->shouldBeAnInstanceOf (Job::class);
34
37
}
Original file line number Diff line number Diff line change @@ -24,10 +24,16 @@ protected function fetchBatch()
24
24
return ;
25
25
}
26
26
27
- $ response = $ this -> client -> getJSON ( $ this ->url ('' , [
27
+ $ url = $ this ->url ('' , [
28
28
'offset ' => $ this ->offset ,
29
29
'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
+ }
31
37
32
38
return $ this ->onData ($ response );
33
39
}
You can’t perform that action at this time.
0 commit comments