From 65c8bb3b8f200eb0a47334fbb2f430f59e114260 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Tue, 21 Mar 2017 10:27:03 +0100 Subject: [PATCH] Bug 12026: [QA Follow-up] POD typo and tiny change in AddMember_Opac Content-Type: text/plain; charset=utf-8 [1] Correct xml error in POD Copy-pasting this example from Auth_with_shibboleth.pm into koha-conf.xml did not work. We need a closing tag ;) [2] If AddMember_Opac calls AddMember_Auto, there is no need to call fixup_cardnumber. Adding trivial test for AddMember_Auto in Members.t. Signed-off-by: Marcel de Rooy --- C4/Auth_with_shibboleth.pm | 2 +- C4/Members.pm | 2 -- t/db_dependent/Members.t | 20 ++++++++++++++++---- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/C4/Auth_with_shibboleth.pm b/C4/Auth_with_shibboleth.pm index 6a9a1cf..1c996a2 100644 --- a/C4/Auth_with_shibboleth.pm +++ b/C4/Auth_with_shibboleth.pm @@ -256,7 +256,7 @@ This is as simple as enabling B in koha-conf.xml: Map shibboleth attributes to koha fields, and configure authentication match point in koha-conf.xml. - userid + userid diff --git a/C4/Members.pm b/C4/Members.pm index abdffb4..ee10cc7 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -1291,8 +1291,6 @@ sub AddMember_Opac { $borrower{'password'} = $password; } - $borrower{'cardnumber'} = fixup_cardnumber( $borrower{'cardnumber'} ); - %borrower = AddMember_Auto(%borrower); return ( $borrower{'borrowernumber'}, $borrower{'password'} ); diff --git a/t/db_dependent/Members.t b/t/db_dependent/Members.t index 3d24e44..8520777 100755 --- a/t/db_dependent/Members.t +++ b/t/db_dependent/Members.t @@ -17,9 +17,9 @@ use Modern::Perl; -use Test::More tests => 64; +use Test::More tests => 65; use Test::MockModule; -use Data::Dumper; +use Data::Dumper qw/Dumper/; use C4::Context; use Koha::Database; use Koha::Holds; @@ -37,7 +37,6 @@ my $schema = Koha::Database->schema; $schema->storage->txn_begin; my $builder = t::lib::TestBuilder->new; my $dbh = C4::Context->dbh; -$dbh->{RaiseError} = 1; # Remove invalid guarantorid's as long as we have no FK $dbh->do("UPDATE borrowers b1 LEFT JOIN borrowers b2 ON b2.borrowernumber=b1.guarantorid SET b1.guarantorid=NULL where b1.guarantorid IS NOT NULL AND b2.borrowernumber IS NULL"); @@ -491,4 +490,17 @@ eval { is($@, '', 'Bug 16009: GetMember(cardnumber => undef) works'); is($patron, undef, 'Bug 16009: GetMember(cardnumber => undef) returns undef'); -1; +subtest 'Trivial test for AddMember_Auto' => sub { + plan tests => 3; + my $members_mock = Test::MockModule->new( 'C4::Members' ); + $members_mock->mock( 'fixup_cardnumber', sub { 12345; } ); + my $library = $builder->build({ source => 'Branch' }); + my $category = $builder->build({ source => 'Category' }); + my %borr = AddMember_Auto( surname=> 'Dick3', firstname => 'Philip', branchcode => $library->{branchcode}, categorycode => $category->{categorycode}, password => '34567890' ); + ok( $borr{borrowernumber}, 'Borrower hash contains borrowernumber' ); + is( $borr{cardnumber}, 12345, 'Borrower hash contains cardnumber' ); + $patron = Koha::Patrons->find( $borr{borrowernumber} ); + isnt( $patron, undef, 'Patron found' ); +}; + +$schema->storage->txn_rollback; -- 2.1.4