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

(-)a/Koha/Patron.pm (-3 / +3 lines)
Lines 209-223 sub update_password { Link Here
209
    return 1;
209
    return 1;
210
}
210
}
211
211
212
=head3 extend_subscription
212
=head3 renew_account
213
213
214
my $new_expiry_date = $patron->extend_subscription
214
my $new_expiry_date = $patron->renew_account
215
215
216
Extending the subscription to the expiry date.
216
Extending the subscription to the expiry date.
217
217
218
=cut
218
=cut
219
219
220
sub extend_subscription {
220
sub renew_account {
221
    my ($self) = @_;
221
    my ($self) = @_;
222
222
223
    my $date =
223
    my $date =
(-)a/members/setstatus.pl (-1 / +1 lines)
Lines 47-53 my $dateexpiry; Link Here
47
47
48
if ( $reregistration eq 'y' ) {
48
if ( $reregistration eq 'y' ) {
49
    # re-reregistration function to automatic calcul of date expiry
49
    # re-reregistration function to automatic calcul of date expiry
50
    $dateexpiry = Koha::Patrons->find( $borrowernumber )->extend_subscription;
50
    $dateexpiry = Koha::Patrons->find( $borrowernumber )->renew_account;
51
} else {
51
} else {
52
    my $sth = $dbh->prepare("UPDATE borrowers SET debarred = ?, debarredcomment = '' WHERE borrowernumber = ?");
52
    my $sth = $dbh->prepare("UPDATE borrowers SET debarred = ?, debarredcomment = '' WHERE borrowernumber = ?");
53
    $sth->execute( $status, $borrowernumber );
53
    $sth->execute( $status, $borrowernumber );
(-)a/t/db_dependent/Koha/Patrons.t (-6 / +5 lines)
Lines 129-135 subtest 'update_password' => sub { Link Here
129
    is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->update_password should not have logged' );
129
    is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->update_password should not have logged' );
130
};
130
};
131
131
132
subtest 'extend_subscription' => sub {
132
subtest 'renew_account' => sub {
133
    plan tests => 6;
133
    plan tests => 6;
134
    my $a_month_ago                = dt_from_string->add( months => -1 )->truncate( to => 'day' );
134
    my $a_month_ago                = dt_from_string->add( months => -1 )->truncate( to => 'day' );
135
    my $a_year_later               = dt_from_string->add( months => 12 )->truncate( to => 'day' );
135
    my $a_year_later               = dt_from_string->add( months => 12 )->truncate( to => 'day' );
Lines 154-174 subtest 'extend_subscription' => sub { Link Here
154
154
155
    t::lib::Mocks::mock_preference( 'BorrowerRenewalPeriodBase', 'dateexpiry' );
155
    t::lib::Mocks::mock_preference( 'BorrowerRenewalPeriodBase', 'dateexpiry' );
156
    t::lib::Mocks::mock_preference( 'BorrowersLog',              1 );
156
    t::lib::Mocks::mock_preference( 'BorrowersLog',              1 );
157
    my $expiry_date = $retrieved_patron->extend_subscription;
157
    my $expiry_date = $retrieved_patron->renew_account;
158
    is( $expiry_date, $a_year_later_minus_a_month, );
158
    is( $expiry_date, $a_year_later_minus_a_month, );
159
    my $retrieved_expiry_date = Koha::Patrons->find( $patron->{borrowernumber} )->dateexpiry;
159
    my $retrieved_expiry_date = Koha::Patrons->find( $patron->{borrowernumber} )->dateexpiry;
160
    is( dt_from_string($retrieved_expiry_date), $a_year_later_minus_a_month );
160
    is( dt_from_string($retrieved_expiry_date), $a_year_later_minus_a_month );
161
    my $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'RENEW', object => $retrieved_patron->borrowernumber } )->count;
161
    my $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'RENEW', object => $retrieved_patron->borrowernumber } )->count;
162
    is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->extend_subscription should have logged' );
162
    is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->renew_account should have logged' );
163
163
164
    t::lib::Mocks::mock_preference( 'BorrowerRenewalPeriodBase', 'now' );
164
    t::lib::Mocks::mock_preference( 'BorrowerRenewalPeriodBase', 'now' );
165
    t::lib::Mocks::mock_preference( 'BorrowersLog',              0 );
165
    t::lib::Mocks::mock_preference( 'BorrowersLog',              0 );
166
    $expiry_date = $retrieved_patron->extend_subscription;
166
    $expiry_date = $retrieved_patron->renew_account;
167
    is( $expiry_date, $a_year_later, );
167
    is( $expiry_date, $a_year_later, );
168
    $retrieved_expiry_date = Koha::Patrons->find( $patron->{borrowernumber} )->dateexpiry;
168
    $retrieved_expiry_date = Koha::Patrons->find( $patron->{borrowernumber} )->dateexpiry;
169
    is( dt_from_string($retrieved_expiry_date), $a_year_later );
169
    is( dt_from_string($retrieved_expiry_date), $a_year_later );
170
    $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'RENEW', object => $retrieved_patron->borrowernumber } )->count;
170
    $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'RENEW', object => $retrieved_patron->borrowernumber } )->count;
171
    is( $number_of_logs, 1, 'Without BorrowerLogs, Koha::Patron->extend_subscription should not have logged' );
171
    is( $number_of_logs, 1, 'Without BorrowerLogs, Koha::Patron->renew_account should not have logged' );
172
172
173
    $retrieved_patron->delete;
173
    $retrieved_patron->delete;
174
};
174
};
175
- 

Return to bug 16911