View | Details | Raw Unified | Return to bug 34415
Collapse All | Expand All

(-)a/t/EdiTransport.t (-33 / +25 lines)
Lines 2-41 Link Here
2
2
3
use Modern::Perl;
3
use Modern::Perl;
4
use FindBin qw( $Bin );
4
use FindBin qw( $Bin );
5
use Test::More;
5
use Test::More tests => 5;
6
use Test::MockModule;
6
use Test::Warn;
7
use Module::Load::Conditional qw/check_install/;
8
9
BEGIN {
10
    if ( check_install( module => 'Test::DBIx::Class' ) ) {
11
        plan tests => 5;
12
    }
13
    else {
14
        plan skip_all => 'Need Test::DBIx::Class';
15
    }
16
17
}
18
19
use Test::DBIx::Class;
20
21
fixtures_ok [
22
    VendorEdiAccount =>
23
      [ [ 'id', 'description', 'transport' ], [ 1, 'test vendor', 'FILE' ], ],
24
    EdifactMessage => [
25
        [ 'message_type', 'filename',  'raw_msg' ],
26
        [ 'TEST',         'duplicate', 'message_contents' ],
27
    ],
28
  ],
29
  'add_fixtures';
30
7
31
my $filename = 'QUOTES_413514.CEQ';
8
use t::lib::TestBuilder;
9
10
use Koha::Database;
11
12
my $schema = Koha::Database->new->schema;
13
my $builder = t::lib::TestBuilder->new;
14
15
$schema->storage->txn_begin;
32
16
33
my $db = Test::MockModule->new('Koha::Database');
17
my $account = $builder->build({ source => 'VendorEdiAccount', value => {
34
$db->mock( _new_schema => sub { return Schema(); } );
18
    description => 'test vendor', transport => 'FILE',
19
}});
20
$builder->build({ source => 'EdifactMessage', value => {
21
    message_type => 'TEST', filename => 'duplicate', raw_msg => 'message_contents'
22
}});
23
24
my $filename = 'QUOTES_413514.CEQ';
35
25
36
use_ok('Koha::Edifact::Transport');
26
use_ok('Koha::Edifact::Transport');
37
27
38
my $trans = Koha::Edifact::Transport->new(1);
28
my $trans = Koha::Edifact::Transport->new( $account->{id} );
39
29
40
isa_ok( $trans, 'Koha::Edifact::Transport' );
30
isa_ok( $trans, 'Koha::Edifact::Transport' );
41
31
Lines 46-57 $mhash->{message_type} = 'TEST'; # set a bogus message type Link Here
46
36
47
$trans->ingest( $mhash, $filename );
37
$trans->ingest( $mhash, $filename );
48
38
49
my $cnt = ResultSet('EdifactMessage')->count();
39
my $cnt = $schema->resultset('EdifactMessage')->count();
50
40
51
is( $cnt, 2, 'unique message name ingested' );
41
is( $cnt, 2, 'unique message name ingested' );
52
42
53
$trans->ingest( $mhash, $filename );    # try a repeat ingest
43
# try a repeat ingest
44
warning_like {$trans->ingest( $mhash, $filename ) } qr/skipping ingest of QUOTES_413514.CEQ/, 'Warning on repeated ingest';
54
45
55
my $cnt2 = ResultSet('EdifactMessage')->count();
46
my $cnt2 = $schema->resultset('EdifactMessage')->count();
56
47
57
is( $cnt2, 2, 'duplicate message name not ingested' );
48
is( $cnt2, 2, 'duplicate message name not ingested' );
58
- 
49
50
$schema->storage->txn_rollback;

Return to bug 34415