Bug 5327 shifting database dependent modules and scripts to t/db_dependent
[koha.git] / t / db_dependent / lib / KohaTest / ImportBatch / GetImportBatch.pm
1 package KohaTest::ImportBatch::getImportBatch;
2 use base qw( KohaTest::ImportBatch );
3
4 use strict;
5 use warnings;
6
7 use Test::More;
8
9 use C4::ImportBatch;
10 use C4::Matcher;
11 use C4::Biblio;
12
13
14 =head3 add_one_and_find_it
15
16 =cut
17
18 sub add_one_and_find_it : Test( 7 ) {
19     my $self = shift;
20
21     my $batch = {
22         overlay_action => 'create_new',
23         import_status  => 'staging',
24         batch_type     => 'batch',
25         file_name      => 'foo',
26         comments       => 'inserted during automated testing',
27     };
28     my $batch_id = AddImportBatch(
29       $batch->{'overlay_action'},
30       $batch->{'import_status'},
31       $batch->{'batch_type'},
32       $batch->{'file_name'},
33       $batch->{'comments'},
34     );
35     ok( $batch_id, "successfully inserted batch: $batch_id" );
36
37     my $retrieved = GetImportBatch( $batch_id );
38
39     foreach my $key ( keys %$batch ) {
40         is( $retrieved->{$key}, $batch->{$key}, "both objects agree on $key" );
41     }
42     is( $retrieved->{'import_batch_id'}, $batch_id, 'batch_id' );
43 }
44
45 1;