Lines 34-40
BEGIN {
Link Here
|
34 |
use_ok('Koha::Items'); |
34 |
use_ok('Koha::Items'); |
35 |
} |
35 |
} |
36 |
|
36 |
|
37 |
my $dbh = C4::Context->dbh; |
37 |
my $schema = Koha::Database->new->schema; |
|
|
38 |
|
38 |
my $branches = GetBranches; |
39 |
my $branches = GetBranches; |
39 |
my ($branch1, $branch2) = keys %$branches; |
40 |
my ($branch1, $branch2) = keys %$branches; |
40 |
my $location = 'My Location'; |
41 |
my $location = 'My Location'; |
Lines 43-51
subtest 'General Add, Get and Del tests' => sub {
Link Here
|
43 |
|
44 |
|
44 |
plan tests => 14; |
45 |
plan tests => 14; |
45 |
|
46 |
|
46 |
# Start transaction |
47 |
$schema->storage->txn_begin; |
47 |
$dbh->{AutoCommit} = 0; |
|
|
48 |
$dbh->{RaiseError} = 1; |
49 |
|
48 |
|
50 |
# Create a biblio instance for testing |
49 |
# Create a biblio instance for testing |
51 |
C4::Context->set_preference('marcflavour', 'MARC21'); |
50 |
C4::Context->set_preference('marcflavour', 'MARC21'); |
Lines 88-94
subtest 'General Add, Get and Del tests' => sub {
Link Here
|
88 |
is( $getitem->{location}, 'CART', "The location should have been set to CART" ); |
87 |
is( $getitem->{location}, 'CART', "The location should have been set to CART" ); |
89 |
is( $getitem->{permanent_location}, $location, "The permanent_location should not have been set to CART" ); |
88 |
is( $getitem->{permanent_location}, $location, "The permanent_location should not have been set to CART" ); |
90 |
|
89 |
|
91 |
$dbh->rollback; |
90 |
$schema->storage->txn_rollback; |
92 |
}; |
91 |
}; |
93 |
|
92 |
|
94 |
subtest 'GetHiddenItemnumbers tests' => sub { |
93 |
subtest 'GetHiddenItemnumbers tests' => sub { |
Lines 97-105
subtest 'GetHiddenItemnumbers tests' => sub {
Link Here
|
97 |
|
96 |
|
98 |
# This sub is controlled by the OpacHiddenItems system preference. |
97 |
# This sub is controlled by the OpacHiddenItems system preference. |
99 |
|
98 |
|
100 |
# Start transaction |
99 |
$schema->storage->txn_begin; |
101 |
$dbh->{AutoCommit} = 0; |
|
|
102 |
$dbh->{RaiseError} = 1; |
103 |
|
100 |
|
104 |
# Create a new biblio |
101 |
# Create a new biblio |
105 |
C4::Context->set_preference('marcflavour', 'MARC21'); |
102 |
C4::Context->set_preference('marcflavour', 'MARC21'); |
Lines 175-190
subtest 'GetHiddenItemnumbers tests' => sub {
Link Here
|
175 |
@hidden = GetHiddenItemnumbers( @items ); |
172 |
@hidden = GetHiddenItemnumbers( @items ); |
176 |
ok( scalar @hidden == 0, "Empty items list, no item hidden"); |
173 |
ok( scalar @hidden == 0, "Empty items list, no item hidden"); |
177 |
|
174 |
|
178 |
$dbh->rollback; |
175 |
$schema->storage->txn_rollback; |
179 |
}; |
176 |
}; |
180 |
|
177 |
|
181 |
subtest 'GetItemsInfo tests' => sub { |
178 |
subtest 'GetItemsInfo tests' => sub { |
182 |
|
179 |
|
183 |
plan tests => 4; |
180 |
plan tests => 4; |
184 |
|
181 |
|
185 |
# Start transaction |
182 |
$schema->storage->txn_begin; |
186 |
$dbh->{AutoCommit} = 0; |
|
|
187 |
$dbh->{RaiseError} = 1; |
188 |
|
183 |
|
189 |
# Add a biblio |
184 |
# Add a biblio |
190 |
my ($biblionumber, $biblioitemnumber) = get_biblio(); |
185 |
my ($biblionumber, $biblioitemnumber) = get_biblio(); |
Lines 212-227
subtest 'GetItemsInfo tests' => sub {
Link Here
|
212 |
is( exists( $results[0]->{ onsite_checkout } ), 1, |
207 |
is( exists( $results[0]->{ onsite_checkout } ), 1, |
213 |
'GetItemsInfo returns a onsite_checkout key' ); |
208 |
'GetItemsInfo returns a onsite_checkout key' ); |
214 |
|
209 |
|
215 |
$dbh->rollback; |
210 |
$schema->storage->txn_rollback; |
216 |
}; |
211 |
}; |
217 |
|
212 |
|
218 |
subtest q{Test Koha::Database->schema()->resultset('Item')->itemtype()} => sub { |
213 |
subtest q{Test Koha::Database->schema()->resultset('Item')->itemtype()} => sub { |
219 |
|
214 |
|
220 |
plan tests => 4; |
215 |
plan tests => 4; |
221 |
|
216 |
|
222 |
# Start transaction |
217 |
$schema->storage->txn_begin; |
223 |
$dbh->{AutoCommit} = 0; |
|
|
224 |
$dbh->{RaiseError} = 1; |
225 |
|
218 |
|
226 |
my $schema = Koha::Database->new()->schema(); |
219 |
my $schema = Koha::Database->new()->schema(); |
227 |
|
220 |
|
Lines 260-274
subtest q{Test Koha::Database->schema()->resultset('Item')->itemtype()} => sub {
Link Here
|
260 |
$effective_itemtype eq 'BIB_LEVEL', |
253 |
$effective_itemtype eq 'BIB_LEVEL', |
261 |
'$item->effective_itemtype() falls back to biblioitems.itemtype when item-level_itypes is enabled but undef' ); |
254 |
'$item->effective_itemtype() falls back to biblioitems.itemtype when item-level_itypes is enabled but undef' ); |
262 |
|
255 |
|
263 |
$dbh->rollback; |
256 |
$schema->storage->txn_rollback; |
264 |
}; |
257 |
}; |
265 |
|
258 |
|
266 |
subtest 'SearchItems test' => sub { |
259 |
subtest 'SearchItems test' => sub { |
267 |
plan tests => 14; |
260 |
plan tests => 14; |
268 |
|
261 |
|
269 |
# Start transaction |
262 |
$schema->storage->txn_begin; |
270 |
$dbh->{AutoCommit} = 0; |
263 |
my $dbh = C4::Context->dbh; |
271 |
$dbh->{RaiseError} = 1; |
|
|
272 |
|
264 |
|
273 |
C4::Context->set_preference('marcflavour', 'MARC21'); |
265 |
C4::Context->set_preference('marcflavour', 'MARC21'); |
274 |
my $cpl_items_before = SearchItemsByField( 'homebranch', 'CPL'); |
266 |
my $cpl_items_before = SearchItemsByField( 'homebranch', 'CPL'); |
Lines 424-440
subtest 'SearchItems test' => sub {
Link Here
|
424 |
my $cpl_items_after = SearchItemsByField( 'homebranch', 'CPL'); |
416 |
my $cpl_items_after = SearchItemsByField( 'homebranch', 'CPL'); |
425 |
is( ( scalar( @$cpl_items_after ) - scalar ( @$cpl_items_before ) ), 1, 'SearchItemsByField should return something' ); |
417 |
is( ( scalar( @$cpl_items_after ) - scalar ( @$cpl_items_before ) ), 1, 'SearchItemsByField should return something' ); |
426 |
|
418 |
|
427 |
$dbh->rollback; |
419 |
$schema->storage->txn_rollback; |
428 |
}; |
420 |
}; |
429 |
|
421 |
|
430 |
subtest 'Koha::Item(s) tests' => sub { |
422 |
subtest 'Koha::Item(s) tests' => sub { |
431 |
|
423 |
|
432 |
plan tests => 5; |
424 |
plan tests => 5; |
433 |
|
425 |
|
434 |
# Start transaction |
|
|
435 |
my $schema = Koha::Database->new()->schema(); |
436 |
$schema->storage->txn_begin(); |
426 |
$schema->storage->txn_begin(); |
437 |
$dbh->{RaiseError} = 1; |
|
|
438 |
|
427 |
|
439 |
# Create a biblio and item for testing |
428 |
# Create a biblio and item for testing |
440 |
C4::Context->set_preference('marcflavour', 'MARC21'); |
429 |
C4::Context->set_preference('marcflavour', 'MARC21'); |
Lines 457-464
subtest 'Koha::Item(s) tests' => sub {
Link Here
|
457 |
subtest 'C4::Biblio::EmbedItemsInMarcBiblio' => sub { |
446 |
subtest 'C4::Biblio::EmbedItemsInMarcBiblio' => sub { |
458 |
plan tests => 7; |
447 |
plan tests => 7; |
459 |
|
448 |
|
460 |
$dbh->{AutoCommit} = 0; |
449 |
$schema->storage->txn_begin(); |
461 |
$dbh->{RaiseError} = 1; |
|
|
462 |
|
450 |
|
463 |
my ( $biblionumber, $biblioitemnumber ) = get_biblio(); |
451 |
my ( $biblionumber, $biblioitemnumber ) = get_biblio(); |
464 |
my $item_infos = [ |
452 |
my $item_infos = [ |