Lines 103-109
subtest 'siblings' => sub {
Link Here
|
103 |
$retrieved_guarantee_1->delete; |
103 |
$retrieved_guarantee_1->delete; |
104 |
}; |
104 |
}; |
105 |
|
105 |
|
106 |
subtest 'extend_subscription' => sub { |
106 |
subtest 'renew_account' => sub { |
107 |
plan tests => 6; |
107 |
plan tests => 6; |
108 |
my $a_month_ago = dt_from_string->add( months => -1 )->truncate( to => 'day' ); |
108 |
my $a_month_ago = dt_from_string->add( months => -1 )->truncate( to => 'day' ); |
109 |
my $a_year_later = dt_from_string->add( months => 12 )->truncate( to => 'day' ); |
109 |
my $a_year_later = dt_from_string->add( months => 12 )->truncate( to => 'day' ); |
Lines 128-148
subtest 'extend_subscription' => sub {
Link Here
|
128 |
|
128 |
|
129 |
t::lib::Mocks::mock_preference( 'BorrowerRenewalPeriodBase', 'dateexpiry' ); |
129 |
t::lib::Mocks::mock_preference( 'BorrowerRenewalPeriodBase', 'dateexpiry' ); |
130 |
t::lib::Mocks::mock_preference( 'BorrowersLog', 1 ); |
130 |
t::lib::Mocks::mock_preference( 'BorrowersLog', 1 ); |
131 |
my $expiry_date = $retrieved_patron->extend_subscription; |
131 |
my $expiry_date = $retrieved_patron->renew_account; |
132 |
is( $expiry_date, $a_year_later_minus_a_month, ); |
132 |
is( $expiry_date, $a_year_later_minus_a_month, ); |
133 |
my $retrieved_expiry_date = Koha::Patrons->find( $patron->{borrowernumber} )->dateexpiry; |
133 |
my $retrieved_expiry_date = Koha::Patrons->find( $patron->{borrowernumber} )->dateexpiry; |
134 |
is( dt_from_string($retrieved_expiry_date), $a_year_later_minus_a_month ); |
134 |
is( dt_from_string($retrieved_expiry_date), $a_year_later_minus_a_month ); |
135 |
my $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'RENEW', object => $retrieved_patron->borrowernumber } )->count; |
135 |
my $number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'RENEW', object => $retrieved_patron->borrowernumber } )->count; |
136 |
is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->extend_subscription should have logged' ); |
136 |
is( $number_of_logs, 1, 'With BorrowerLogs, Koha::Patron->renew_account should have logged' ); |
137 |
|
137 |
|
138 |
t::lib::Mocks::mock_preference( 'BorrowerRenewalPeriodBase', 'now' ); |
138 |
t::lib::Mocks::mock_preference( 'BorrowerRenewalPeriodBase', 'now' ); |
139 |
t::lib::Mocks::mock_preference( 'BorrowersLog', 0 ); |
139 |
t::lib::Mocks::mock_preference( 'BorrowersLog', 0 ); |
140 |
$expiry_date = $retrieved_patron->extend_subscription; |
140 |
$expiry_date = $retrieved_patron->renew_account; |
141 |
is( $expiry_date, $a_year_later, ); |
141 |
is( $expiry_date, $a_year_later, ); |
142 |
$retrieved_expiry_date = Koha::Patrons->find( $patron->{borrowernumber} )->dateexpiry; |
142 |
$retrieved_expiry_date = Koha::Patrons->find( $patron->{borrowernumber} )->dateexpiry; |
143 |
is( dt_from_string($retrieved_expiry_date), $a_year_later ); |
143 |
is( dt_from_string($retrieved_expiry_date), $a_year_later ); |
144 |
$number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'RENEW', object => $retrieved_patron->borrowernumber } )->count; |
144 |
$number_of_logs = $schema->resultset('ActionLog')->search( { module => 'MEMBERS', action => 'RENEW', object => $retrieved_patron->borrowernumber } )->count; |
145 |
is( $number_of_logs, 1, 'Without BorrowerLogs, Koha::Patron->extend_subscription should not have logged' ); |
145 |
is( $number_of_logs, 1, 'Without BorrowerLogs, Koha::Patron->renew_account should not have logged' ); |
146 |
|
146 |
|
147 |
$retrieved_patron->delete; |
147 |
$retrieved_patron->delete; |
148 |
}; |
148 |
}; |
149 |
- |
|
|