Line 0
Link Here
|
0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
|
3 |
use Modern::Perl; |
4 |
|
5 |
use C4::Context; |
6 |
use C4::Acquisition; |
7 |
use C4::Bookseller qw/ AddBookseller /; |
8 |
|
9 |
use Test::More tests => 13; |
10 |
|
11 |
my $dbh = C4::Context->dbh; |
12 |
$dbh->{AutoCommit} = 0; |
13 |
$dbh->{RaiseError} = 1; |
14 |
|
15 |
my $booksellerid = AddBookseller({ |
16 |
name => "Bookseller test 1", |
17 |
currency => '', |
18 |
}); |
19 |
my $basketgroupid = NewBasketgroup({ |
20 |
booksellerid => $booksellerid, |
21 |
name => "Basketgroup test 1", |
22 |
}); |
23 |
|
24 |
my $basketgroup = GetBasketgroup($basketgroupid); |
25 |
ok(!$basketgroup->{closed}, "basket group is open"); |
26 |
ok(!defined($basketgroup->{closeddate}), "basket group closed date is empty"); |
27 |
|
28 |
CloseBasketgroup($basketgroupid); |
29 |
$basketgroup = GetBasketgroup($basketgroupid); |
30 |
ok($basketgroup->{closed}, "basket group is closed"); |
31 |
ok(defined($basketgroup->{closeddate}), "basket group closed date is not empty"); |
32 |
my ($day, $month, $year) = (localtime)[3,4,5]; |
33 |
ok($basketgroup->{closeddate} eq sprintf("%04d-%02d-%02d", $year+1900, $month+1, $day), "basket group closed date is correct"); |
34 |
|
35 |
ReOpenBasketgroup($basketgroupid); |
36 |
$basketgroup = GetBasketgroup($basketgroupid); |
37 |
ok(!$basketgroup->{closed}, "basket group is open"); |
38 |
ok(!defined($basketgroup->{closeddate}), "basket group closed date is empty"); |
39 |
|
40 |
$basketgroup->{closed} = 1; |
41 |
ModBasketgroup($basketgroup); |
42 |
$basketgroup = GetBasketgroup($basketgroupid); |
43 |
ok($basketgroup->{closed}, "basket group is closed"); |
44 |
ok(defined($basketgroup->{closeddate}), "basket group closed date is not empty"); |
45 |
ok($basketgroup->{closeddate} eq sprintf("%04d-%02d-%02d", $year+1900, $month+1, $day), "basket group closed date is correct"); |
46 |
|
47 |
$basketgroupid = NewBasketgroup({ |
48 |
booksellerid => $booksellerid, |
49 |
name => "Basketgroup test 1", |
50 |
closed => 1, |
51 |
}); |
52 |
$basketgroup = GetBasketgroup($basketgroupid); |
53 |
ok($basketgroup->{closed}, "basket group is closed"); |
54 |
ok(defined($basketgroup->{closeddate}), "basket group closed date is not empty"); |
55 |
ok($basketgroup->{closeddate} eq sprintf("%04d-%02d-%02d", $year+1900, $month+1, $day), "basket group closed date is correct"); |
56 |
|
57 |
$dbh->rollback; |