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

(-)a/t/db_dependent/Circulation.t (-50 / +47 lines)
Lines 48-53 use Koha::Account::Lines; Link Here
48
use Koha::Account::Offsets;
48
use Koha::Account::Offsets;
49
use Koha::ActionLogs;
49
use Koha::ActionLogs;
50
50
51
sub set_userenv {
52
    my ( $library ) = @_;
53
    t::lib::Mocks::mock_userenv({ branchcode => $library->{branchcode} });
54
}
55
56
sub str {
57
    my ( $error, $question, $alert ) = @_;
58
    my $s;
59
    $s  = %$error    ? ' (error: '    . join( ' ', keys %$error    ) . ')' : '';
60
    $s .= %$question ? ' (question: ' . join( ' ', keys %$question ) . ')' : '';
61
    $s .= %$alert    ? ' (alert: '    . join( ' ', keys %$alert    ) . ')' : '';
62
    return $s;
63
}
64
65
sub test_debarment_on_checkout {
66
    my ($params) = @_;
67
    my $item     = $params->{item};
68
    my $library  = $params->{library};
69
    my $patron   = $params->{patron};
70
    my $due_date = $params->{due_date} || dt_from_string;
71
    my $return_date = $params->{return_date} || dt_from_string;
72
    my $expected_expiration_date = $params->{expiration_date};
73
74
    $expected_expiration_date = output_pref(
75
        {
76
            dt         => $expected_expiration_date,
77
            dateformat => 'sql',
78
            dateonly   => 1,
79
        }
80
    );
81
    my @caller      = caller;
82
    my $line_number = $caller[2];
83
    AddIssue( $patron, $item->{barcode}, $due_date );
84
85
    my ( undef, $message ) = AddReturn( $item->{barcode}, $library->{branchcode}, undef, $return_date );
86
    is( $message->{WasReturned} && exists $message->{Debarred}, 1, 'AddReturn must have debarred the patron' )
87
        or diag('AddReturn returned message ' . Dumper $message );
88
    my $debarments = Koha::Patron::Debarments::GetDebarments(
89
        { borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } );
90
    is( scalar(@$debarments), 1, 'Test at line ' . $line_number );
91
92
    is( $debarments->[0]->{expiration},
93
        $expected_expiration_date, 'Test at line ' . $line_number );
94
    Koha::Patron::Debarments::DelUniqueDebarment(
95
        { borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } );
96
};
97
51
my $schema = Koha::Database->schema;
98
my $schema = Koha::Database->schema;
52
$schema->storage->txn_begin;
99
$schema->storage->txn_begin;
53
my $builder = t::lib::TestBuilder->new;
100
my $builder = t::lib::TestBuilder->new;
Lines 3112-3166 subtest 'ProcessOfflinePayment() tests' => sub { Link Here
3112
    $schema->storage->txn_rollback;
3159
    $schema->storage->txn_rollback;
3113
};
3160
};
3114
3161
3115
3116
3117
sub set_userenv {
3118
    my ( $library ) = @_;
3119
    t::lib::Mocks::mock_userenv({ branchcode => $library->{branchcode} });
3120
}
3121
3122
sub str {
3123
    my ( $error, $question, $alert ) = @_;
3124
    my $s;
3125
    $s  = %$error    ? ' (error: '    . join( ' ', keys %$error    ) . ')' : '';
3126
    $s .= %$question ? ' (question: ' . join( ' ', keys %$question ) . ')' : '';
3127
    $s .= %$alert    ? ' (alert: '    . join( ' ', keys %$alert    ) . ')' : '';
3128
    return $s;
3129
}
3130
3131
sub test_debarment_on_checkout {
3132
    my ($params) = @_;
3133
    my $item     = $params->{item};
3134
    my $library  = $params->{library};
3135
    my $patron   = $params->{patron};
3136
    my $due_date = $params->{due_date} || dt_from_string;
3137
    my $return_date = $params->{return_date} || dt_from_string;
3138
    my $expected_expiration_date = $params->{expiration_date};
3139
3140
    $expected_expiration_date = output_pref(
3141
        {
3142
            dt         => $expected_expiration_date,
3143
            dateformat => 'sql',
3144
            dateonly   => 1,
3145
        }
3146
    );
3147
    my @caller      = caller;
3148
    my $line_number = $caller[2];
3149
    AddIssue( $patron, $item->{barcode}, $due_date );
3150
3151
    my ( undef, $message ) = AddReturn( $item->{barcode}, $library->{branchcode}, undef, $return_date );
3152
    is( $message->{WasReturned} && exists $message->{Debarred}, 1, 'AddReturn must have debarred the patron' )
3153
        or diag('AddReturn returned message ' . Dumper $message );
3154
    my $debarments = Koha::Patron::Debarments::GetDebarments(
3155
        { borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } );
3156
    is( scalar(@$debarments), 1, 'Test at line ' . $line_number );
3157
3158
    is( $debarments->[0]->{expiration},
3159
        $expected_expiration_date, 'Test at line ' . $line_number );
3160
    Koha::Patron::Debarments::DelUniqueDebarment(
3161
        { borrowernumber => $patron->{borrowernumber}, type => 'SUSPENSION' } );
3162
};
3163
3164
subtest 'Incremented fee tests' => sub {
3162
subtest 'Incremented fee tests' => sub {
3165
    plan tests => 11;
3163
    plan tests => 11;
3166
3164
3167
- 

Return to bug 23177