|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace spec\Scriptotek\Alma\Bibs; |
|
4
|
|
|
|
|
5
|
|
|
use PhpSpec\ObjectBehavior; |
|
6
|
|
|
use Scriptotek\Alma\Bibs\Bib; |
|
7
|
|
|
use Scriptotek\Alma\Bibs\Holding; |
|
8
|
|
|
use Scriptotek\Alma\Bibs\Item; |
|
9
|
|
|
use Scriptotek\Alma\Bibs\ScanInResponse; |
|
10
|
|
|
use Scriptotek\Alma\Client as AlmaClient; |
|
11
|
|
|
use Scriptotek\Alma\Conf\Library; |
|
12
|
|
|
use Scriptotek\Alma\Users\Loan; |
|
13
|
|
|
use Scriptotek\Alma\Users\Requests; |
|
14
|
|
|
use Scriptotek\Alma\Users\User; |
|
15
|
|
|
use spec\Scriptotek\Alma\SpecHelper; |
|
16
|
|
|
|
|
17
|
|
|
class ItemSpec extends ObjectBehavior |
|
18
|
|
|
{ |
|
19
|
|
|
public function let(AlmaClient $client, Bib $bib, Holding $holding) |
|
20
|
|
|
{ |
|
21
|
|
|
$bib->mms_id = '990006312214702204'; |
|
22
|
|
|
$holding->holding_id = '22163771200002204'; |
|
23
|
|
|
$item_id = '23163771190002204'; |
|
24
|
|
|
|
|
25
|
|
|
$this->beConstructedWith($client, $bib, $holding, $item_id); |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
public function it_is_initializable() |
|
29
|
|
|
{ |
|
30
|
|
|
$this->shouldHaveType(Item::class); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
public function it_can_be_checked_out(AlmaClient $client, User $user, Library $library) |
|
34
|
|
|
{ |
|
35
|
|
|
$client->postJSON( |
|
36
|
|
|
'/bibs/990006312214702204/holdings/22163771200002204/items/23163771190002204/loans?user_id=Dan+Michael', |
|
37
|
|
|
[ |
|
38
|
|
|
'library' => ['value' => 'THAT LIBRARY'], |
|
39
|
|
|
'circ_desk' => ['value' => 'DEFAULT_CIRC_DESK'], |
|
40
|
|
|
] |
|
41
|
|
|
) |
|
42
|
|
|
->shouldBeCalled() |
|
43
|
|
|
->willReturn(SpecHelper::getDummyData('create_loan_response.json')); |
|
44
|
|
|
|
|
45
|
|
|
$user->id = 'Dan Michael'; |
|
46
|
|
|
$library->code = 'THAT LIBRARY'; |
|
47
|
|
|
|
|
48
|
|
|
$this->checkOut($user, $library) |
|
49
|
|
|
->shouldHaveType(Loan::class); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
View Code Duplication |
public function it_can_be_on_loan(AlmaClient $client, User $user, Library $library) |
|
|
|
|
|
|
53
|
|
|
{ |
|
54
|
|
|
$client->getJSON('/bibs/990006312214702204/holdings/22163771200002204/items/23163771190002204/loans') |
|
55
|
|
|
->shouldBeCalled() |
|
56
|
|
|
->willReturn(SpecHelper::getDummyData('item_loan_response.json')); |
|
57
|
|
|
|
|
58
|
|
|
$this->getLoan()->shouldHaveType(Loan::class); |
|
59
|
|
|
$this->loan->shouldHaveType(Loan::class); |
|
|
|
|
|
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
View Code Duplication |
public function it_can_be_available(AlmaClient $client, User $user, Library $library) |
|
|
|
|
|
|
63
|
|
|
{ |
|
64
|
|
|
$client->getJSON('/bibs/990006312214702204/holdings/22163771200002204/items/23163771190002204/loans') |
|
65
|
|
|
->shouldBeCalled() |
|
66
|
|
|
->willReturn(SpecHelper::getDummyData('item_no_loan_response.json')); |
|
67
|
|
|
|
|
68
|
|
|
$this->getLoan()->shouldBe(null); |
|
69
|
|
|
$this->loan->shouldBe(null); |
|
|
|
|
|
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
public function it_can_be_scanned_in(AlmaClient $client, Library $library) |
|
73
|
|
|
{ |
|
74
|
|
|
$client->postJSON('/bibs/990006312214702204/holdings/22163771200002204/items/23163771190002204?op=scan&library=THAT+LIBRARY&circ_desk=DEFAULT_CIRC_DESK') |
|
75
|
|
|
->shouldBeCalled() |
|
76
|
|
|
->willReturn(SpecHelper::getDummyData('scanin_transit_response.json')); |
|
77
|
|
|
|
|
78
|
|
|
$library->code = 'THAT LIBRARY'; |
|
79
|
|
|
|
|
80
|
|
|
$this->scanIn($library) |
|
81
|
|
|
->shouldHaveType(ScanInResponse::class); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
public function it_can_be_scanned_in_with_params(AlmaClient $client, Library $library) |
|
85
|
|
|
{ |
|
86
|
|
|
$client->postJSON('/bibs/990006312214702204/holdings/22163771200002204/items/23163771190002204?place_on_hold_shelf=true&op=scan&library=THAT+LIBRARY&circ_desk=OTHER_DESK') |
|
87
|
|
|
->shouldBeCalled() |
|
88
|
|
|
->willReturn(SpecHelper::getDummyData('scanin_transit_response.json')); |
|
89
|
|
|
|
|
90
|
|
|
$library->code = 'THAT LIBRARY'; |
|
91
|
|
|
|
|
92
|
|
|
$this->scanIn($library, 'OTHER_DESK', ['place_on_hold_shelf' => 'true']) |
|
93
|
|
|
->shouldHaveType(ScanInResponse::class); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
public function it_has_requests() |
|
97
|
|
|
{ |
|
98
|
|
|
$this->requests->shouldHaveType(Requests::class); |
|
|
|
|
|
|
99
|
|
|
} |
|
100
|
|
|
} |
|
101
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.