View | Details | Raw Unified | Return to bug 17047
Collapse All | Expand All

(-)a/t/db_dependent/Koha/SharedContent.t (+29 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2016 BibLibre Morgane Alonso
4
#
5
# This file is part of Koha
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use t::lib::TestBuilder;
23
use Test::More tests => 1;
24
use Koha::Database;
25
26
use_ok('Koha::SharedContent');
27
28
my $schema = Koha::Database->new->schema;
29
$schema->storage->txn_begin;    # mode insertion
(-)a/t/db_dependent/Koha/Subscription.t (-1 / +111 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# Copyright 2016 BibLibre Morgane Alonso
4
#
5
# This file is part of Koha
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use t::lib::TestBuilder;
23
use Test::More tests => 6;
24
use Koha::Database;
25
use Koha::Subscriptions;
26
use Koha::Biblios;
27
28
use_ok('Koha::Subscription');
29
30
my $schema = Koha::Database->new->schema;
31
$schema->storage->txn_begin;
32
my $builder = t::lib::TestBuilder->new;
33
34
my $nb_of_subs = Koha::Subscriptions->search->count;
35
my $biblio_1   = $builder->build( { source => 'Biblio' } );
36
my $bi_1       = $builder->build(
37
    {
38
        source => 'Biblioitem',
39
        value  => {
40
            biblionumber => $biblio_1->{biblionumber}
41
        }
42
    }
43
);
44
my $sub_freq_1 = $builder->build( { source => 'SubscriptionFrequency' } );
45
my $sub_np_1   = $builder->build( { source => 'SubscriptionNumberpattern' } );
46
my $sub_1      = $builder->build(
47
    {
48
        source => 'Subscription',
49
        value  => {
50
            biblionumber  => $biblio_1->{biblionumber},
51
            periodicity   => $sub_freq_1->{id},
52
            numberpattern => $sub_np_1->{id}
53
        }
54
    }
55
);
56
57
is(
58
    Koha::Subscriptions->search->count,
59
    $nb_of_subs + 1,
60
    'The subscription should have been added'
61
);
62
is(
63
    $sub_1->{biblionumber},
64
    $biblio_1->{biblionumber},
65
    'The link between sub and biblio is well done'
66
);
67
is( $sub_1->{periodicity}, $sub_freq_1->{id},
68
    'The link between sub and sub_freq is well done' );
69
is( $sub_1->{numberpattern},
70
    $sub_np_1->{id},
71
    'The link between sub and sub_numberpattern is well done' );
72
73
my $ref = {
74
    'title'           => $biblio_1->{title},
75
    'notes'           => $sub_1->{notes},
76
    'sfdescription'   => $sub_freq_1->{description},
77
    'displayorder'    => $sub_freq_1->{displayorder},
78
    'unit'            => $sub_freq_1->{unit},
79
    'unitsperissue'   => $sub_freq_1->{unitsperissue},
80
    'issuesperunit'   => $sub_freq_1->{issuesperunit},
81
    'sndescription'   => $sub_np_1->{description},
82
    'numberingmethod' => $sub_np_1->{numberingmethod},
83
    'label1'          => $sub_np_1->{label1},
84
    'add1'            => $sub_np_1->{add1},
85
    'every1'          => $sub_np_1->{every1},
86
    'whenmorethan1'   => $sub_np_1->{whenmorethan1},
87
    'setto1'          => $sub_np_1->{setto1},
88
    'numbering1'      => $sub_np_1->{numbering1},
89
    'label2'          => $sub_np_1->{label2},
90
    'add2'            => $sub_np_1->{add2},
91
    'every2'          => $sub_np_1->{every2},
92
    'whenmorethan2'   => $sub_np_1->{whenmorethan2},
93
    'setto2'          => $sub_np_1->{setto2},
94
    'numbering2'      => $sub_np_1->{numbering2},
95
    'label3'          => $sub_np_1->{label3},
96
    'add3'            => $sub_np_1->{add3},
97
    'every3'          => $sub_np_1->{every3},
98
    'whenmorethan3'   => $sub_np_1->{whenmorethan3},
99
    'setto3'          => $sub_np_1->{setto3},
100
    'numbering3'      => $sub_np_1->{numbering3},
101
    'issn'            => $bi_1->{issn},
102
    'ean'             => $bi_1->{ean},
103
    'publishercode'   => $bi_1->{publishercode}
104
};
105
106
is_deeply( Koha::Subscription::get_sharable_info( $sub_1->{subscriptionid} ),
107
    $ref, "get_sharable_info function is ok" );
108
109
$schema->storage->txn_rollback;
110
111
1;

Return to bug 17047