|
Lines 19-25
Link Here
|
| 19 |
|
19 |
|
| 20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
| 21 |
|
21 |
|
| 22 |
use Test::More tests => 18; |
22 |
use Test::More tests => 20; |
| 23 |
use Data::Dumper; |
23 |
use Data::Dumper; |
| 24 |
use Koha::Database; |
24 |
use Koha::Database; |
| 25 |
|
25 |
|
|
Lines 31-36
BEGIN {
Link Here
|
| 31 |
my $database = Koha::Database->new(); |
31 |
my $database = Koha::Database->new(); |
| 32 |
my $schema = $database->schema(); |
32 |
my $schema = $database->schema(); |
| 33 |
$schema->txn_begin; |
33 |
$schema->txn_begin; |
|
|
34 |
Koha::ItemTypes->delete; |
| 34 |
|
35 |
|
| 35 |
Koha::ItemType->new( |
36 |
Koha::ItemType->new( |
| 36 |
{ |
37 |
{ |
|
Lines 56-61
Koha::ItemType->new(
Link Here
|
| 56 |
} |
57 |
} |
| 57 |
)->store; |
58 |
)->store; |
| 58 |
|
59 |
|
|
|
60 |
Koha::Localization->new( |
| 61 |
{ |
| 62 |
entity => 'itemtypes', |
| 63 |
code => 'type1', |
| 64 |
lang => 'en', |
| 65 |
translation => 'b translated itemtype desc' |
| 66 |
} |
| 67 |
)->store; |
| 68 |
Koha::Localization->new( |
| 69 |
{ |
| 70 |
entity => 'itemtypes', |
| 71 |
code => 'type2', |
| 72 |
lang => 'en', |
| 73 |
translation => 'a translated itemtype desc' |
| 74 |
} |
| 75 |
)->store; |
| 76 |
Koha::Localization->new( |
| 77 |
{ |
| 78 |
entity => 'something_else', |
| 79 |
code => 'type2', |
| 80 |
lang => 'en', |
| 81 |
translation => 'another thing' |
| 82 |
} |
| 83 |
)->store; |
| 84 |
|
| 59 |
my $type = Koha::ItemTypes->find('type1'); |
85 |
my $type = Koha::ItemTypes->find('type1'); |
| 60 |
ok( defined($type), 'first result' ); |
86 |
ok( defined($type), 'first result' ); |
| 61 |
is( $type->itemtype, 'type1', 'itemtype/code' ); |
87 |
is( $type->itemtype, 'type1', 'itemtype/code' ); |
|
Lines 76-79
is( $type->summary, 'summary', 'summary' );
Link Here
|
| 76 |
is( $type->checkinmsg, 'checkinmsg', 'checkinmsg' ); |
102 |
is( $type->checkinmsg, 'checkinmsg', 'checkinmsg' ); |
| 77 |
is( $type->checkinmsgtype, 'checkinmsgtype', 'checkinmsgtype' ); |
103 |
is( $type->checkinmsgtype, 'checkinmsgtype', 'checkinmsgtype' ); |
| 78 |
|
104 |
|
|
|
105 |
my $itemtypes = Koha::ItemTypes->search_with_localization; |
| 106 |
is( $itemtypes->count, 2, 'There are 2 item types' ); |
| 107 |
my $first_itemtype = $itemtypes->next; |
| 108 |
is( |
| 109 |
$first_itemtype->translated_description, |
| 110 |
'a translated itemtype desc', |
| 111 |
'item types should be sorted by translated description' |
| 112 |
); |
| 113 |
|
| 79 |
$schema->txn_rollback; |
114 |
$schema->txn_rollback; |
| 80 |
- |
|
|