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

(-)a/t/db_dependent/Koha/Patrons.t (-2 / +34 lines)
Lines 166-175 subtest 'update_password' => sub { Link Here
166
};
166
};
167
167
168
subtest 'renew_account' => sub {
168
subtest 'renew_account' => sub {
169
    plan tests => 6;
169
    plan tests => 10;
170
    my $a_month_ago                = dt_from_string->add( months => -1 )->truncate( to => 'day' );
170
    my $a_month_ago                = dt_from_string->add( months => -1 )->truncate( to => 'day' );
171
    my $a_year_later               = dt_from_string->add( months => 12 )->truncate( to => 'day' );
171
    my $a_year_later               = dt_from_string->add( months => 12 )->truncate( to => 'day' );
172
    my $a_year_later_minus_a_month = dt_from_string->add( months => 11 )->truncate( to => 'day' );
172
    my $a_year_later_minus_a_month = dt_from_string->add( months => 11 )->truncate( to => 'day' );
173
    my $a_month_later              = dt_from_string->add( months => 1  )->truncate( to => 'day' );
174
    my $a_year_later_plus_a_month  = dt_from_string->add( months => 13 )->truncate( to => 'day' );
173
    my $patron_category = $builder->build(
175
    my $patron_category = $builder->build(
174
        {   source => 'Category',
176
        {   source => 'Category',
175
            value  => {
177
            value  => {
Lines 186-192 subtest 'renew_account' => sub { Link Here
186
            }
188
            }
187
        }
189
        }
188
    );
190
    );
191
    my $patron_2 = $builder->build(
192
        {  source => 'Borrower',
193
           value  => {
194
               dateexpiry => $a_month_ago,
195
               categorycode => $patron_category->{categorycode},
196
            }
197
        }
198
    );
199
    my $patron_3 = $builder->build(
200
        {  source => 'Borrower',
201
           value  => {
202
               dateexpiry => $a_month_later,
203
               categorycode => $patron_category->{categorycode},
204
           }
205
        }
206
    );
189
    my $retrieved_patron = Koha::Patrons->find( $patron->{borrowernumber} );
207
    my $retrieved_patron = Koha::Patrons->find( $patron->{borrowernumber} );
208
    my $retrieved_patron_2 = Koha::Patrons->find( $patron_2->{borrowernumber} );
209
    my $retrieved_patron_3 = Koha::Patrons->find( $patron_3->{borrowernumber} );
190
210
191
    t::lib::Mocks::mock_preference( 'BorrowerRenewalPeriodBase', 'dateexpiry' );
211
    t::lib::Mocks::mock_preference( 'BorrowerRenewalPeriodBase', 'dateexpiry' );
192
    t::lib::Mocks::mock_preference( 'BorrowersLog',              1 );
212
    t::lib::Mocks::mock_preference( 'BorrowersLog',              1 );
Lines 206-212 subtest 'renew_account' => sub { Link Here
206
    $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'RENEW', object => $retrieved_patron->borrowernumber } )->count;
226
    $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'RENEW', object => $retrieved_patron->borrowernumber } )->count;
207
    is( $number_of_logs, 1, 'Without BorrowerLogs, Koha::Patron->renew_account should not have logged' );
227
    is( $number_of_logs, 1, 'Without BorrowerLogs, Koha::Patron->renew_account should not have logged' );
208
228
229
    t::lib::Mocks::mock_preference( 'BorrowerRenewalPeriodBase', 'combination' );
230
    $expiry_date = $retrieved_patron_2->renew_account;
231
    is( $expiry_date, $a_year_later );
232
    $retrieved_expiry_date = Koha::Patrons->find( $patron_2->{borrowernumber} )->dateexpiry;
233
    is( dt_from_string($retrieved_expiry_date), $a_year_later );
234
235
    $expiry_date = $retrieved_patron_3->renew_account;
236
    is( $expiry_date, $a_year_later_plus_a_month );
237
    $retrieved_expiry_date = Koha::Patrons->find( $patron_3->{borrowernumber} )->dateexpiry;
238
    is( dt_from_string($retrieved_expiry_date), $a_year_later_plus_a_month );
239
209
    $retrieved_patron->delete;
240
    $retrieved_patron->delete;
241
    $retrieved_patron_2->delete;
242
    $retrieved_patron_3->delete;
210
};
243
};
211
244
212
subtest "move_to_deleted" => sub {
245
subtest "move_to_deleted" => sub {
213
- 

Return to bug 17443