Bugzilla – Attachment 44570 Details for
Bug 15151
t/Circulation_barcodedecode.t fails if no DB present
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15151: (counter patch) Avoid DB access to load C4::Members
Bug-15151-counter-patch-Avoid-DB-access-to-load-C4.patch (text/plain), 4.78 KB, created by
Tomás Cohen Arazi (tcohen)
on 2015-11-06 14:40:51 UTC
(
hide
)
Description:
Bug 15151: (counter patch) Avoid DB access to load C4::Members
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2015-11-06 14:40:51 UTC
Size:
4.78 KB
patch
obsolete
>From 126d8a13a32227bae61b03005b200b8e0d6b152f Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 6 Nov 2015 11:21:56 -0300 >Subject: [PATCH] Bug 15151: (counter patch) Avoid DB access to load > C4::Members > >In order to avoid loading Koha::NorwegianPatronDB a DB query was >used. Instead, a require should be used. This causes non-db_dependent >tests that load C4::Members to fail. > >To test: >- Shut mysql down > $ sudo service mysql stop >- Run the tests: > prove t/Circulation_barcodedecode.t >=> FAIL: DB connection is expected, tests fail >- Apply the patch >- Run the tests: > prove t/Circulation_barcodedecode.t >=> SUCCESS: Tests pass >- Sign off .-D >--- > C4/Members.pm | 11 ++++------- > t/Circulation_barcodedecode.t | 33 ++++++++++++--------------------- > 2 files changed, 16 insertions(+), 28 deletions(-) > >diff --git a/C4/Members.pm b/C4/Members.pm >index 171f3c0..9166b75 100644 >--- a/C4/Members.pm >+++ b/C4/Members.pm >@@ -41,10 +41,7 @@ use Koha::Borrower::Debarments qw(IsDebarred); > use Text::Unaccent qw( unac_string ); > use Koha::AuthUtils qw(hash_password); > use Koha::Database; >-use Module::Load; >-if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) { >- load Koha::NorwegianPatronDB, qw( NLUpdateHashedPIN NLEncryptPIN NLSync ); >-} >+require Koha::NorwegianPatronDB; > > our ($VERSION,@ISA,@EXPORT,@EXPORT_OK,$debug); > >@@ -651,7 +648,7 @@ sub ModMember { > } else { > if ( C4::Context->preference('NorwegianPatronDBEnable') && C4::Context->preference('NorwegianPatronDBEnable') == 1 ) { > # Update the hashed PIN in borrower_sync.hashed_pin, before Koha hashes it >- NLUpdateHashedPIN( $data{'borrowernumber'}, $data{password} ); >+ Koha::NorwegianPatronDB::NLUpdateHashedPIN( $data{'borrowernumber'}, $data{password} ); > } > $data{password} = hash_password($data{password}); > } >@@ -705,7 +702,7 @@ sub ModMember { > # Set the value of 'sync' > $borrowersync->update( { 'sync' => $data{'sync'} } ); > # Try to do the live sync >- NLSync({ 'borrowernumber' => $data{'borrowernumber'} }); >+ Koha::NorwegianPatronDB::NLSync({ 'borrowernumber' => $data{'borrowernumber'} }); > } > > logaction("MEMBERS", "MODIFY", $data{'borrowernumber'}, "UPDATE (executed w/ arg: $data{'borrowernumber'})") if C4::Context->preference("BorrowersLog"); >@@ -781,7 +778,7 @@ sub AddMember { > 'synctype' => 'norwegianpatrondb', > 'sync' => 1, > 'syncstatus' => 'new', >- 'hashed_pin' => NLEncryptPIN( $plain_text_password ), >+ 'hashed_pin' => Koha::NorwegianPatronDB::NLEncryptPIN( $plain_text_password ), > }); > } > >diff --git a/t/Circulation_barcodedecode.t b/t/Circulation_barcodedecode.t >index 5b1e065..eff9624 100644 >--- a/t/Circulation_barcodedecode.t >+++ b/t/Circulation_barcodedecode.t >@@ -16,14 +16,12 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use Test::More tests => 25; >-use t::lib::Mocks; >-use C4::Circulation; >+ >+use Test::More tests => 26; >+ > use C4::Context; > >-BEGIN { >- t::lib::Mocks::mock_dbh; >-}; >+use_ok( 'C4::Circulation' ); > > C4::Context->_new_userenv(123456); > C4::Context->set_userenv(1,'kmkale' , 1, 'km', 'kale' , 'IMS', 'IMS Branch DEscription', 0, 'kmkale@anantcorp.com'); >@@ -49,25 +47,18 @@ our %outputs = ( > my @filters = sort keys %inputs; > foreach my $filter (@filters) { > foreach my $datum (@{$inputs{$filter}}) { >- my $expect = shift @{$outputs{$filter}} or die "Internal Test Error: missing expected output for filter '$filter' on input '$datum'"; >+ my $expect = shift @{$outputs{$filter}} >+ or die "Internal Test Error: missing expected output for filter '$filter' on input '$datum'"; > my $output = C4::Circulation::barcodedecode($datum, $filter); > ok($output eq $expect, sprintf("%12s: %20s => %15s", $filter, "'$datum'", "'$expect'")); > ($output eq $expect) or diag "Bad output: '$output'"; > } > } > >-__END__ >- >-=head2 C4::Circulation::barcodedecode() >- >-This tests avoids being dependent on the database by using the optional >-second argument to barcodedecode. >- >-T-prefix style is derived from zero-padded "Follett Classic Code 3 of 9". From: >- www.fsc.follett.com/_file/File/pdf/Barcode%20Symbology%20Q%20%20A%203_05.pdf >- >- ~ 1 to 7 characters >- ~ T, P or X followed by numeric characters >- ~ No checkdigit >+# T-prefix style is derived from zero-padded "Follett Classic Code 3 of 9". From: >+# www.fsc.follett.com/_file/File/pdf/Barcode%20Symbology%20Q%20%20A%203_05.pdf >+# ~ 1 to 7 characters >+# ~ T, P or X followed by numeric characters >+# ~ No checkdigit > >-=cut >+1; >-- >2.6.2
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 15151
:
44568
|
44569
|
44570
|
44571
|
44573
|
44604