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

(-)a/t/db_dependent/Circulation/GetIssues.t (-27 / +10 lines)
Lines 12-17 use C4::Category; Link Here
12
use C4::Circulation;
12
use C4::Circulation;
13
use MARC::Record;
13
use MARC::Record;
14
14
15
my $dbh = C4::Context->dbh;
16
$dbh->{AutoCommit} = 0;
17
$dbh->{RaiseError} = 1;
18
15
my $branchcode;
19
my $branchcode;
16
my $branch_created;
20
my $branch_created;
17
my @branches = keys %{ GetBranches() };
21
my @branches = keys %{ GetBranches() };
Lines 58-101 AddIssue($borrower, '0203'); Link Here
58
62
59
# Begin tests...
63
# Begin tests...
60
my $issues;
64
my $issues;
61
$issues = GetIssues({biblionumber => $biblionumber1});
65
$issues = C4::Circulation::GetIssues({biblionumber => $biblionumber1});
62
is(scalar @$issues, 1, "Biblio $biblionumber1 has 1 item issued");
66
is(scalar @$issues, 1, "Biblio $biblionumber1 has 1 item issued");
63
is($issues->[0]->{itemnumber}, $itemnumber1, "First item of biblio $biblionumber1 is issued");
67
is($issues->[0]->{itemnumber}, $itemnumber1, "First item of biblio $biblionumber1 is issued");
64
68
65
$issues = GetIssues({biblionumber => $biblionumber2});
69
$issues = C4::Circulation::GetIssues({biblionumber => $biblionumber2});
66
is(scalar @$issues, 1, "Biblio $biblionumber2 has 1 item issued");
70
is(scalar @$issues, 1, "Biblio $biblionumber2 has 1 item issued");
67
is($issues->[0]->{itemnumber}, $itemnumber3, "First item of biblio $biblionumber2 is issued");
71
is($issues->[0]->{itemnumber}, $itemnumber3, "First item of biblio $biblionumber2 is issued");
68
72
69
$issues = GetIssues({borrowernumber => $borrowernumber});
73
$issues = C4::Circulation::GetIssues({borrowernumber => $borrowernumber});
70
is(scalar @$issues, 2, "Borrower $borrowernumber checked out 2 items");
74
is(scalar @$issues, 2, "Borrower $borrowernumber checked out 2 items");
71
75
72
$issues = GetIssues({borrowernumber => $borrowernumber, biblionumber => $biblionumber1});
76
$issues = C4::Circulation::GetIssues({borrowernumber => $borrowernumber, biblionumber => $biblionumber1});
73
is(scalar @$issues, 1, "One of those is an item from biblio $biblionumber1");
77
is(scalar @$issues, 1, "One of those is an item from biblio $biblionumber1");
74
78
75
$issues = GetIssues({borrowernumber => $borrowernumber, biblionumber => $biblionumber2});
79
$issues = C4::Circulation::GetIssues({borrowernumber => $borrowernumber, biblionumber => $biblionumber2});
76
is(scalar @$issues, 1, "The other is an item from biblio $biblionumber2");
80
is(scalar @$issues, 1, "The other is an item from biblio $biblionumber2");
77
81
78
$issues = GetIssues({itemnumber => $itemnumber2});
82
$issues = C4::Circulation::GetIssues({itemnumber => $itemnumber2});
79
is(scalar @$issues, 0, "No one has issued the second item of biblio $biblionumber2");
83
is(scalar @$issues, 0, "No one has issued the second item of biblio $biblionumber2");
80
84
81
END {
82
    AddReturn('0101', $branchcode);
83
    AddReturn('0203', $branchcode);
84
    DelMember($borrowernumber);
85
    if ($category_created) {
86
        C4::Context->dbh->do(
87
            "DELETE FROM categories WHERE categorycode = ?", undef, $categorycode);
88
    }
89
    my $dbh = C4::Context->dbh;
90
    C4::Items::DelItem($dbh, $biblionumber1, $itemnumber1);
91
    C4::Items::DelItem($dbh, $biblionumber1, $itemnumber2);
92
    C4::Items::DelItem($dbh, $biblionumber2, $itemnumber3);
93
    C4::Biblio::DelBiblio($biblionumber1);
94
    C4::Biblio::DelBiblio($biblionumber2);
95
96
    if ($branch_created) {
97
        DelBranch($branchcode);
98
    }
99
};
100
101
done_testing;
85
done_testing;
102
- 

Return to bug 10859