Lines 124-131
subtest 'add_credit() tests' => sub {
Link Here
|
124 |
$schema->storage->txn_begin; |
124 |
$schema->storage->txn_begin; |
125 |
|
125 |
|
126 |
# delete logs and statistics |
126 |
# delete logs and statistics |
127 |
$schema->resultset('ActionLog')->search()->delete(); |
127 |
my $action_logs = $schema->resultset('ActionLog')->search()->count; |
128 |
$schema->resultset('Statistic')->search()->delete(); |
128 |
my $statistics = $schema->resultset('Statistic')->search()->count; |
129 |
|
129 |
|
130 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
130 |
my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); |
131 |
my $account = Koha::Account->new( { patron_id => $patron->borrowernumber } ); |
131 |
my $account = Koha::Account->new( { patron_id => $patron->borrowernumber } ); |
Lines 146-153
subtest 'add_credit() tests' => sub {
Link Here
|
146 |
); |
146 |
); |
147 |
|
147 |
|
148 |
is( $account->balance, -25, 'Patron has a balance of -25' ); |
148 |
is( $account->balance, -25, 'Patron has a balance of -25' ); |
149 |
is( $schema->resultset('ActionLog')->count(), 0, 'No log was added' ); |
149 |
is( $schema->resultset('ActionLog')->count(), $action_logs + 0, 'No log was added' ); |
150 |
is( $schema->resultset('Statistic')->count(), 1, 'Action added to statistics' ); |
150 |
is( $schema->resultset('Statistic')->count(), $statistics + 1, 'Action added to statistics' ); |
151 |
is( $line_1->accounttype, $Koha::Account::account_type->{'payment'}, 'Account type is correctly set' ); |
151 |
is( $line_1->accounttype, $Koha::Account::account_type->{'payment'}, 'Account type is correctly set' ); |
152 |
|
152 |
|
153 |
# Enable logs |
153 |
# Enable logs |
Lines 165-172
subtest 'add_credit() tests' => sub {
Link Here
|
165 |
); |
165 |
); |
166 |
|
166 |
|
167 |
is( $account->balance, -62, 'Patron has a balance of -25' ); |
167 |
is( $account->balance, -62, 'Patron has a balance of -25' ); |
168 |
is( $schema->resultset('ActionLog')->count(), 1, 'Log was added' ); |
168 |
is( $schema->resultset('ActionLog')->count(), $action_logs + 1, 'Log was added' ); |
169 |
is( $schema->resultset('Statistic')->count(), 2, 'Action added to statistics' ); |
169 |
is( $schema->resultset('Statistic')->count(), $statistics + 2, 'Action added to statistics' ); |
170 |
is( $line_2->accounttype, $Koha::Account::account_type->{'payment'} . $sip_code, 'Account type is correctly set' ); |
170 |
is( $line_2->accounttype, $Koha::Account::account_type->{'payment'} . $sip_code, 'Account type is correctly set' ); |
171 |
|
171 |
|
172 |
# offsets have the credit_id set to accountlines_id, and debit_id is undef |
172 |
# offsets have the credit_id set to accountlines_id, and debit_id is undef |
Lines 187-194
subtest 'add_credit() tests' => sub {
Link Here
|
187 |
} |
187 |
} |
188 |
); |
188 |
); |
189 |
|
189 |
|
190 |
is( $schema->resultset('ActionLog')->count(), 2, 'Log was added' ); |
190 |
is( $schema->resultset('ActionLog')->count(), $action_logs + 2, 'Log was added' ); |
191 |
is( $schema->resultset('Statistic')->count(), 2, 'No action added to statistics, because of credit type' ); |
191 |
is( $schema->resultset('Statistic')->count(), $statistics + 2, 'No action added to statistics, because of credit type' ); |
192 |
|
192 |
|
193 |
$schema->storage->txn_rollback; |
193 |
$schema->storage->txn_rollback; |
194 |
}; |
194 |
}; |
195 |
- |
|
|