Bugzilla – Attachment 53342 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), 5.92 KB, created by
Jonathan Druart
on 2016-07-12 19:08:01 UTC
(
hide
)
Description:
Bug 16912: Koha::Patrons - Move and rewrite tests for AddEnrolmentFeeIfNeeded
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-07-12 19:08:01 UTC
Size:
5.92 KB
patch
obsolete
>From 433acd7bcaf0efe72b89479e057e75a1ad9aae2c 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 > >--- > t/db_dependent/Koha/Patrons.t | 54 ++++++++++++++++- > t/db_dependent/Members/AddEnrolmentFeeIfNeeded.t | 74 ------------------------ > 2 files changed, 53 insertions(+), 75 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 644f22e..a0b43fb 100644 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 6; >+use Test::More tests => 7; > > use C4::Members; > >@@ -147,6 +147,58 @@ subtest 'extend_subscription' => 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.8.1
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