|
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 => 36; |
4 |
use Test::More tests => 46; |
| 5 |
|
5 |
|
| 6 |
use MARC::Record; |
6 |
use MARC::Record; |
| 7 |
|
7 |
|
|
Lines 65-70
my $subscriptionid_from_another_branch = NewSubscription(
Link Here
|
| 65 |
|
65 |
|
| 66 |
my $subscription_from_my_branch = GetSubscription( $subscriptionid_from_my_branch ); |
66 |
my $subscription_from_my_branch = GetSubscription( $subscriptionid_from_my_branch ); |
| 67 |
is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 0, "cannot edit a subscription without userenv set"); |
67 |
is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 0, "cannot edit a subscription without userenv set"); |
|
|
68 |
is( C4::Serials::can_claim_subscription($subscription_from_my_branch), 0, "cannot edit a subscription without userenv set"); |
| 68 |
|
69 |
|
| 69 |
my $userid = 'my_userid'; |
70 |
my $userid = 'my_userid'; |
| 70 |
my $borrowernumber = C4::Members::AddMember( |
71 |
my $borrowernumber = C4::Members::AddMember( |
|
Lines 80-85
$userenv = { flags => 1, id => $borrowernumber, branch => '' };
Link Here
|
| 80 |
# Can edit a subscription |
81 |
# Can edit a subscription |
| 81 |
|
82 |
|
| 82 |
is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 1, "User can edit a subscription with an empty branchcode"); |
83 |
is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 1, "User can edit a subscription with an empty branchcode"); |
|
|
84 |
is( C4::Serials::can_claim_subscription($subscription_from_my_branch), 1, "User can edit a subscription with an empty branchcode"); |
| 83 |
|
85 |
|
| 84 |
my $subscription_from_another_branch = GetSubscription( $subscriptionid_from_another_branch ); |
86 |
my $subscription_from_another_branch = GetSubscription( $subscriptionid_from_another_branch ); |
| 85 |
|
87 |
|
|
Lines 101-106
is( C4::Serials::can_show_subscription($subscription_from_my_branch), 1,
Link Here
|
| 101 |
is( C4::Serials::can_show_subscription($subscription_from_another_branch), 1, |
103 |
is( C4::Serials::can_show_subscription($subscription_from_another_branch), 1, |
| 102 |
"With IndependentBranches, superlibrarian can show a subscription from another branch" |
104 |
"With IndependentBranches, superlibrarian can show a subscription from another branch" |
| 103 |
); |
105 |
); |
|
|
106 |
is( C4::Serials::can_claim_subscription($subscription_from_my_branch), 1, |
| 107 |
"With IndependentBranches, superlibrarian can claim a subscription from his branch" |
| 108 |
); |
| 109 |
is( C4::Serials::can_claim_subscription($subscription_from_another_branch), 1, |
| 110 |
"With IndependentBranches, superlibrarian can claim a subscription from another branch" |
| 111 |
); |
| 112 |
|
| 104 |
|
113 |
|
| 105 |
set_flags( 'superserials', $borrowernumber ); |
114 |
set_flags( 'superserials', $borrowernumber ); |
| 106 |
is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 1, |
115 |
is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 1, |
|
Lines 115-120
is( C4::Serials::can_show_subscription($subscription_from_my_branch), 1,
Link Here
|
| 115 |
is( C4::Serials::can_show_subscription($subscription_from_another_branch), 1, |
124 |
is( C4::Serials::can_show_subscription($subscription_from_another_branch), 1, |
| 116 |
"With IndependentBranches, superserials can show a subscription from another branch" |
125 |
"With IndependentBranches, superserials can show a subscription from another branch" |
| 117 |
); |
126 |
); |
|
|
127 |
is( C4::Serials::can_claim_subscription($subscription_from_my_branch), 1, |
| 128 |
"With IndependentBranches, superserials can claim a subscription from his branch" |
| 129 |
); |
| 130 |
is( C4::Serials::can_claim_subscription($subscription_from_another_branch), 1, |
| 131 |
"With IndependentBranches, superserials can claim a subscription from another branch" |
| 132 |
); |
| 133 |
|
| 118 |
|
134 |
|
| 119 |
|
135 |
|
| 120 |
set_flags( 'edit_subscription', $borrowernumber ); |
136 |
set_flags( 'edit_subscription', $borrowernumber ); |
|
Lines 130-135
is( C4::Serials::can_show_subscription($subscription_from_my_branch), 1,
Link Here
|
| 130 |
is( C4::Serials::can_show_subscription($subscription_from_another_branch), 0, |
146 |
is( C4::Serials::can_show_subscription($subscription_from_another_branch), 0, |
| 131 |
"With IndependentBranches, show_subscription cannot show a subscription from another branch" |
147 |
"With IndependentBranches, show_subscription cannot show a subscription from another branch" |
| 132 |
); |
148 |
); |
|
|
149 |
is( C4::Serials::can_claim_subscription($subscription_from_my_branch), 0, |
| 150 |
"With IndependentBranches, claim_subscription cannot claim a subscription from his branch with the edit_subscription permission" |
| 151 |
); |
| 152 |
is( C4::Serials::can_claim_subscription($subscription_from_another_branch), 0, |
| 153 |
"With IndependentBranches, claim_subscription cannot claim a subscription from another branch" |
| 154 |
); |
| 155 |
|
| 133 |
|
156 |
|
| 134 |
set_flags( 'renew_subscription', $borrowernumber ); |
157 |
set_flags( 'renew_subscription', $borrowernumber ); |
| 135 |
is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 0, |
158 |
is( C4::Serials::can_edit_subscription($subscription_from_my_branch), 0, |
|
Lines 145-150
is( C4::Serials::can_show_subscription($subscription_from_another_branch), 0,
Link Here
|
| 145 |
"With IndependentBranches, renew_subscription cannot show a subscription from another branch" |
168 |
"With IndependentBranches, renew_subscription cannot show a subscription from another branch" |
| 146 |
); |
169 |
); |
| 147 |
|
170 |
|
|
|
171 |
set_flags( 'claim_serials', $borrowernumber ); |
| 172 |
is( C4::Serials::can_claim_subscription($subscription_from_my_branch), 1, |
| 173 |
"With IndependentBranches, claim_subscription can claim a subscription from his branch with the edit_subscription permission" |
| 174 |
); |
| 175 |
is( C4::Serials::can_claim_subscription($subscription_from_another_branch), 0, |
| 176 |
"With IndependentBranches, claim_subscription cannot claim a subscription from another branch" |
| 177 |
); |
| 148 |
|
178 |
|
| 149 |
# Branches are not independent |
179 |
# Branches are not independent |
| 150 |
t::lib::Mocks::mock_preference( "IndependentBranches", 0 ); |
180 |
t::lib::Mocks::mock_preference( "IndependentBranches", 0 ); |
| 151 |
- |
|
|