Lines 19-25
Link Here
|
19 |
|
19 |
|
20 |
use Modern::Perl; |
20 |
use Modern::Perl; |
21 |
|
21 |
|
22 |
use Test::More tests => 20; |
22 |
use Test::More tests => 22; |
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; |
Lines 117-123
Koha::Item->new(
Link Here
|
117 |
itemnumber => 1, |
117 |
itemnumber => 1, |
118 |
biblionumber => 1, |
118 |
biblionumber => 1, |
119 |
biblioitemnumber =>1, |
119 |
biblioitemnumber =>1, |
120 |
itype => 'type2', |
120 |
itype => 'type1', |
121 |
notforloan => 1, |
121 |
notforloan => 1, |
122 |
itemlost => 0, |
122 |
itemlost => 0, |
123 |
} |
123 |
} |
Lines 155-162
is(
Link Here
|
155 |
'item types should be sorted by translated description' |
155 |
'item types should be sorted by translated description' |
156 |
); |
156 |
); |
157 |
|
157 |
|
158 |
subtest is_used => sub{ |
158 |
sub is_used { |
159 |
plan test => 2; |
159 |
require Test::More; |
160 |
my $itemtype_code = shift; |
160 |
my $itemtype_code = shift; |
161 |
my $schema = Koha::Database->new()->schema(); |
161 |
my $schema = Koha::Database->new()->schema(); |
162 |
my $itemtotal = Koha::Items->search({ 'itype' => $itemtype_code })->count; |
162 |
my $itemtotal = Koha::Items->search({ 'itype' => $itemtype_code })->count; |
Lines 164-171
subtest is_used => sub{
Link Here
|
164 |
my $overalltotal = $itemtotal + $bibliototal; |
164 |
my $overalltotal = $itemtotal + $bibliototal; |
165 |
return $overalltotal; |
165 |
return $overalltotal; |
166 |
} |
166 |
} |
167 |
for my $itemtype_code ('type1', 'type 2') { |
167 |
|
168 |
subtest "is_used $itemtype_code", \&is_used, $range; |
168 |
my $passcount = is_used('type1'); |
169 |
} |
169 |
is ( $passcount,2,'Exists in the database, test is successful'); |
|
|
170 |
|
171 |
my $failcount = is_used('type2'); |
172 |
is ( $failcount,0,'Doesnt exist in database, test is success'); |
170 |
|
173 |
|
171 |
$schema->txn_rollback; |
174 |
$schema->txn_rollback; |
172 |
- |
|
|