Bugzilla – Attachment 108634 Details for
Bug 26059
Create guarantor/guarantee links on patron import
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26059: Add unit tests
Bug-26059-Add-unit-tests.patch (text/plain), 4.66 KB, created by
Kyle M Hall (khall)
on 2020-08-19 14:31:24 UTC
(
hide
)
Description:
Bug 26059: Add unit tests
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2020-08-19 14:31:24 UTC
Size:
4.66 KB
patch
obsolete
>From a65c3bb3fa47738eda167efaedd3b08097ebb7eb Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Wed, 19 Aug 2020 10:30:29 -0400 >Subject: [PATCH] Bug 26059: Add unit tests > >--- > t/db_dependent/Koha/Patrons/Import.t | 43 +++++++++++++++++++++++++--- > 1 file changed, 39 insertions(+), 4 deletions(-) > >diff --git a/t/db_dependent/Koha/Patrons/Import.t b/t/db_dependent/Koha/Patrons/Import.t >index a6f09e41ab..efd0a55197 100644 >--- a/t/db_dependent/Koha/Patrons/Import.t >+++ b/t/db_dependent/Koha/Patrons/Import.t >@@ -18,7 +18,7 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use Test::More tests => 159; >+use Test::More tests => 160; > use Test::Warn; > use Encode qw( encode_utf8 ); > use utf8; >@@ -26,6 +26,7 @@ use utf8; > # To be replaced by t::lib::Mock > use Test::MockModule; > use Koha::Database; >+use Koha::Patron::Relationships; > > use File::Temp qw(tempfile tempdir); > my $temp_dir = tempdir('Koha_patrons_import_test_XXXX', CLEANUP => 1, TMPDIR => 1); >@@ -87,7 +88,6 @@ is($result_0, undef, 'Got the expected undef from import_patrons with no file ha > t::lib::Mocks::mock_preference('ExtendedPatronAttributes', 0); > t::lib::Mocks::mock_preference('dateformat', 'us'); > >- > my $csv_headers = 'cardnumber,surname,firstname,title,othernames,initials,streetnumber,streettype,address,address2,city,state,zipcode,country,email,phone,mobile,fax,dateofbirth,branchcode,categorycode,dateenrolled,dateexpiry,userid,password'; > my $res_header = 'cardnumber, surname, firstname, title, othernames, initials, streetnumber, streettype, address, address2, city, state, zipcode, country, email, phone, mobile, fax, dateofbirth, branchcode, categorycode, dateenrolled, dateexpiry, userid, password'; > my $csv_one_line = '1000,Nancy,Jenkins,Dr,,NJ,78,Circle,Bunting,El Paso,Henderson,Texas,79984,United States,ajenkins0@sourceforge.net,7-(388)559-6763,3-(373)151-4471,8-(509)286-4001,10/16/1965,CPL,PT,12/28/2014,07/01/2015,jjenkins0,DPQILy'; >@@ -434,6 +434,40 @@ subtest 'test_import_with_cardnumber_0' => sub { > > }; > >+subtest 'Import patron with guarantor' => sub { >+ plan tests => 4; >+ t::lib::Mocks::mock_preference( 'borrowerRelationship', 'guarantor' ); >+ >+ my $category = $builder->build( { source => 'Category' } )->{categorycode}; >+ my $branch = $builder->build( { source => 'Branch' } )->{branchcode}; >+ my $guarantor = Koha::Patron->new( >+ { >+ surname => 'Guarantor', >+ branchcode => $branch, >+ categorycode => $category, >+ } >+ )->store(); >+ my $guarantor_id = $guarantor->id; >+ >+ my $branchcode = $builder->build( { source => "Branch" } )->{branchcode}; >+ my $categorycode = $builder->build( { source => "Category" } )->{categorycode}; >+ my $csv_headers = 'cardnumber,surname, branchcode, categorycode, guarantor_id, guarantor_relationship'; >+ my $csv_nocard_1 = "kylemhall,Hall,$branchcode,$categorycode,$guarantor_id,guarantor"; >+ >+ my $filename_1 = make_csv( $temp_dir, $csv_headers, $csv_nocard_1 ); >+ open( my $handle_1, "<", $filename_1 ) or die "cannot open < $filename_1: $!"; >+ my $params_1 = { file => $handle_1, }; >+ >+ my $result = $patrons_import->import_patrons( $params_1 ); >+ like( $result->{feedback}->[1]->{value}, qr/^Hall \/ \d+/, 'First borrower imported as expected' ); >+ my $patron = Koha::Patrons->find( { cardnumber => 'kylemhall' } ); >+ is( $patron->surname, "Hall", "Patron was created" ); >+ >+ my $r = Koha::Patron::Relationships->find( { guarantor_id => $guarantor_id } ); >+ ok( $r, 'Found relationship' ); >+ is( $r->guarantee->cardnumber, 'kylemhall', 'Found the correct guarantee' ); >+}; >+ > subtest 'test_import_with_password_overwrite' => sub { > plan tests => 8; > >@@ -584,14 +618,15 @@ subtest 'test_set_column_keys' => sub { > # When ... Then ... > my @columnkeys_0 = $patrons_import->set_column_keys(undef); > # -1 because we do not want the borrowernumber column >- is(scalar @columnkeys_0, @columns - 1, 'Got the expected array size from set column keys with undef extended'); >+ # +2 for guarantor id and guarantor relationship >+ is(scalar @columnkeys_0, @columns - 1 + 2, 'Got the expected array size from set column keys with undef extended'); > > # Given ... extended. > my $extended = 1; > > # When ... Then ... > my @columnkeys_1 = $patrons_import->set_column_keys($extended); >- is(scalar @columnkeys_1, @columns - 1 + $extended, 'Got the expected array size from set column keys with extended'); >+ is(scalar @columnkeys_1, @columns - 1 + 2 + $extended, 'Got the expected array size from set column keys with extended'); > }; > > subtest 'test_generate_patron_attributes' => sub { >-- >2.24.1 (Apple Git-126)
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 26059
:
107360
|
107364
|
107505
|
107703
|
108319
|
108634
|
108635