From 89dea9d85958302d596e39b2b12b578e784a1e26 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Wed, 7 Sep 2016 11:57:39 +0200 Subject: [PATCH] Bug 11708: UT: Use DateTime instead of localtime+sprintf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Séverine QUEUNE --- t/db_dependent/Acquisition/Basketgroups.t | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/t/db_dependent/Acquisition/Basketgroups.t b/t/db_dependent/Acquisition/Basketgroups.t index fdd3b0fc78..c494019500 100755 --- a/t/db_dependent/Acquisition/Basketgroups.t +++ b/t/db_dependent/Acquisition/Basketgroups.t @@ -2,6 +2,8 @@ use Modern::Perl; +use DateTime; + use C4::Context; use C4::Acquisition; use C4::Bookseller qw/ AddBookseller /; @@ -29,8 +31,8 @@ CloseBasketgroup($basketgroupid); $basketgroup = GetBasketgroup($basketgroupid); ok($basketgroup->{closed}, "basket group is closed"); ok(defined($basketgroup->{closeddate}), "basket group closed date is not empty"); -my ($day, $month, $year) = (localtime)[3,4,5]; -is($basketgroup->{closeddate}, sprintf("%04d-%02d-%02d", $year+1900, $month+1, $day), "basket group closed date is correct"); +my $today = DateTime->now(time_zone => C4::Context->tz); +is($basketgroup->{closeddate}, $today->ymd, "basket group closed date is correct"); ReOpenBasketgroup($basketgroupid); $basketgroup = GetBasketgroup($basketgroupid); @@ -42,7 +44,7 @@ ModBasketgroup($basketgroup); $basketgroup = GetBasketgroup($basketgroupid); ok($basketgroup->{closed}, "basket group is closed"); ok(defined($basketgroup->{closeddate}), "basket group closed date is not empty"); -is($basketgroup->{closeddate}, sprintf("%04d-%02d-%02d", $year+1900, $month+1, $day), "basket group closed date is correct"); +is($basketgroup->{closeddate}, $today->ymd, "basket group closed date is correct"); $basketgroupid = NewBasketgroup({ booksellerid => $booksellerid, @@ -52,6 +54,6 @@ $basketgroupid = NewBasketgroup({ $basketgroup = GetBasketgroup($basketgroupid); ok($basketgroup->{closed}, "basket group is closed"); ok(defined($basketgroup->{closeddate}), "basket group closed date is not empty"); -is($basketgroup->{closeddate}, sprintf("%04d-%02d-%02d", $year+1900, $month+1, $day), "basket group closed date is correct"); +is($basketgroup->{closeddate}, $today->ymd, "basket group closed date is correct"); $dbh->rollback; -- 2.14.2