View | Details | Raw Unified | Return to bug 11708
Collapse All | Expand All

(-)t/db_dependent/Acquisition/Basketgroups.t (-1 / +57 lines)
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});
26
ok(!defined($basketgroup->{closeddate}));
27
28
CloseBasketgroup($basketgroupid);
29
$basketgroup = GetBasketgroup($basketgroupid);
30
ok($basketgroup->{closed});
31
ok(defined($basketgroup->{closeddate}));
32
my ($day, $month, $year) = (localtime)[3,4,5];
33
ok($basketgroup->{closeddate} eq sprintf("%04d-%02d-%02d", $year+1900, $month+1, $day));
34
35
ReOpenBasketgroup($basketgroupid);
36
$basketgroup = GetBasketgroup($basketgroupid);
37
ok(!$basketgroup->{closed});
38
ok(!defined($basketgroup->{closeddate}));
39
40
$basketgroup->{closed} = 1;
41
ModBasketgroup($basketgroup);
42
$basketgroup = GetBasketgroup($basketgroupid);
43
ok($basketgroup->{closed});
44
ok(defined($basketgroup->{closeddate}));
45
ok($basketgroup->{closeddate} eq sprintf("%04d-%02d-%02d", $year+1900, $month+1, $day));
46
47
$basketgroupid = NewBasketgroup({
48
    booksellerid => $booksellerid,
49
    name => "Basketgroup test 1",
50
    closed => 1,
51
});
52
$basketgroup = GetBasketgroup($basketgroupid);
53
ok($basketgroup->{closed});
54
ok(defined($basketgroup->{closeddate}));
55
ok($basketgroup->{closeddate} eq sprintf("%04d-%02d-%02d", $year+1900, $month+1, $day));
56
57
$dbh->rollback;

Return to bug 11708