From 6bebfc60a733c3cd6c45ad5fb3d4bebbcfac5990 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Fri, 7 Feb 2014 11:29:58 +0100 Subject: [PATCH] Bug 11708: Unit tests for aqbasketgroups.closeddate Signed-off-by: juliette levast Signed-off-by: Paola Rossi --- t/db_dependent/Acquisition/Basketgroups.t | 57 +++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 t/db_dependent/Acquisition/Basketgroups.t diff --git a/t/db_dependent/Acquisition/Basketgroups.t b/t/db_dependent/Acquisition/Basketgroups.t new file mode 100755 index 0000000000..a17a295c00 --- /dev/null +++ b/t/db_dependent/Acquisition/Basketgroups.t @@ -0,0 +1,57 @@ +#!/usr/bin/perl + +use Modern::Perl; + +use C4::Context; +use C4::Acquisition; +use C4::Bookseller qw/ AddBookseller /; + +use Test::More tests => 13; + +my $dbh = C4::Context->dbh; +$dbh->{AutoCommit} = 0; +$dbh->{RaiseError} = 1; + +my $booksellerid = AddBookseller({ + name => "Bookseller test 1", + currency => '', +}); +my $basketgroupid = NewBasketgroup({ + booksellerid => $booksellerid, + name => "Basketgroup test 1", +}); + +my $basketgroup = GetBasketgroup($basketgroupid); +ok(!$basketgroup->{closed}, "basket group is open"); +ok(!defined($basketgroup->{closeddate}), "basket group closed date is empty"); + +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]; +ok($basketgroup->{closeddate} eq sprintf("%04d-%02d-%02d", $year+1900, $month+1, $day), "basket group closed date is correct"); + +ReOpenBasketgroup($basketgroupid); +$basketgroup = GetBasketgroup($basketgroupid); +ok(!$basketgroup->{closed}, "basket group is open"); +ok(!defined($basketgroup->{closeddate}), "basket group closed date is empty"); + +$basketgroup->{closed} = 1; +ModBasketgroup($basketgroup); +$basketgroup = GetBasketgroup($basketgroupid); +ok($basketgroup->{closed}, "basket group is closed"); +ok(defined($basketgroup->{closeddate}), "basket group closed date is not empty"); +ok($basketgroup->{closeddate} eq sprintf("%04d-%02d-%02d", $year+1900, $month+1, $day), "basket group closed date is correct"); + +$basketgroupid = NewBasketgroup({ + booksellerid => $booksellerid, + name => "Basketgroup test 1", + closed => 1, +}); +$basketgroup = GetBasketgroup($basketgroupid); +ok($basketgroup->{closed}, "basket group is closed"); +ok(defined($basketgroup->{closeddate}), "basket group closed date is not empty"); +ok($basketgroup->{closeddate} eq sprintf("%04d-%02d-%02d", $year+1900, $month+1, $day), "basket group closed date is correct"); + +$dbh->rollback; -- 2.14.2