Bug 10481: Unit tests for C4::Members::AddEnrolmentFeeIfNeeded
prove t/db_dependent/Members/AddEnrolmentFeeIfNeeded.t t/db_dependent/Members/AddEnrolmentFeeIfNeeded.t .. ok All tests successful. Files=1, Tests=3, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.38 cusr 0.01 csys = 0.41 CPU) Result: PASS Signed-off-by: Srdjan <srdjan@catalyst.net.nz> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
This commit is contained in:
parent
f8eb19163b
commit
1c8efaf3f9
1 changed files with 56 additions and 0 deletions
56
t/db_dependent/Members/AddEnrolmentFeeIfNeeded.t
Normal file
56
t/db_dependent/Members/AddEnrolmentFeeIfNeeded.t
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
use Modern::Perl;
|
||||||
|
use Test::More tests => 3;
|
||||||
|
|
||||||
|
use C4::Context;
|
||||||
|
use C4::Members;
|
||||||
|
|
||||||
|
my $dbh = C4::Context->dbh;
|
||||||
|
$dbh->{AutoCommit} = 0;
|
||||||
|
$dbh->{RaiseError} = 1;
|
||||||
|
|
||||||
|
my $enrolmentfee_K = 5;
|
||||||
|
my $enrolmentfee_J = 10;
|
||||||
|
my $enrolmentfee_YA = 20;
|
||||||
|
|
||||||
|
$dbh->do(q{
|
||||||
|
UPDATE categories
|
||||||
|
SET enrolmentfee=?
|
||||||
|
WHERE categorycode=?
|
||||||
|
}, {}, $enrolmentfee_K, 'K' );
|
||||||
|
|
||||||
|
$dbh->do(q{
|
||||||
|
UPDATE categories
|
||||||
|
SET enrolmentfee=?
|
||||||
|
WHERE categorycode=?
|
||||||
|
}, {}, $enrolmentfee_J, 'J' );
|
||||||
|
|
||||||
|
$dbh->do(q{
|
||||||
|
UPDATE categories
|
||||||
|
SET enrolmentfee=?
|
||||||
|
WHERE categorycode=?
|
||||||
|
}, {}, $enrolmentfee_YA, 'YA' );
|
||||||
|
|
||||||
|
my %borrower_data = (
|
||||||
|
firstname => 'my firstname',
|
||||||
|
surname => 'my surname',
|
||||||
|
categorycode => 'K',
|
||||||
|
branchcode => 'CPL',
|
||||||
|
);
|
||||||
|
|
||||||
|
my $borrowernumber = C4::Members::AddMember( %borrower_data );
|
||||||
|
$borrower_data{borrowernumber} = $borrowernumber;
|
||||||
|
|
||||||
|
my ( $total ) = C4::Members::GetMemberAccountRecords( $borrowernumber );
|
||||||
|
is( $total, $enrolmentfee_K, "New kid pay $enrolmentfee_K" );
|
||||||
|
|
||||||
|
$borrower_data{categorycode} = 'J';
|
||||||
|
C4::Members::ModMember( %borrower_data );
|
||||||
|
( $total ) = C4::Members::GetMemberAccountRecords( $borrowernumber );
|
||||||
|
is( $total, $enrolmentfee_K + $enrolmentfee_J, "Kid growing and become a juvenile, he should pay " . ( $enrolmentfee_K + $enrolmentfee_J ) );
|
||||||
|
|
||||||
|
# Check with calling directly AddEnrolmentFeeIfNeeded
|
||||||
|
C4::Members::AddEnrolmentFeeIfNeeded( 'YA', $borrowernumber );
|
||||||
|
( $total ) = C4::Members::GetMemberAccountRecords( $borrowernumber );
|
||||||
|
is( $total, $enrolmentfee_K + $enrolmentfee_J + $enrolmentfee_YA, "Juvenile growing and become an young adult, he should pay " . ( $enrolmentfee_K + $enrolmentfee_J + $enrolmentfee_YA ) );
|
||||||
|
|
||||||
|
$dbh->rollback;
|
Loading…
Reference in a new issue