3 # This script includes tests for ReNewSubscription
5 # Copyright 2015 BibLibre, Paul Poulain
7 # This file is part of Koha.
9 # Koha is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3 of the License, or
12 # (at your option) any later version.
14 # Koha is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with Koha; if not, see <http://www.gnu.org/licenses>.
24 use Test
::More tests
=> 1;
26 use t
::lib
::TestBuilder
;
32 use Koha
::Subscription
::Histories
;
34 my $schema = Koha
::Database
->new->schema;
35 $schema->storage->txn_begin;
37 my $builder = t
::lib
::TestBuilder
->new();
39 # create fake numberpattern & fake periodicity
40 my $frequency = $builder->build({
41 source
=> 'SubscriptionFrequency',
43 description
=> "daily",
49 my $pattern = $builder->build({
50 source
=> 'SubscriptionNumberpattern',
54 numberingmethod
=> 'Issue {X}',
61 # Create fake subscription, daily subscription, duration 12 months, issues startint at #100
62 my $subscription = $builder->build({
63 source
=> 'Subscription',
66 startdate
=> '2015-01-01',
67 enddate
=> '2015-12-31',
69 periodicity
=> $frequency->{id
},
70 numberpattern
=> $pattern->{id
},
75 my $subscriptionhistory = $builder->build({
76 source
=> 'Subscriptionhistory',
78 subscriptionid
=> $subscription->{subscriptionid
},
80 opacnote
=> 'Testing',
84 # Actual testing starts here!
86 # Renew the subscription and check that enddate has not been set
87 ReNewSubscription
($subscription->{subscriptionid
},'',"2016-01-01",'','',12,'');
88 my $history = Koha
::Subscription
::Histories
->find($subscription->{subscriptionid
});
90 is
( $history->histenddate(), undef, 'subscription history not empty after renewal');
94 $schema->storage->txn_rollback;