--- /dev/null
+package WebPAC::Input::Test;
+
+use warnings;
+use strict;
+
+use WebPAC::Input;
+use base qw/WebPAC::Common/;
+
+=head1 NAME
+
+WebPAC::Input::Test - Mock test records for WebPAC
+
+=head1 VERSION
+
+Version 0.01
+
+=cut
+
+our $VERSION = '0.01';
+
+=head1 SYNOPSIS
+
+Setup test record
+
+ $WebPAC::Input::Test::rec = {
+ '200' => [ {
+ 'a' => 'foo',
+ 'b' => 'bar',
+ }, {
+ 'a' => 'baz',
+ } ],
+ '900' => [
+ 'foobar',
+ ],
+ };
+
+Setup optional size
+
+ $WebPAC::Input::Test::Size = 42;
+
+=head1 FUNCTIONS
+
+=head2 new
+
+ my $isis = new WebPAC::Input::Test(
+ path => '/path/to/LIBRI'
+ filter => sub {
+ my ($l,$field_nr) = @_;
+ # do something with $l which is line of input file
+ return $l;
+ },
+ }
+
+=cut
+
+sub new {
+ my $class = shift;
+ my $self = {@_};
+ bless($self, $class);
+
+ my $arg = {@_};
+
+ $self->_get_logger()->info("mocking Test database with args = ", dump($arg));
+
+ $self ? return $self : return undef;
+}
+
+=head2 fetch_rec
+
+Return record with ID C<$mfn> from database
+
+ my $rec = $isis->fetch_rec( $mfn );
+
+Second argument, C<filter_coderef> is ignored.
+
+=cut
+
+my $rec;
+
+sub fetch_rec {
+ my $self = shift;
+
+ my ($mfn, $filter_coderef) = @_;
+
+ $self->_get_logger()->info("mfn = $mfn");
+
+ return $rec;
+}
+
+=head2 dump_ascii
+
+Return dump of record ID C<$mfn> from database
+
+ my $rec = $isis->dump_ascii( $mfn );
+
+=cut
+
+sub dump_ascii {
+ my $self = shift;
+
+ return dump( $rec );
+}
+
+=head2 size
+
+Return number of records in database
+
+ my $size = $isis->size;
+
+=cut
+
+my $size = 1;
+
+sub size {
+ my $self = shift;
+ $self->_get_logger()->info("size = $size");
+ return $size;
+}
+
+=head1 AUTHOR
+
+Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>
+
+=head1 COPYRIGHT & LICENSE
+
+Copyright 2007 Dobrica Pavlinusic, All Rights Reserved.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+=cut
+
+1; # End of WebPAC::Input::Test
BEGIN {
use_ok( 'WebPAC::Input::ISIS' );
use_ok( 'WebPAC::Input::MARC' );
+use_ok( 'WebPAC::Input::Test' );
}
my $debug = shift @ARGV;
test_fetch($input, $input->size);
# test modify_record
-$module = 'WebPAC::Input::ISIS';
-ok($input = new WebPAC::Input( module => $module, no_log => $no_log, no_progress_bar => 1 ), "new $module");
+$module = 'WebPAC::Input::Test';
+ok($input = new WebPAC::Input( module => $module, no_log => $no_log, no_progress_bar => 1, debug => $debug ), "new $module");
ok($input->open( path => "$abs_path/modify_isis/LIBRI", ), "open modify_isis (plain)");
+
+$WebPAC::Input::Test::rec = {
+ '200' => [ {
+ 'a' => 'foo',
+ 'b' => 'bar',
+ }, {
+ 'a' => 'baz',
+ } ],
+ '900' => [
+ 'foobar',
+ ],
+};
+
+ok($input->size, 'size');
+
ok(my $rec_p = $input->fetch, 'fetch');
# modify_records