Bug 20434: Update UNIMARC framework - authorised values
[koha.git] / t / db_dependent / Serials / ReNewSubscription.t
blob1a90c5150185e5c1b036deceaa95dfa4a31e06cf
1 #!/usr/bin/perl
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>.
22 use Modern::Perl;
24 use Test::More tests => 1;
25 use Test::MockModule;
26 use t::lib::TestBuilder;
27 use t::lib::Mocks;
29 use C4::Serials;
31 use Koha::Database;
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',
42 value => {
43 description => "daily",
44 unit => "day",
45 unitsperissue => 1,
47 });
49 my $pattern = $builder->build({
50 source => 'SubscriptionNumberpattern',
51 value => {
52 label => 'mock',
53 description =>'mock',
54 numberingmethod => 'Issue {X}',
55 add1 => 1,
56 every1 => 1,
57 setto1 => 100,
59 });
61 # Create fake subscription, daily subscription, duration 12 months, issues startint at #100
62 my $subscription = $builder->build({
63 source => 'Subscription',
64 value => {
65 biblionumber => 1,
66 startdate => '2015-01-01',
67 enddate => '2015-12-31',
68 aqbooksellerid => 1,
69 periodicity => $frequency->{id},
70 numberpattern => $pattern->{id},
71 monthlength => 12,
73 });
75 my $subscriptionhistory = $builder->build({
76 source => 'Subscriptionhistory',
77 value => {
78 subscriptionid => $subscription->{subscriptionid},
79 histenddate => undef,
80 opacnote => 'Testing',
82 });
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');
92 # End of tests
94 $schema->storage->txn_rollback;