Lines 23-32
use C4::Biblio;
Link Here
|
23 |
use C4::Branch; |
23 |
use C4::Branch; |
24 |
use Koha::Database; |
24 |
use Koha::Database; |
25 |
|
25 |
|
26 |
use Test::More tests => 6; |
26 |
use Test::More tests => 8; |
27 |
|
27 |
|
28 |
BEGIN { |
28 |
BEGIN { |
29 |
use_ok('C4::Items'); |
29 |
use_ok('C4::Items'); |
|
|
30 |
use_ok('Koha::Items'); |
30 |
} |
31 |
} |
31 |
|
32 |
|
32 |
my $dbh = C4::Context->dbh; |
33 |
my $dbh = C4::Context->dbh; |
Lines 386-391
subtest 'SearchItems test' => sub {
Link Here
|
386 |
$dbh->rollback; |
387 |
$dbh->rollback; |
387 |
}; |
388 |
}; |
388 |
|
389 |
|
|
|
390 |
subtest 'Koha::Item(s) tests' => sub { |
391 |
|
392 |
plan tests => 5; |
393 |
|
394 |
# Start transaction |
395 |
my $schema = Koha::Database->new()->schema(); |
396 |
$schema->storage->txn_begin(); |
397 |
$dbh->{RaiseError} = 1; |
398 |
|
399 |
# Create a biblio and item for testing |
400 |
C4::Context->set_preference('marcflavour', 'MARC21'); |
401 |
my ($bibnum, $bibitemnum) = get_biblio(); |
402 |
my ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => $branch1, holdingbranch => $branch2 } , $bibnum); |
403 |
|
404 |
# Get item. |
405 |
my $item = Koha::Items->find( $itemnumber ); |
406 |
ok( $item, "Got Koha::Item" ); |
407 |
|
408 |
my $homebranch = $item->home_branch(); |
409 |
ok( $homebranch, "Got Koha::Branch from home_branch method" ); |
410 |
is( $homebranch->branchcode(), $branch1, "Home branch code matches homebranch" ); |
411 |
|
412 |
my $holdingbranch = $item->holding_branch(); |
413 |
ok( $holdingbranch, "Got Koha::Branch from holding_branch method" ); |
414 |
is( $holdingbranch->branchcode(), $branch2, "Home branch code matches holdingbranch" ); |
415 |
}; |
416 |
|
389 |
# Helper method to set up a Biblio. |
417 |
# Helper method to set up a Biblio. |
390 |
sub get_biblio { |
418 |
sub get_biblio { |
391 |
my $bib = MARC::Record->new(); |
419 |
my $bib = MARC::Record->new(); |
392 |
- |
|
|