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

(-)a/t/db_dependent/ImportBatch.t (-1 / +75 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
use Modern::Perl;
4
5
use C4::Context;
6
7
use Test::More tests => 5;
8
9
BEGIN {
10
        use_ok('C4::ImportBatch');
11
}
12
13
# Start transaction
14
my $dbh = C4::Context->dbh;
15
$dbh->{AutoCommit} = 0;
16
$dbh->{RaiseError} = 1;
17
18
# clear 
19
$dbh->do('DELETE FROM import_batches');
20
21
my $sample_import_batch1 = {
22
    matcher_id => 1,
23
    template_id => 1,
24
    branchcode => 'QRT',
25
    overlay_action => 'create_new',
26
    nomatch_action => 'create_new',
27
    item_action => 'always_add',
28
    import_status => 'staged',
29
    batch_type => 'z3950',
30
    file_name => 'test.mrc',
31
    comments => 'test',
32
    record_type => 'auth',
33
};
34
35
my $sample_import_batch2 = {
36
    matcher_id => 2,
37
    template_id => 2,
38
    branchcode => 'QRZ',
39
    overlay_action => 'create_new',
40
    nomatch_action => 'create_new',
41
    item_action => 'always_add',
42
    import_status => 'staged',
43
    batch_type => 'z3950',
44
    file_name => 'test.mrc',
45
    comments => 'test',
46
    record_type => 'auth',
47
};
48
49
my $id_import_batch1 = C4::ImportBatch::AddImportBatch($sample_import_batch1);
50
my $id_import_batch2 = C4::ImportBatch::AddImportBatch($sample_import_batch2);
51
52
like( $id_import_batch1, '/^\d+$/', "AddImportBatch for sample_import_batch1 return an id" );
53
like( $id_import_batch2, '/^\d+$/', "AddImportBatch for sample_import_batch2 return an id" );
54
55
#Test GetImportBatch
56
my $importbatch2 = C4::ImportBatch::GetImportBatch( $id_import_batch2 );
57
delete $importbatch2->{upload_timestamp};
58
delete $importbatch2->{import_batch_id};
59
delete $importbatch2->{num_records};
60
delete $importbatch2->{num_items};
61
62
is_deeply( $importbatch2, $sample_import_batch2,
63
    "GetImportBatch returns the right informations about $sample_import_batch2" );
64
65
my $importbatch1 = C4::ImportBatch::GetImportBatch( $id_import_batch1 );
66
delete $importbatch1->{upload_timestamp};
67
delete $importbatch1->{import_batch_id};
68
delete $importbatch1->{num_records};
69
delete $importbatch1->{num_items};
70
71
is_deeply( $importbatch1, $sample_import_batch1,
72
    "GetImportBatch returns the right informations about $sample_import_batch1" );
73
74
75

Return to bug 11876