my $sth = $dbh->prepare("INSERT INTO transport_cost (frombranch, tobranch, cost, disable_transfer) VALUES (?, ?, ?, ?)");
- $dbh->do("TRUNCATE TABLE transport_cost");
+ $dbh->do("DELETE FROM transport_cost");
foreach (@$records) {
my $cost = $_->{cost};
my $from = $_->{frombranch};
$cost ||= 0;
}
elsif ( !defined ($cost) || ($cost !~ m/(0|[1-9][0-9]*)(\.[0-9]*)?/o) ) {
- warn "Invalid $from -> $to cost $cost - must be a number >= 0, disablig";
+ warn "Invalid $from -> $to cost $cost - must be a number >= 0, disabling";
$cost = 0;
$_->{disable_transfer} = 1;
}
use Modern::Perl;
-use Test::More tests => 43;
+use Test::More tests => 44;
use Data::Dumper;
use C4::Calendar;
my $queue_rs = $schema->resultset('TmpHoldsqueue');
is( $queue_rs->count(), 1, "Hold queue contains one hold from chosen from three possible items" );
+subtest 'Trivial test for UpdateTransportCostMatrix' => sub {
+ plan tests => 1;
+ my $recs = [
+ { frombranch => $library1->{branchcode}, tobranch => $library2->{branchcode}, cost => 1, disable_transfer => 0 },
+ { frombranch => $library2->{branchcode}, tobranch => $library3->{branchcode}, cost => 0, disable_transfer => 1 },
+ ];
+ C4::HoldsQueue::UpdateTransportCostMatrix( $recs );
+ is( $schema->resultset('TransportCost')->count, 2, 'UpdateTransportCostMatrix added two records' );
+};
+
# Cleanup
$schema->storage->txn_rollback;