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',
63 description => 'description',
64 rentalcharge => '0.00',
65 imageurl => 'imageurl',
67 checkinmsg => 'checkinmsg',
68 checkinmsgtype => 'checkinmsgtype',
72 Koha::Localization->new(
74 entity => 'itemtypes',
77 translation => 'b translated itemtype desc'
80 Koha::Localization->new(
82 entity => 'itemtypes',
85 translation => 'a translated itemtype desc'
88 Koha::Localization->new(
90 entity => 'something_else',
93 translation => 'another thing'
97 my $type = Koha::ItemTypes->find('type1');
98 ok( defined($type), 'first result' );
99 is( $type->itemtype, 'type1', 'itemtype/code' );
100 is( $type->description, 'description', 'description' );
101 is( $type->rentalcharge, '0.0000', 'rentalcharge' );
102 is( $type->imageurl, 'imageurl', 'imageurl' );
103 is( $type->summary, 'summary', 'summary' );
104 is( $type->checkinmsg, 'checkinmsg', 'checkinmsg' );
105 is( $type->checkinmsgtype, 'checkinmsgtype', 'checkinmsgtype' );
107 $type = Koha::ItemTypes->find('type2');
108 ok( defined($type), 'second result' );
109 is( $type->itemtype, 'type2', 'itemtype/code' );
110 is( $type->description, 'description', 'description' );
111 is( $type->rentalcharge, '0.0000', 'rentalcharge' );
112 is( $type->imageurl, 'imageurl', 'imageurl' );
113 is( $type->summary, 'summary', 'summary' );
114 is( $type->checkinmsg, 'checkinmsg', 'checkinmsg' );
115 is( $type->checkinmsgtype, 'checkinmsgtype', 'checkinmsgtype' );
117 my $itemtypes = Koha::ItemTypes->search_with_localization;
118 is( $itemtypes->count, 3, 'There are 3 item types' );
119 my $first_itemtype = $itemtypes->next;
121 $first_itemtype->translated_description,
122 'a translated itemtype desc',
123 'item types should be sorted by translated description'
126 $schema->txn_rollback;