4 use FindBin
qw( $Bin );
7 use Module::Load::Conditional qw/check_install/;
10 if ( check_install( module => 'Test::DBIx::Class' ) ) {
14 plan skip_all => 'Need Test::DBIx::Class';
19 use Test::DBIx::Class;
23 [ [ 'id', 'description', 'transport' ], [ 1, 'test vendor', 'FILE' ], ],
25 [ 'message_type', 'filename', 'raw_msg' ],
26 [ 'TEST', 'duplicate', 'message_contents' ],
31 my $filename = 'QUOTES_413514.CEQ';
33 my $db = Test::MockModule->new('Koha::Database');
34 $db->mock( _new_schema => sub { return Schema(); } );
36 use_ok('Koha::Edifact::Transport');
38 my $trans = Koha::Edifact::Transport->new(1);
40 isa_ok( $trans, 'Koha::Edifact::Transport' );
42 $trans->working_directory("$Bin/edi_testfiles");
44 my $mhash = $trans->message_hash();
45 $mhash->{message_type} = 'TEST'; # set a bogus message type
47 $trans->ingest( $mhash, $filename );
49 my $cnt = ResultSet('EdifactMessage')->count();
51 is( $cnt, 2, 'unique message name ingested' );
53 $trans->ingest( $mhash, $filename ); # try a repeat ingest
55 my $cnt2 = ResultSet('EdifactMessage')->count();
57 is( $cnt2, 2, 'duplicate message name not ingested' );