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 my $biblio = $builder->build_sample_biblio();
63 # Create fake subscription, daily subscription, duration 12 months, issues startint at #100
64 my $subscription = $builder->build({
65 source => 'Subscription',
67 biblionumber => $biblio->biblionumber,
68 startdate => '2015-01-01',
69 enddate => '2015-12-31',
71 periodicity => $frequency->{id},
72 numberpattern => $pattern->{id},
77 my $subscriptionhistory = $builder->build({
78 source => 'Subscriptionhistory',
80 biblionumber => $biblio->biblionumber,
81 subscriptionid => $subscription->{subscriptionid},
83 opacnote => 'Testing',
87 # Actual testing starts here!
88 # Renew the subscription and check that enddate has not been set
91 subscriptionid => $subscription->{subscriptionid},
92 startdate => "2016-01-01",
96 my $history = Koha::Subscription::Histories->find($subscription->{subscriptionid});
98 is ( $history->histenddate(), undef, 'subscription history not empty after renewal');
102 $schema->storage->txn_rollback;