Lines 22-28
Link Here
|
22 |
|
22 |
|
23 |
use Modern::Perl; |
23 |
use Modern::Perl; |
24 |
|
24 |
|
25 |
use Test::More tests => 7; |
25 |
use Test::More tests => 10; |
26 |
use Test::MockModule; |
26 |
use Test::MockModule; |
27 |
use t::lib::TestBuilder; |
27 |
use t::lib::TestBuilder; |
28 |
use t::lib::Mocks; |
28 |
use t::lib::Mocks; |
Lines 85-92
my $subscriptionhistory = $builder->build({
Link Here
|
85 |
} |
85 |
} |
86 |
}); |
86 |
}); |
87 |
|
87 |
|
|
|
88 |
t::lib::Mocks::mock_preference( 'RenewSerialAddsSuggestion', '0' ); |
89 |
my $suggestions_count = Koha::Suggestions->search()->count; |
90 |
|
88 |
# Actual testing starts here! |
91 |
# Actual testing starts here! |
89 |
# Renew the subscription and check that enddate has not been set |
92 |
# Renew the subscription and check that enddate has been set |
|
|
93 |
ReNewSubscription( |
94 |
{ |
95 |
subscriptionid => $subscription->{subscriptionid}, |
96 |
startdate => "2016-01-01", |
97 |
monthlength => 12 |
98 |
} |
99 |
); |
100 |
|
101 |
$subscription = Koha::Subscriptions->find( $subscription->{subscriptionid} ); |
102 |
is( $subscription->enddate, '2017-01-01', "We don't update the subscription end date when renewing with a month length"); |
103 |
|
104 |
is( $suggestions_count, Koha::Suggestions->search()->count, "Suggestion not added when RenewSerialAddsSuggestion set to Don't add"); |
105 |
|
106 |
t::lib::Mocks::mock_preference( 'RenewSerialAddsSuggestion', '1' ); |
107 |
|
90 |
ReNewSubscription( |
108 |
ReNewSubscription( |
91 |
{ |
109 |
{ |
92 |
subscriptionid => $subscription->{subscriptionid}, |
110 |
subscriptionid => $subscription->{subscriptionid}, |
Lines 95-101
ReNewSubscription(
Link Here
|
95 |
} |
113 |
} |
96 |
); |
114 |
); |
97 |
|
115 |
|
|
|
116 |
is( $suggestions_count + 1, Koha::Suggestions->search()->count, "Suggestion added when RenewSerialAddsSuggestion set to add"); |
117 |
|
118 |
my $history = Koha::Subscription::Histories->find($subscription->subscriptionid); |
119 |
|
120 |
is ( $history->histenddate(), undef, 'subscription history not empty after renewal'); |
98 |
# Calculate the subscription length for the renewal for issues, days and months |
121 |
# Calculate the subscription length for the renewal for issues, days and months |
|
|
122 |
|
99 |
my ($numberlength, $weeklength, $monthlength) = GetSubscriptionLength('issues', 7); |
123 |
my ($numberlength, $weeklength, $monthlength) = GetSubscriptionLength('issues', 7); |
100 |
is ( $numberlength, 7, "Subscription length is 7 issues"); |
124 |
is ( $numberlength, 7, "Subscription length is 7 issues"); |
101 |
|
125 |
|
Lines 117-128
is ($monthlength, undef, "Subscription length is undef issues, invalid issue dat
Link Here
|
117 |
($numberlength, $weeklength, $monthlength) = GetSubscriptionLength('weeks', '!'); |
141 |
($numberlength, $weeklength, $monthlength) = GetSubscriptionLength('weeks', '!'); |
118 |
is ($weeklength, undef, "Subscription length is undef weeks, invalid weeks data was not stored"); |
142 |
is ($weeklength, undef, "Subscription length is undef weeks, invalid weeks data was not stored"); |
119 |
|
143 |
|
120 |
# Renew the subscription and check that enddate has not been set |
|
|
121 |
|
122 |
my $history = Koha::Subscription::Histories->find($subscription->{subscriptionid}); |
123 |
|
124 |
is ( $history->histenddate(), undef, 'subscription history not empty after renewal'); |
125 |
|
126 |
# End of tests |
144 |
# End of tests |
127 |
|
145 |
|
128 |
$schema->storage->txn_rollback; |
146 |
$schema->storage->txn_rollback; |
129 |
- |
|
|