| @@ 12-52 (lines=41) @@ | ||
| 9 | use Scriptotek\Alma\Users\User; |
|
| 10 | use spec\Scriptotek\Alma\SpecHelper; |
|
| 11 | ||
| 12 | class FeesSpec extends ObjectBehavior |
|
| 13 | { |
|
| 14 | public function let(AlmaClient $client, User $user) |
|
| 15 | { |
|
| 16 | $user->id = '123435'; |
|
| 17 | $this->beConstructedWith($client, $user); |
|
| 18 | } |
|
| 19 | ||
| 20 | public function it_is_initializable() |
|
| 21 | { |
|
| 22 | $this->shouldHaveType(Fees::class); |
|
| 23 | } |
|
| 24 | ||
| 25 | public function it_yields_fees(AlmaClient $client) |
|
| 26 | { |
|
| 27 | $client->getJSON('/users/123435/fees') |
|
| 28 | ->shouldBeCalled() |
|
| 29 | ->willReturn(SpecHelper::getDummyData('fees_response.json')); |
|
| 30 | ||
| 31 | $this->total_sum->shouldBe(750); |
|
| 32 | ||
| 33 | $this->rewind(); |
|
| 34 | $this->valid()->shouldBe(true); |
|
| 35 | $this->current()->shouldBeAnInstanceOf(Fee::class); |
|
| 36 | ||
| 37 | $this->shouldHaveCount(1); |
|
| 38 | } |
|
| 39 | ||
| 40 | public function it_can_be_empty(AlmaClient $client) |
|
| 41 | { |
|
| 42 | $client->getJSON('/users/123435/fees') |
|
| 43 | ->shouldBeCalled() |
|
| 44 | ->willReturn(SpecHelper::getDummyData('zero_fees_response.json')); |
|
| 45 | ||
| 46 | $this->rewind(); |
|
| 47 | $this->valid()->shouldBe(false); |
|
| 48 | ||
| 49 | $this->shouldHaveCount(0); |
|
| 50 | } |
|
| 51 | } |
|
| 52 | ||
| @@ 12-49 (lines=38) @@ | ||
| 9 | use Scriptotek\Alma\Users\User; |
|
| 10 | use spec\Scriptotek\Alma\SpecHelper; |
|
| 11 | ||
| 12 | class LoansSpec extends ObjectBehavior |
|
| 13 | { |
|
| 14 | public function let(AlmaClient $client, User $user) |
|
| 15 | { |
|
| 16 | $user->id = '123435'; |
|
| 17 | $this->beConstructedWith($client, $user); |
|
| 18 | } |
|
| 19 | ||
| 20 | public function it_is_initializable() |
|
| 21 | { |
|
| 22 | $this->shouldHaveType(Loans::class); |
|
| 23 | } |
|
| 24 | ||
| 25 | public function it_yields_loans(AlmaClient $client) |
|
| 26 | { |
|
| 27 | $client->getJSON('/users/123435/loans?offset=0&limit=10') |
|
| 28 | ->shouldBeCalled() |
|
| 29 | ->willReturn(SpecHelper::getDummyData('loans_response.json')); |
|
| 30 | ||
| 31 | $this->rewind(); |
|
| 32 | $this->valid()->shouldBe(true); |
|
| 33 | $this->current()->shouldBeAnInstanceOf(Loan::class); |
|
| 34 | ||
| 35 | $this->shouldHaveCount(2); |
|
| 36 | } |
|
| 37 | ||
| 38 | public function it_can_be_empty(AlmaClient $client) |
|
| 39 | { |
|
| 40 | $client->getJSON('/users/123435/loans?offset=0&limit=10') |
|
| 41 | ->shouldBeCalled() |
|
| 42 | ->willReturn(SpecHelper::getDummyData('zero_loans_response.json')); |
|
| 43 | ||
| 44 | $this->rewind(); |
|
| 45 | $this->valid()->shouldBe(false); |
|
| 46 | ||
| 47 | $this->shouldHaveCount(0); |
|
| 48 | } |
|
| 49 | } |
|
| 50 | ||