use Koha::Patrons;
use Koha::Item;
use Koha::DateUtils;
+use t::lib::TestBuilder;
use Test::More tests => 31;
my $schema = Koha::Database->new()->schema();
$schema->storage->txn_begin();
-my $dbh = C4::Context->dbh;
-$dbh->{RaiseError} = 1;
-
-my @branches = Koha::Libraries->search();
-my $borrower = Koha::Patrons->search()->next();
+# add two branches and a borrower
+my $builder = t::lib::TestBuilder->new;
+my @branches;
+foreach( 1..2 ) {
+ push @branches, $builder->build({ source => 'Branch' });
+}
+my $borrower = $builder->build({ source => 'Borrower' });
my $biblio = MARC::Record->new();
my $title = 'Silence in the library';
{
biblionumber => $biblionumber,
biblioitemnumber => $biblioitemnumber,
- holdingbranch => $branches[0]->branchcode(),
- homebranch => $branches[0]->branchcode(),
+ holdingbranch => $branches[0]->{branchcode},
+ homebranch => $branches[0]->{branchcode},
}
);
$item->store();
biblionumber => $biblionumber,
itemnumber => $item->id(),
waitingdate => '2000-01-01',
- borrowernumber => $borrower->borrowernumber(),
- branchcode => $branches[1]->branchcode(),
+ borrowernumber => $borrower->{borrowernumber},
+ branchcode => $branches[1]->{branchcode},
suspend => 0,
}
);
my $hold_borrower = $hold->borrower();
ok( $hold_borrower, 'Got hold borrower' );
-is( $hold_borrower->borrowernumber(), $borrower->borrowernumber(), 'Hold borrower matches correct borrower' );
+is( $hold_borrower->borrowernumber(), $borrower->{borrowernumber}, 'Hold borrower matches correct borrower' );
t::lib::Mocks::mock_preference( 'ReservesMaxPickUpDelay', '' );
$dt = $hold->waiting_expires_on();
ok( !$hold->is_at_destination(), "In transit hold cannot be at destination" );
$hold->found('W');
ok( !$hold->is_at_destination(), "Waiting hold where hold branchcode is not the same as the item's holdingbranch is not at destination" );
-$item->holdingbranch( $branches[1]->branchcode() );
+$item->holdingbranch( $branches[1]->{branchcode} );
ok( $hold->is_at_destination(), "Waiting hold where hold branchcode is the same as the item's holdingbranch is at destination" );
$schema->storage->txn_rollback();