Line 0
Link Here
|
0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
|
3 |
# This file is part of Koha. |
4 |
# |
5 |
# Koha is free software; you can redistribute it and/or modify it under the |
6 |
# terms of the GNU General Public License as published by the Free Software |
7 |
# Foundation; either version 3 of the License, or (at your option) any later |
8 |
# version. |
9 |
# |
10 |
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY |
11 |
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
12 |
# A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
13 |
# |
14 |
# You should have received a copy of the GNU General Public License along |
15 |
# with Koha; if not, see <http://www.gnu.org/licenses>. |
16 |
|
17 |
use Modern::Perl; |
18 |
|
19 |
use Test::More tests => 2; |
20 |
|
21 |
use t::lib::TestBuilder; |
22 |
use t::lib::Mocks; |
23 |
use Koha::Biblio::ItemGroups; |
24 |
use Koha::Template::Plugin::ItemGroups; |
25 |
|
26 |
my $schema = Koha::Database->schema; |
27 |
my $builder = t::lib::TestBuilder->new; |
28 |
|
29 |
$schema->storage->txn_begin; |
30 |
|
31 |
ok( my $settings = Koha::Template::Plugin::ItemGroups->new(), 'Able to instantiate template plugin' ); |
32 |
|
33 |
subtest 'Item_Groups' => sub { |
34 |
plan tests => 2; |
35 |
|
36 |
my $biblio = $builder->build_sample_biblio(); |
37 |
my $item_group_count = Koha::Template::Plugin::ItemGroups->getCount( $biblio->id ); |
38 |
|
39 |
is( $item_group_count, 0, '0 items correctly counted in the item group' ); |
40 |
|
41 |
#Add some item groups to the bib |
42 |
my $item_group_1 = |
43 |
Koha::Biblio::ItemGroup->new( { biblio_id => $biblio->id, display_order => 2, description => "Vol 2" } ) |
44 |
->store(); |
45 |
my $item_group_2 = |
46 |
Koha::Biblio::ItemGroup->new( { biblio_id => $biblio->id, display_order => 3, description => "Vol 3" } ) |
47 |
->store(); |
48 |
my $item_group_3 = |
49 |
Koha::Biblio::ItemGroup->new( { biblio_id => $biblio->id, display_order => 1, description => "Vol 1" } ) |
50 |
->store(); |
51 |
|
52 |
$item_group_count = Koha::Template::Plugin::ItemGroups->getCount( $biblio->id ); |
53 |
|
54 |
is( $item_group_count, 3, '3 items correctly counted in the item group' ); |
55 |
}; |
56 |
|
57 |
$schema->storage->txn_rollback; |