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\Fees; |
9
|
|
|
use Scriptotek\Alma\Users\Loans; |
10
|
|
|
use Scriptotek\Alma\Users\User; |
11
|
|
|
use spec\Scriptotek\Alma\SpecHelper; |
12
|
|
|
|
13
|
|
|
class UserSpec extends ObjectBehavior |
14
|
|
|
{ |
15
|
|
|
public function let(AlmaClient $client, UriInterface $url) |
16
|
|
|
{ |
17
|
|
|
$this->beConstructedWith($client, '12345'); |
18
|
|
|
|
19
|
|
|
$client->buildUrl('/users/12345', []) |
20
|
|
|
->willReturn($url); |
21
|
|
|
|
22
|
|
|
$client->getJSON($url) |
23
|
|
|
->willReturn(SpecHelper::getDummyData('user_response.json')); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function it_is_initializable() |
27
|
|
|
{ |
28
|
|
|
$this->shouldHaveType(User::class); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function it_has_primary_id() |
32
|
|
|
{ |
33
|
|
|
$this->primaryId->shouldBe('12345'); |
|
|
|
|
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
public function it_has_barcode() |
37
|
|
|
{ |
38
|
|
|
$this->barcode->shouldBe('ub54321'); |
|
|
|
|
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function it_has_barcodes() |
42
|
|
|
{ |
43
|
|
|
$this->barcodes->shouldBe(['ub54321', 'ntb12897787']); |
|
|
|
|
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
public function it_has_university_id() |
47
|
|
|
{ |
48
|
|
|
$this->universityId->shouldBe('[email protected]'); |
|
|
|
|
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function it_has_university_ids() |
52
|
|
|
{ |
53
|
|
|
$this->universityIds->shouldBe(['[email protected]']); |
|
|
|
|
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function it_has_identifiers() |
57
|
|
|
{ |
58
|
|
|
$this->identifiers->all()->shouldBe(['12345', 'ub54321', 'ntb12897787', '[email protected]']); |
|
|
|
|
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
function it_has_loans(AlmaClient $client) |
62
|
|
|
{ |
63
|
|
|
SpecHelper::expectNoRequests($client); |
64
|
|
|
$this->loans->shouldHaveType(Loans::class); |
|
|
|
|
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
function it_has_fees(AlmaClient $client) |
68
|
|
|
{ |
69
|
|
|
SpecHelper::expectNoRequests($client); |
70
|
|
|
$this->fees->shouldHaveType(Fees::class); |
|
|
|
|
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|
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.