Bug 5327 shifting database dependent modules and scripts to t/db_dependent
[koha.git] / t / db_dependent / lib / KohaTest / ImportBatch / GetZ3950BatchId.pm
1 package KohaTest::ImportBatch::GetZ3950BatchId;
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 batch_does_not_exist
15
16 =cut
17
18 sub batch_does_not_exist : Test( 5 ) {
19     my $self = shift;
20
21     my $file_name = 'testing batch';
22
23     # lets make sure it doesn't exist first
24     my $sth = C4::Context->dbh->prepare('SELECT import_batch_id FROM import_batches
25                                          WHERE  batch_type = ?
26                                          AND    file_name = ?');
27     ok( $sth->execute( 'z3950', $file_name, ), 'execute' );
28     my $rowref = $sth->fetchrow_arrayref();
29     ok( !defined( $rowref ), 'this batch does not exist' );
30
31     # now let GetZ3950BatchId create one
32     my $new_batch_id = GetZ3950BatchId( $file_name );
33     ok( $new_batch_id, "got a new batch ID: $new_batch_id" );
34
35     # now search for the one that was just created
36     my $second_batch_id = GetZ3950BatchId( $file_name );
37     ok( $second_batch_id, "got a second batch ID: $second_batch_id" );
38     is( $second_batch_id, $new_batch_id, 'we got the same batch both times.' );
39 }
40
41
42 1;