|
Lines 22-27
use Modern::Perl;
Link Here
|
| 22 |
use Test::More tests => 18; |
22 |
use Test::More tests => 18; |
| 23 |
use Data::Dumper; |
23 |
use Data::Dumper; |
| 24 |
use Koha::Database; |
24 |
use Koha::Database; |
|
|
25 |
use Koha::Items; |
| 26 |
use Koha::Biblioitems; |
| 25 |
|
27 |
|
| 26 |
BEGIN { |
28 |
BEGIN { |
| 27 |
use_ok('Koha::ItemType'); |
29 |
use_ok('Koha::ItemType'); |
|
Lines 56-61
Koha::ItemType->new(
Link Here
|
| 56 |
} |
58 |
} |
| 57 |
)->store; |
59 |
)->store; |
| 58 |
|
60 |
|
|
|
61 |
Koha::Biblio->new( |
| 62 |
{ |
| 63 |
biblionumber => 1, |
| 64 |
} |
| 65 |
)->store; |
| 66 |
|
| 67 |
Koha::Biblioitem->new( |
| 68 |
{ |
| 69 |
biblioitemnumber => 1, |
| 70 |
biblionumber => 1, |
| 71 |
itemtype => 'type1' |
| 72 |
} |
| 73 |
)->store; |
| 74 |
|
| 75 |
|
| 76 |
Koha::Item->new( |
| 77 |
{ |
| 78 |
itemnumber => 1, |
| 79 |
biblionumber => 1, |
| 80 |
biblioitemnumber =>1, |
| 81 |
itype => 'type2', |
| 82 |
notforloan => 1, |
| 83 |
itemlost => 0, |
| 84 |
} |
| 85 |
)->store; |
| 86 |
|
| 87 |
|
| 59 |
my $type = Koha::ItemTypes->find('type1'); |
88 |
my $type = Koha::ItemTypes->find('type1'); |
| 60 |
ok( defined($type), 'first result' ); |
89 |
ok( defined($type), 'first result' ); |
| 61 |
is( $type->itemtype, 'type1', 'itemtype/code' ); |
90 |
is( $type->itemtype, 'type1', 'itemtype/code' ); |
|
Lines 76-79
is( $type->summary, 'summary', 'summary' );
Link Here
|
| 76 |
is( $type->checkinmsg, 'checkinmsg', 'checkinmsg' ); |
105 |
is( $type->checkinmsg, 'checkinmsg', 'checkinmsg' ); |
| 77 |
is( $type->checkinmsgtype, 'checkinmsgtype', 'checkinmsgtype' ); |
106 |
is( $type->checkinmsgtype, 'checkinmsgtype', 'checkinmsgtype' ); |
| 78 |
|
107 |
|
|
|
108 |
|
| 109 |
subtest is_used => sub{ |
| 110 |
plan test => 2; |
| 111 |
my $itemtype_code = shift; |
| 112 |
my $schema = Koha::Database->new()->schema(); |
| 113 |
my $itemtotal = Koha::Items->search({ 'itype' => $itemtype_code })->count; |
| 114 |
my $bibliototal = Koha::Biblioitems->search({ 'itemtype' => $itemtype_code})->count; |
| 115 |
my $overalltotal = $itemtotal + $bibliototal; |
| 116 |
return $overalltotal; |
| 117 |
} |
| 118 |
for my $itemtype_code ('type1', 'type 2') { |
| 119 |
subtest "is_used $itemtype_code", \&is_used, $range; |
| 120 |
} |
| 121 |
|
| 79 |
$schema->txn_rollback; |
122 |
$schema->txn_rollback; |
| 80 |
- |
|
|