f4e00328bc
Add test framework for Koha::Edifact::Transport Add specific test that ingest does not duplicate an existing filename Signed-off-by: Mark Tompsett <mtompset@hotmail.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
57 lines
1.3 KiB
Perl
57 lines
1.3 KiB
Perl
#!/usr/bin/perl
|
|
|
|
use Modern::Perl;
|
|
use FindBin qw( $Bin );
|
|
use Test::More;
|
|
use Test::MockModule;
|
|
use Module::Load::Conditional qw/check_install/;
|
|
|
|
BEGIN {
|
|
if ( check_install( module => 'Test::DBIx::Class' ) ) {
|
|
plan tests => 5;
|
|
}
|
|
else {
|
|
plan skip_all => 'Need Test::DBIx::Class';
|
|
}
|
|
|
|
}
|
|
|
|
use Test::DBIx::Class;
|
|
|
|
fixtures_ok [
|
|
VendorEdiAccount =>
|
|
[ [ 'id', 'description', 'transport' ], [ 1, 'test vendor', 'FILE' ], ],
|
|
EdifactMessage => [
|
|
[ 'message_type', 'filename', 'raw_msg' ],
|
|
[ 'TEST', 'duplicate', 'message_contents' ],
|
|
],
|
|
],
|
|
'add_fixtures';
|
|
|
|
my $filename = 'QUOTES_413514.CEQ';
|
|
|
|
my $db = Test::MockModule->new('Koha::Database');
|
|
$db->mock( _new_schema => sub { return Schema(); } );
|
|
|
|
use_ok('Koha::Edifact::Transport');
|
|
|
|
my $trans = Koha::Edifact::Transport->new(1);
|
|
|
|
isa_ok( $trans, 'Koha::Edifact::Transport' );
|
|
|
|
$trans->working_directory("$Bin/edi_testfiles");
|
|
|
|
my $mhash = $trans->message_hash();
|
|
$mhash->{message_type} = 'TEST'; # set a bogus message type
|
|
|
|
$trans->ingest( $mhash, $filename );
|
|
|
|
my $cnt = ResultSet('EdifactMessage')->count();
|
|
|
|
is( $cnt, 2, 'unique message name ingested' );
|
|
|
|
$trans->ingest( $mhash, $filename ); # try a repeat ingest
|
|
|
|
my $cnt2 = ResultSet('EdifactMessage')->count();
|
|
|
|
is( $cnt2, 2, 'duplicate message name not ingested' );
|