use Modern::Perl;
+use Data::Dumper; # REMOVEME with diag
use Test::More tests => 3;
use Test::MockModule;
+use Test::MockTime qw( set_fixed_time );
use t::lib::TestBuilder;
use C4::Biblio;
use Koha::DateUtils qw( dt_from_string output_pref );
use Koha::Library;
+use Koha::Patrons;
use DateTime::Duration;
use MARC::Record;
$dbh->do(q|DELETE FROM issues|);
$dbh->do(q|DELETE FROM borrowers|);
$dbh->do(q|DELETE FROM items|);
-$dbh->do(q|DELETE FROM branches|);
$dbh->do(q|DELETE FROM biblio|);
$dbh->do(q|DELETE FROM categories|);
$dbh->do(q|DELETE FROM letter|);
my $builder = t::lib::TestBuilder->new;
+set_fixed_time(CORE::time());
my $branchcode = $builder->build({ source => 'Branch' })->{ branchcode };
my $categorycode = $builder->build({ source => 'Category' })->{ categorycode };
AddItem( { barcode => $barcode2, %item_infos }, $biblionumber2 );
my $borrowernumber =
- AddMember( categorycode => $categorycode, branchcode => $branchcode );
-my $borrower = GetMember( borrowernumber => $borrowernumber );
+ Koha::Patron->new({ categorycode => $categorycode, branchcode => $branchcode })->store->borrowernumber;
+my $borrower = Koha::Patrons->find( $borrowernumber )->unblessed;
my $module = new Test::MockModule('C4::Context');
$module->mock( 'userenv', sub { { branch => $branchcode } } );
$issue_date = $yesterday_daily;
AddIssue( $borrower, $barcode2, $date_due, undef, $issue_date );
+ # Set timestamps to the same value to avoid a different order
+ Koha::Checkouts->search(
+ { borrowernumber => $borrower->{borrowernumber} }
+ )->update( { timestamp => dt_from_string } );
+
$expected_slip = <<EOS;
Checked out:
$issue_date = $yesterday->clone;
AddIssue( $borrower, $barcode2, $date_due_in_time, undef, $issue_date );
+ # Set timestamps to the same value to avoid a different order
+ Koha::Checkouts->search(
+ { borrowernumber => $borrower->{borrowernumber} }
+ )->update( { timestamp => dt_from_string } );
+
$expected_slip = <<EOS;
Checked out:
EOS
$slip = IssueSlip( $branchcode, $borrowernumber );
- is( $slip->{content}, $expected_slip, 'IssueSlip should return a slip with 2 checkouts' );
+ is( $slip->{content}, $expected_slip, 'IssueSlip should return a slip with 2 checkouts' )
+ or diag(Dumper(Koha::Checkouts->search({borrowernumber => $borrower->{borrowernumber}})->unblessed));
AddReturn( $barcode1, $branchcode );
AddReturn( $barcode2, $branchcode );
$schema->storage->txn_rollback;
-1;