Lines 1-7
Link Here
|
1 |
#!/usr/bin/perl |
1 |
#!/usr/bin/perl |
2 |
use Modern::Perl; |
2 |
use Modern::Perl; |
3 |
|
3 |
|
4 |
use Test::More tests => 37; |
4 |
use Test::More tests => 47; |
5 |
|
5 |
|
6 |
use MARC::Record; |
6 |
use MARC::Record; |
7 |
|
7 |
|
Lines 71-76
my $subscriptionid_from_another_branch = NewSubscription(
Link Here
|
71 |
|
71 |
|
72 |
my $subscription_from_my_branch = GetSubscription( $subscriptionid_from_my_branch ); |
72 |
my $subscription_from_my_branch = GetSubscription( $subscriptionid_from_my_branch ); |
73 |
is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 0, "cannot edit a subscription without userenv set"); |
73 |
is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 0, "cannot edit a subscription without userenv set"); |
|
|
74 |
is( C4::Serials::can_claim_subscription($subscription_from_my_branch), 0, "cannot edit a subscription without userenv set"); |
74 |
|
75 |
|
75 |
my $userid = 'my_userid'; |
76 |
my $userid = 'my_userid'; |
76 |
my $borrowernumber = C4::Members::AddMember( |
77 |
my $borrowernumber = C4::Members::AddMember( |
Lines 86-91
$userenv = { flags => 1, id => $borrowernumber, branch => '' };
Link Here
|
86 |
# Can edit a subscription |
87 |
# Can edit a subscription |
87 |
|
88 |
|
88 |
is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 1, "User can edit a subscription with an empty branchcode"); |
89 |
is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 1, "User can edit a subscription with an empty branchcode"); |
|
|
90 |
is( C4::Serials::can_claim_subscription($subscription_from_my_branch), 1, "User can edit a subscription with an empty branchcode"); |
89 |
|
91 |
|
90 |
my $subscription_from_another_branch = GetSubscription( $subscriptionid_from_another_branch ); |
92 |
my $subscription_from_another_branch = GetSubscription( $subscriptionid_from_another_branch ); |
91 |
|
93 |
|
Lines 107-112
is( C4::Serials::can_show_subscription($subscription_from_my_branch), 1,
Link Here
|
107 |
is( C4::Serials::can_show_subscription($subscription_from_another_branch), 1, |
109 |
is( C4::Serials::can_show_subscription($subscription_from_another_branch), 1, |
108 |
"With IndependentBranches, superlibrarian can show a subscription from another branch" |
110 |
"With IndependentBranches, superlibrarian can show a subscription from another branch" |
109 |
); |
111 |
); |
|
|
112 |
is( C4::Serials::can_claim_subscription($subscription_from_my_branch), 1, |
113 |
"With IndependentBranches, superlibrarian can claim a subscription from his branch" |
114 |
); |
115 |
is( C4::Serials::can_claim_subscription($subscription_from_another_branch), 1, |
116 |
"With IndependentBranches, superlibrarian can claim a subscription from another branch" |
117 |
); |
118 |
|
110 |
|
119 |
|
111 |
set_flags( 'superserials', $borrowernumber ); |
120 |
set_flags( 'superserials', $borrowernumber ); |
112 |
is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 1, |
121 |
is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 1, |
Lines 121-126
is( C4::Serials::can_show_subscription($subscription_from_my_branch), 1,
Link Here
|
121 |
is( C4::Serials::can_show_subscription($subscription_from_another_branch), 1, |
130 |
is( C4::Serials::can_show_subscription($subscription_from_another_branch), 1, |
122 |
"With IndependentBranches, superserials can show a subscription from another branch" |
131 |
"With IndependentBranches, superserials can show a subscription from another branch" |
123 |
); |
132 |
); |
|
|
133 |
is( C4::Serials::can_claim_subscription($subscription_from_my_branch), 1, |
134 |
"With IndependentBranches, superserials can claim a subscription from his branch" |
135 |
); |
136 |
is( C4::Serials::can_claim_subscription($subscription_from_another_branch), 1, |
137 |
"With IndependentBranches, superserials can claim a subscription from another branch" |
138 |
); |
139 |
|
124 |
|
140 |
|
125 |
|
141 |
|
126 |
set_flags( 'edit_subscription', $borrowernumber ); |
142 |
set_flags( 'edit_subscription', $borrowernumber ); |
Lines 136-141
is( C4::Serials::can_show_subscription($subscription_from_my_branch), 1,
Link Here
|
136 |
is( C4::Serials::can_show_subscription($subscription_from_another_branch), 0, |
152 |
is( C4::Serials::can_show_subscription($subscription_from_another_branch), 0, |
137 |
"With IndependentBranches, show_subscription cannot show a subscription from another branch" |
153 |
"With IndependentBranches, show_subscription cannot show a subscription from another branch" |
138 |
); |
154 |
); |
|
|
155 |
is( C4::Serials::can_claim_subscription($subscription_from_my_branch), 0, |
156 |
"With IndependentBranches, claim_subscription cannot claim a subscription from his branch with the edit_subscription permission" |
157 |
); |
158 |
is( C4::Serials::can_claim_subscription($subscription_from_another_branch), 0, |
159 |
"With IndependentBranches, claim_subscription cannot claim a subscription from another branch" |
160 |
); |
161 |
|
139 |
|
162 |
|
140 |
set_flags( 'renew_subscription', $borrowernumber ); |
163 |
set_flags( 'renew_subscription', $borrowernumber ); |
141 |
is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 0, |
164 |
is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 0, |
Lines 151-156
is( C4::Serials::can_show_subscription($subscription_from_another_branch), 0,
Link Here
|
151 |
"With IndependentBranches, renew_subscription cannot show a subscription from another branch" |
174 |
"With IndependentBranches, renew_subscription cannot show a subscription from another branch" |
152 |
); |
175 |
); |
153 |
|
176 |
|
|
|
177 |
set_flags( 'claim_serials', $borrowernumber ); |
178 |
is( C4::Serials::can_claim_subscription($subscription_from_my_branch), 1, |
179 |
"With IndependentBranches, claim_subscription can claim a subscription from his branch with the edit_subscription permission" |
180 |
); |
181 |
is( C4::Serials::can_claim_subscription($subscription_from_another_branch), 0, |
182 |
"With IndependentBranches, claim_subscription cannot claim a subscription from another branch" |
183 |
); |
154 |
|
184 |
|
155 |
# Branches are not independent |
185 |
# Branches are not independent |
156 |
t::lib::Mocks::mock_preference( "IndependentBranches", 0 ); |
186 |
t::lib::Mocks::mock_preference( "IndependentBranches", 0 ); |
157 |
- |
|
|