Bugzilla – Attachment 56527 Details for
Bug 16912
Koha::Patrons - Move AddEnrolmentFeeIfNeeded to add_enrolment_fee_if_needed
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16912: Koha::Patrons - Move and rewrite tests for AddEnrolmentFeeIfNeeded
Bug-16912-KohaPatrons---Move-and-rewrite-tests-for.patch (text/plain), 6.12 KB, created by
Nick Clemens (kidclamp)
on 2016-10-14 13:12:21 UTC
(
hide
)
Description:
Bug 16912: Koha::Patrons - Move and rewrite tests for AddEnrolmentFeeIfNeeded
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2016-10-14 13:12:21 UTC
Size:
6.12 KB
patch
obsolete
>From 60fa45ca45babbd4cf61a20b83de70b8a093d10d Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 12 Jul 2016 08:31:01 +0100 >Subject: [PATCH] Bug 16912: Koha::Patrons - Move and rewrite tests for > AddEnrolmentFeeIfNeeded > >Signed-off-by: Aleisha Amohia <aleishaamohia@hotmail.com> > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > t/db_dependent/Koha/Patrons.t | 57 +++++++++++++++++- > t/db_dependent/Members/AddEnrolmentFeeIfNeeded.t | 74 ------------------------ > 2 files changed, 55 insertions(+), 76 deletions(-) > delete mode 100644 t/db_dependent/Members/AddEnrolmentFeeIfNeeded.t > >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index f18e207..899a1d6 100644 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -19,10 +19,11 @@ > > use Modern::Perl; > >-use Test::More tests => 8; >+use Test::More tests => 9; > use Test::Warn; > >-use C4::Circulation; >+use C4::Members; >+ > use Koha::Patron; > use Koha::Patrons; > use Koha::Database; >@@ -207,6 +208,58 @@ subtest 'renew_account' => sub { > $retrieved_patron->delete; > }; > >+subtest 'add_enrolment_fee_if_needed' => sub { >+ plan tests => 4; >+ >+ my $enrolmentfee_K = 5; >+ my $enrolmentfee_J = 10; >+ my $enrolmentfee_YA = 20; >+ >+ $builder->build( { source => 'Category', value => { categorycode => 'K', enrolmentfee => $enrolmentfee_K } } ); >+ $builder->build( { source => 'Category', value => { categorycode => 'J', enrolmentfee => $enrolmentfee_J } } ); >+ $builder->build( { source => 'Category', value => { categorycode => 'YA', enrolmentfee => $enrolmentfee_YA } } ); >+ >+ my %borrower_data = ( >+ firstname => 'my firstname', >+ surname => 'my surname', >+ categorycode => 'K', >+ branchcode => $library->{branchcode}, >+ ); >+ >+ 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" ); >+ >+ t::lib::Mocks::mock_preference( 'FeeOnChangePatronCategory', 0 ); >+ $borrower_data{categorycode} = 'J'; >+ C4::Members::ModMember(%borrower_data); >+ ($total) = C4::Members::GetMemberAccountRecords($borrowernumber); >+ is( $total, $enrolmentfee_K, "Kid growing and become a juvenile, but shouldn't pay for the upgrade " ); >+ >+ $borrower_data{categorycode} = 'K'; >+ C4::Members::ModMember(%borrower_data); >+ t::lib::Mocks::mock_preference( 'FeeOnChangePatronCategory', 1 ); >+ >+ $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 Koha::Patron->get_enrolment_fee_if_needed >+ my $patron = Koha::Patrons->find($borrowernumber); >+ $patron->categorycode('YA')->store; >+ my $fee = $patron->add_enrolment_fee_if_needed; >+ ($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 ) >+ ); >+ >+ $patron->delete; >+}; >+ > $retrieved_patron_1->delete; > is( Koha::Patrons->search->count, $nb_of_patrons + 1, 'Delete should have deleted the patron' ); > >diff --git a/t/db_dependent/Members/AddEnrolmentFeeIfNeeded.t b/t/db_dependent/Members/AddEnrolmentFeeIfNeeded.t >deleted file mode 100644 >index cc0a22c..0000000 >--- a/t/db_dependent/Members/AddEnrolmentFeeIfNeeded.t >+++ /dev/null >@@ -1,74 +0,0 @@ >-use Modern::Perl; >-use Test::More tests => 4; >- >-use C4::Context; >-use C4::Members; >-use Koha::Database; >- >-use t::lib::Mocks; >-use t::lib::TestBuilder; >- >-my $schema = Koha::Database->schema; >-$schema->storage->txn_begin; >-my $builder = t::lib::TestBuilder->new; >-my $dbh = C4::Context->dbh; >-$dbh->{RaiseError} = 1; >- >-my $library = $builder->build({ >- source => 'Branch', >-}); >- >-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 => $library->{branchcode}, >-); >- >-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" ); >- >-t::lib::Mocks::mock_preference( 'FeeOnChangePatronCategory', 0 ); >-$borrower_data{categorycode} = 'J'; >-C4::Members::ModMember( %borrower_data ); >-( $total ) = C4::Members::GetMemberAccountRecords( $borrowernumber ); >-is( $total, $enrolmentfee_K , "Kid growing and become a juvenile, but shouldn't pay for the upgrade "); >- >-$borrower_data{categorycode} = 'K'; >-C4::Members::ModMember( %borrower_data ); >-t::lib::Mocks::mock_preference( 'FeeOnChangePatronCategory', 1 ); >- >-$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 ) ); >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 16912
:
53342
|
53343
|
53519
|
53520
|
54798
|
54804
|
54836
|
54837
|
54838
|
56493
|
56494
|
56495
|
56526
|
56527
|
56528
|
56771
|
56772
|
56773