From 591fd7ee7c0cca718b18dd6893601ba870c7cea3 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Wed, 30 Oct 2024 11:53:35 +0000 Subject: [PATCH] Bug 37582: Add unit test [WIP] --- t/db_dependent/SIP/Message.t | 39 ++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/t/db_dependent/SIP/Message.t b/t/db_dependent/SIP/Message.t index 7975619b075..befb8112e36 100755 --- a/t/db_dependent/SIP/Message.t +++ b/t/db_dependent/SIP/Message.t @@ -1637,6 +1637,45 @@ sub test_renew_desensitize { } +subtest 'Test convert_nonprinting_characters' => sub { + + my $schema = Koha::Database->new->schema; + $schema->storage->txn_begin; + + plan tests => 1; + my $builder = t::lib::TestBuilder->new(); + my $branchcode = $builder->build({ source => 'Branch' })->{branchcode}; + my ( $response, $findpatron ); + my $mocks = create_mocks( \$response, \$findpatron, \$branchcode ); + my $seen_patron = $builder->build({ + source => 'Borrower', + value => { + lastseen => '2001-01-01', + password => hash_password( PATRON_PW ), + branchcode => $branchcode, + dateexpiry => '3000-01-01', + debarred => '3000-01-01', + debarredcomment => "Comment 1\nComment 2\nComment 3", + }, + }); + my $cardnum = $seen_patron->{cardnumber}; + my $sip_patron = C4::SIP::ILS::Patron->new( $cardnum ); + $findpatron = $sip_patron; + + my $siprequest = PATRON_INFO . 'engYYYYMMDDZZZZHHMMSS' . ' ' . + FID_INST_ID . $branchcode . '|' . + FID_PATRON_ID . $cardnum . '|' . + FID_PATRON_PWD . PATRON_PW . '|'; + my $msg = C4::SIP::Sip::MsgType->new( $siprequest, 0 ); + + my $server = { ils => $mocks->{ils}, account => { convert_nonprinting_characters => ' -- '} }; + $msg->handle_patron_info( $server ); + + like( $response, qr/Comment 1 -- Comment 2 -- Comment 3/, "Response contains converted restriction comment" ); + + $schema->storage->txn_rollback; +}; + # Helper routines sub create_mocks { -- 2.39.5 (Apple Git-154)