From a1bfc1f73e0903bbfd121fbcb7f0d47165883fa6 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Tue, 29 Oct 2024 09:23:31 +0000 Subject: [PATCH] Bug 38284: Add tests Signed-off-by: David Nind --- t/db_dependent/SIP/Message.t | 39 +++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/SIP/Message.t b/t/db_dependent/SIP/Message.t index 325d9361d4..2e3207076e 100755 --- a/t/db_dependent/SIP/Message.t +++ b/t/db_dependent/SIP/Message.t @@ -21,7 +21,7 @@ # along with Koha; if not, see . use Modern::Perl; -use Test::More tests => 21; +use Test::More tests => 22; use Test::Exception; use Test::MockObject; use Test::MockModule; @@ -492,6 +492,43 @@ subtest 'Lastseen response patron status' => sub { }; +subtest 'Invalid cardnumber test response patron status' => sub { + + plan tests => 1; + + my $schema = Koha::Database->new->schema; + $schema->storage->txn_begin; + + my $builder = t::lib::TestBuilder->new(); + my $branchcode = $builder->build( { source => 'Branch' } )->{branchcode}; + my ( $response, $findpatron ); + my $mocks = create_mocks( \$response, \$findpatron, \$branchcode ); + my $cardnum = 'nonexistentcardnumber'; + my $sip_patron = C4::SIP::ILS::Patron->new($cardnum); + $findpatron = $sip_patron; + + my $siprequest = + PATRON_STATUS_REQ + . '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} }; + undef $response; + + t::lib::Mocks::mock_preference( 'TrackLastPatronActivityTriggers', 'login' ); + $msg->handle_patron_status($server); + isnt( $response, undef, 'At least we got a response.' ); + + $schema->storage->txn_rollback; + +}; + subtest "Test build_additional_item_fields_string" => sub { my $schema = Koha::Database->new->schema; $schema->storage->txn_begin; -- 2.39.5