From 48c668b45ab3bd4b847f1de00130aa249a35340a Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Wed, 20 Nov 2013 13:27:34 +1300 Subject: [PATCH] Continuing with work for the LookupUser method So far only works when passed an ID, not a username/password or cardnumber/password combination --- lib/NCIP/Handler.pm | 4 ++-- t/NCIP.t | 5 ++--- t/NCIP_Handler.t | 7 +++---- t/sample_data/LookupUser.xml | 16 ++++++++++++++++ 4 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 t/sample_data/LookupUser.xml diff --git a/lib/NCIP/Handler.pm b/lib/NCIP/Handler.pm index a9fab25..30c2ccf 100644 --- a/lib/NCIP/Handler.pm +++ b/lib/NCIP/Handler.pm @@ -18,13 +18,13 @@ package NCIP::Handler; use Modern::Perl; use Object::Tiny qw{ type namespace ils }; - -use NCIP::Handler::LookupItem; +use Module::Load; sub new { my $class = shift; my $params = shift; my $subclass = __PACKAGE__ . "::" . $params->{type}; + load $subclass || die "Can't load module $subclass"; my $self = bless { type => $params->{type}, namespace => $params->{namespace}, diff --git a/t/NCIP.t b/t/NCIP.t index 8a6519f..c5720a5 100644 --- a/t/NCIP.t +++ b/t/NCIP.t @@ -19,7 +19,7 @@ use strict; use warnings; use File::Slurp; -use Test::More tests => 7; # last test to print +use Test::More tests => 9; # last test to print use lib 'lib'; @@ -51,8 +51,7 @@ ok( ); is( $response, 'LookupItem', 'We got lookupitem with agency' ); -my $lookupuser = read_file('t/sample_data/LookupUser.xml'); - +my $lookupuser = read_file('t/sample_data/LookupUser.xml') || die "Cant open file"; ok( $response = $ncip->process_request($lookupuser), 'Try looking up a user' ); is( $response, 'LookupUser', 'We got lookupuser' ); diff --git a/t/NCIP_Handler.t b/t/NCIP_Handler.t index 8c9e44d..b4fb947 100644 --- a/t/NCIP_Handler.t +++ b/t/NCIP_Handler.t @@ -35,9 +35,8 @@ ok( my $response = $handler->handle() ); $type = 'LookupUser'; ok( - $handler = - NCIP::Handler->new( { namespace => $namespace, type => $type } ), - 'Create new LookupItem handler' - ); + $handler = NCIP::Handler->new( { namespace => $namespace, type => $type } ), + 'Create new LookupItem handler' +); ok( $response = $handler->handle() ); diff --git a/t/sample_data/LookupUser.xml b/t/sample_data/LookupUser.xml new file mode 100644 index 0000000..84e9940 --- /dev/null +++ b/t/sample_data/LookupUser.xml @@ -0,0 +1,16 @@ + + + + + + + 381 + + + + + + + + + -- 2.43.2