1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace spec\Scriptotek\Alma\Users; |
4
|
|
|
|
5
|
|
|
use PhpSpec\ObjectBehavior; |
6
|
|
|
use Psr\Http\Message\UriInterface; |
7
|
|
|
use Scriptotek\Alma\Client as AlmaClient; |
8
|
|
|
use Scriptotek\Alma\Users\Fee; |
9
|
|
|
use Scriptotek\Alma\Users\Fees; |
10
|
|
|
use Scriptotek\Alma\Users\User; |
11
|
|
|
use spec\Scriptotek\Alma\SpecHelper; |
12
|
|
|
|
13
|
|
|
class FeesSpec extends ObjectBehavior |
14
|
|
|
{ |
15
|
|
|
public function let(AlmaClient $client, User $user) |
16
|
|
|
{ |
17
|
|
|
$user->id = '123435'; |
18
|
|
|
$this->beConstructedWith($client, $user); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
function it_is_initializable() |
22
|
|
|
{ |
23
|
|
|
$this->shouldHaveType(Fees::class); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function it_yields_fees(AlmaClient $client, UriInterface $url) |
27
|
|
|
{ |
28
|
|
|
$client->buildUrl('/users/123435/fees', []) |
29
|
|
|
->shouldBeCalled() |
30
|
|
|
->willReturn($url); |
31
|
|
|
|
32
|
|
|
$client->getJSON($url) |
33
|
|
|
->shouldBeCalled() |
34
|
|
|
->willReturn(SpecHelper::getDummyData('fees_response.json')); |
35
|
|
|
|
36
|
|
|
$this->total_sum->shouldBe(750); |
|
|
|
|
37
|
|
|
|
38
|
|
|
$this->rewind(); |
39
|
|
|
$this->valid()->shouldBe(true); |
40
|
|
|
$this->current()->shouldBeAnInstanceOf(Fee::class); |
41
|
|
|
|
42
|
|
|
$this->shouldHaveCount(1); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function it_can_be_empty(AlmaClient $client, UriInterface $url) |
46
|
|
|
{ |
47
|
|
|
$client->buildUrl('/users/123435/fees', []) |
48
|
|
|
->shouldBeCalled() |
49
|
|
|
->willReturn($url); |
50
|
|
|
|
51
|
|
|
$client->getJSON($url) |
52
|
|
|
->shouldBeCalled() |
53
|
|
|
->willReturn(SpecHelper::getDummyData('zero_fees_response.json')); |
54
|
|
|
|
55
|
|
|
$this->rewind(); |
56
|
|
|
$this->valid()->shouldBe(false); |
57
|
|
|
|
58
|
|
|
$this->shouldHaveCount(0); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
} |
62
|
|
|
|
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.