3 use Test::More tests => 15;
6 use_ok('C4::Circulation');
9 my $CircControl = C4::Context->preference('CircControl');
10 my $HomeOrHoldingBranch = C4::Context->preference('HomeOrHoldingBranch');
13 homebranch => 'ItemHomeBranch',
14 holdingbranch => 'ItemHoldingBranch'
18 branchcode => 'BorrowerBranch'
21 # No userenv, PickupLibrary
22 C4::Context->set_preference('CircControl', 'PickupLibrary');
24 C4::Context->preference('CircControl'),
26 'CircControl changed to PickupLibrary'
29 C4::Circulation::_GetCircControlBranch($item, $borrower),
30 $item->{$HomeOrHoldingBranch},
31 '_GetCircControlBranch returned item branch (no userenv defined)'
34 # No userenv, PatronLibrary
35 C4::Context->set_preference('CircControl', 'PatronLibrary');
37 C4::Context->preference('CircControl'),
39 'CircControl changed to PatronLibrary'
42 C4::Circulation::_GetCircControlBranch($item, $borrower),
43 $borrower->{branchcode},
44 '_GetCircControlBranch returned borrower branch'
47 # No userenv, ItemHomeLibrary
48 C4::Context->set_preference('CircControl', 'ItemHomeLibrary');
50 C4::Context->preference('CircControl'),
52 'CircControl changed to ItemHomeLibrary'
55 $item->{$HomeOrHoldingBranch},
56 C4::Circulation::_GetCircControlBranch($item, $borrower),
57 '_GetCircControlBranch returned item branch'
60 diag('Now, set a userenv');
61 C4::Context->_new_userenv('xxx');
62 C4::Context::set_userenv(0,0,0,'firstname','surname', 'CurrentBranch', 'CurrentBranchName', '', '', '');
63 is(C4::Context->userenv->{branch}, 'CurrentBranch', 'userenv set');
65 # Userenv set, PickupLibrary
66 C4::Context->set_preference('CircControl', 'PickupLibrary');
68 C4::Context->preference('CircControl'),
70 'CircControl changed to PickupLibrary'
73 C4::Circulation::_GetCircControlBranch($item, $borrower),
75 '_GetCircControlBranch returned current branch'
78 # Userenv set, PatronLibrary
79 C4::Context->set_preference('CircControl', 'PatronLibrary');
81 C4::Context->preference('CircControl'),
83 'CircControl changed to PatronLibrary'
86 C4::Circulation::_GetCircControlBranch($item, $borrower),
87 $borrower->{branchcode},
88 '_GetCircControlBranch returned borrower branch'
91 # Userenv set, ItemHomeLibrary
92 C4::Context->set_preference('CircControl', 'ItemHomeLibrary');
94 C4::Context->preference('CircControl'),
96 'CircControl changed to ItemHomeLibrary'
99 C4::Circulation::_GetCircControlBranch($item, $borrower),
100 $item->{$HomeOrHoldingBranch},
101 '_GetCircControlBranch returned item branch'
104 # Reset initial configuration
105 C4::Context->set_preference('CircControl', $CircControl);
107 C4::Context->preference('CircControl'),
109 'CircControl reset to its initial value'