From 775efdd2a80fb2b59e4e2c2dfbb862778efde79e Mon Sep 17 00:00:00 2001 From: Chris Cormack Date: Wed, 18 Sep 2013 10:27:40 +1200 Subject: [PATCH] Working on extending NCIP.pm And adding some tests My idea is Figure out what type of request it is Handle request Return response working next on handle_initiation Signed-off-by: Chris Cormack --- lib/NCIP.pm | 26 +++++++++++++++++--------- t/NCIP.t | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 9 deletions(-) create mode 100644 t/NCIP.t diff --git a/lib/NCIP.pm b/lib/NCIP.pm index d1f1521..6bd9c58 100644 --- a/lib/NCIP.pm +++ b/lib/NCIP.pm @@ -1,26 +1,34 @@ package NCIP; use NCIP::Configuration; use Modern::Perl; - - -use FileHandle; +use base qw(Class::Accessor); sub new { - my $self = shift; - my $config_file = shift; - - my $config = NCIP::Configuration->new($config_file); - return bless $config, $self; + my $proto = shift; + my $class = ref $proto || $proto; + my $config_dir = shift; + my $self = {}; + my $config = NCIP::Configuration->new($config_dir); + $self->{config} = $config; + return bless $self, $class; } sub process_request { my $self = shift; my $xml = shift; - + + my $request_type = $self->handle_initiation($xml); my $response = " Hello There

Hello You Big JERK!

Who would take this book seriously if the first eaxample didn't say \"hello world\"? "; return $response; } +sub handle_initiation { + my $self = shift; + my $xml = shift; + + return('lookup_item'); +} + 1; diff --git a/t/NCIP.t b/t/NCIP.t new file mode 100644 index 0000000..fd18414 --- /dev/null +++ b/t/NCIP.t @@ -0,0 +1,34 @@ +# +#=============================================================================== +# +# FILE: NCIP.t +# +# DESCRIPTION: +# +# FILES: --- +# BUGS: --- +# NOTES: --- +# AUTHOR: Chris Cormack (rangi), chrisc@catalyst.net.nz +# ORGANIZATION: Koha Development Team +# VERSION: 1.0 +# CREATED: 18/09/13 09:59:01 +# REVISION: --- +#=============================================================================== + +use strict; +use warnings; + +use Test::More tests => 3; # last test to print + +use lib 'lib'; + +use_ok('NCIP'); +ok( my $ncip = NCIP->new('t/config_sample'), 'Create new object' ); + +my $xml = <<'EOT'; + + +EOT + +ok( my $response = $ncip->process_request($xml), 'Process a request' ); + -- 2.43.2