3 # Copyright 2014 Catalyst IT
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 3 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, write to the Free Software Foundation, Inc.,
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 use Test::More tests => 20;
27 use_ok('Koha::ItemType');
28 use_ok('Koha::ItemTypes');
31 my $database = Koha::Database->new();
32 my $schema = $database->schema();
34 Koha::ItemTypes->delete;
39 description => 'description',
40 rentalcharge => '0.00',
41 imageurl => 'imageurl',
43 checkinmsg => 'checkinmsg',
44 checkinmsgtype => 'checkinmsgtype',
51 description => 'description',
52 rentalcharge => '0.00',
53 imageurl => 'imageurl',
55 checkinmsg => 'checkinmsg',
56 checkinmsgtype => 'checkinmsgtype',
60 Koha::Localization->new(
62 entity => 'itemtypes',
65 translation => 'b translated itemtype desc'
68 Koha::Localization->new(
70 entity => 'itemtypes',
73 translation => 'a translated itemtype desc'
76 Koha::Localization->new(
78 entity => 'something_else',
81 translation => 'another thing'
85 my $type = Koha::ItemTypes->find('type1');
86 ok( defined($type), 'first result' );
87 is( $type->itemtype, 'type1', 'itemtype/code' );
88 is( $type->description, 'description', 'description' );
89 is( $type->rentalcharge, '0.0000', 'rentalcharge' );
90 is( $type->imageurl, 'imageurl', 'imageurl' );
91 is( $type->summary, 'summary', 'summary' );
92 is( $type->checkinmsg, 'checkinmsg', 'checkinmsg' );
93 is( $type->checkinmsgtype, 'checkinmsgtype', 'checkinmsgtype' );
95 $type = Koha::ItemTypes->find('type2');
96 ok( defined($type), 'second result' );
97 is( $type->itemtype, 'type2', 'itemtype/code' );
98 is( $type->description, 'description', 'description' );
99 is( $type->rentalcharge, '0.0000', 'rentalcharge' );
100 is( $type->imageurl, 'imageurl', 'imageurl' );
101 is( $type->summary, 'summary', 'summary' );
102 is( $type->checkinmsg, 'checkinmsg', 'checkinmsg' );
103 is( $type->checkinmsgtype, 'checkinmsgtype', 'checkinmsgtype' );
105 my $itemtypes = Koha::ItemTypes->search_with_localization;
106 is( $itemtypes->count, 2, 'There are 2 item types' );
107 my $first_itemtype = $itemtypes->next;
109 $first_itemtype->translated_description,
110 'a translated itemtype desc',
111 'item types should be sorted by translated description'
114 $schema->txn_rollback;