From c1e8e913b196b85b21113879cbac8a789359fda4 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 --- 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 0000000..28196c6 --- /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}); +ok(!defined($basketgroup->{closeddate})); + +CloseBasketgroup($basketgroupid); +$basketgroup = GetBasketgroup($basketgroupid); +ok($basketgroup->{closed}); +ok(defined($basketgroup->{closeddate})); +my ($day, $month, $year) = (localtime)[3,4,5]; +ok($basketgroup->{closeddate} eq sprintf("%04d-%02d-%02d", $year+1900, $month+1, $day)); + +ReOpenBasketgroup($basketgroupid); +$basketgroup = GetBasketgroup($basketgroupid); +ok(!$basketgroup->{closed}); +ok(!defined($basketgroup->{closeddate})); + +$basketgroup->{closed} = 1; +ModBasketgroup($basketgroup); +$basketgroup = GetBasketgroup($basketgroupid); +ok($basketgroup->{closed}); +ok(defined($basketgroup->{closeddate})); +ok($basketgroup->{closeddate} eq sprintf("%04d-%02d-%02d", $year+1900, $month+1, $day)); + +$basketgroupid = NewBasketgroup({ + booksellerid => $booksellerid, + name => "Basketgroup test 1", + closed => 1, +}); +$basketgroup = GetBasketgroup($basketgroupid); +ok($basketgroup->{closed}); +ok(defined($basketgroup->{closeddate})); +ok($basketgroup->{closeddate} eq sprintf("%04d-%02d-%02d", $year+1900, $month+1, $day)); + +$dbh->rollback; -- 1.9.1