From be3f0240ec8d8b7c140d468f8b791ba217516a93 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 2 Jan 2014 18:02:17 +0000 Subject: [PATCH] [PASSED QA] Bug 11470: fix occassional spurious test failure in Circulation_transfers.t This patch makes Circulation_transfers.t no longer be sensitive to the exact time it runs, avoiding spurious test failures due to datesent being a second off between the creation of the test transfer and the comparison. To test: [1] To simulate the failure, add a "sleep(2);" after the "#Test GetTransfers" comment and run prove -v t/db_dependent/Circulation_transfers.t [2] Remove the sleep and apply the patch. [3] Verify that prove -v t/db_dependent/Circulation_transfers.t passes. Signed-off-by: Galen Charlton Signed-off-by: Chris Cormack Signed-off-by: Katrin Fischer Works as described. --- t/db_dependent/Circulation_transfers.t | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/t/db_dependent/Circulation_transfers.t b/t/db_dependent/Circulation_transfers.t index 5328bde..25e720a 100644 --- a/t/db_dependent/Circulation_transfers.t +++ b/t/db_dependent/Circulation_transfers.t @@ -10,6 +10,7 @@ use Koha::DateUtils; use DateTime::Duration; use Test::More tests => 19; +use Test::Deep; BEGIN { use_ok('C4::Circulation'); @@ -140,13 +141,10 @@ is(CreateBranchTransferLimit(undef,$samplebranch2->{branchcode}),undef, #is(CreateBranchTransferLimit(-1,-1,'CODE'),0,"With wrong CreateBranchTransferLimit returns 0 - No transfertlimit added"); #Test GetTransfers -my $dt_today = dt_from_string( undef, 'sql', undef ); -my $today = $dt_today->strftime("%Y-%m-%d %H:%M:%S"); - my @transfers = GetTransfers($item_id1); -is_deeply( +cmp_deeply( \@transfers, - [ $today, $samplebranch1->{branchcode}, $samplebranch2->{branchcode} ], + [ re('^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$'), $samplebranch1->{branchcode}, $samplebranch2->{branchcode} ], "Transfers of the item1" ); #NOTE: Only the first transfer is returned @transfers = GetTransfers; @@ -159,17 +157,17 @@ is_deeply( \@transfers, [], #Test GetTransfersFromTo my @transferfrom1to2 = GetTransfersFromTo( $samplebranch1->{branchcode}, $samplebranch2->{branchcode} ); -is_deeply( +cmp_deeply( \@transferfrom1to2, [ { itemnumber => $item_id1, - datesent => $today, + datesent => re('^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$'), frombranch => $samplebranch1->{branchcode} }, { itemnumber => $item_id2, - datesent => $today, + datesent => re('^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$'), frombranch => $samplebranch1->{branchcode} } ], -- 1.8.3.2