Lines 23-28
use Test::More tests => 20;
Link Here
|
23 |
use Data::Dumper; |
23 |
use Data::Dumper; |
24 |
use Koha::Database; |
24 |
use Koha::Database; |
25 |
use t::lib::Mocks; |
25 |
use t::lib::Mocks; |
|
|
26 |
use Koha::Items; |
27 |
use Koha::Biblioitems; |
26 |
|
28 |
|
27 |
BEGIN { |
29 |
BEGIN { |
28 |
use_ok('Koha::ItemType'); |
30 |
use_ok('Koha::ItemType'); |
Lines 95-100
Koha::Localization->new(
Link Here
|
95 |
} |
97 |
} |
96 |
)->store; |
98 |
)->store; |
97 |
|
99 |
|
|
|
100 |
Koha::Biblio->new( |
101 |
{ |
102 |
biblionumber => 1, |
103 |
} |
104 |
)->store; |
105 |
|
106 |
Koha::Biblioitem->new( |
107 |
{ |
108 |
biblioitemnumber => 1, |
109 |
biblionumber => 1, |
110 |
itemtype => 'type1' |
111 |
} |
112 |
)->store; |
113 |
|
114 |
|
115 |
Koha::Item->new( |
116 |
{ |
117 |
itemnumber => 1, |
118 |
biblionumber => 1, |
119 |
biblioitemnumber =>1, |
120 |
itype => 'type2', |
121 |
notforloan => 1, |
122 |
itemlost => 0, |
123 |
} |
124 |
)->store; |
125 |
|
126 |
|
98 |
my $type = Koha::ItemTypes->find('type1'); |
127 |
my $type = Koha::ItemTypes->find('type1'); |
99 |
ok( defined($type), 'first result' ); |
128 |
ok( defined($type), 'first result' ); |
100 |
is( $type->itemtype, 'type1', 'itemtype/code' ); |
129 |
is( $type->itemtype, 'type1', 'itemtype/code' ); |
Lines 126-129
is(
Link Here
|
126 |
'item types should be sorted by translated description' |
155 |
'item types should be sorted by translated description' |
127 |
); |
156 |
); |
128 |
|
157 |
|
|
|
158 |
subtest is_used => sub{ |
159 |
plan test => 2; |
160 |
my $itemtype_code = shift; |
161 |
my $schema = Koha::Database->new()->schema(); |
162 |
my $itemtotal = Koha::Items->search({ 'itype' => $itemtype_code })->count; |
163 |
my $bibliototal = Koha::Biblioitems->search({ 'itemtype' => $itemtype_code})->count; |
164 |
my $overalltotal = $itemtotal + $bibliototal; |
165 |
return $overalltotal; |
166 |
} |
167 |
for my $itemtype_code ('type1', 'type 2') { |
168 |
subtest "is_used $itemtype_code", \&is_used, $range; |
169 |
} |
170 |
|
129 |
$schema->txn_rollback; |
171 |
$schema->txn_rollback; |
130 |
- |
|
|