Bug 5327 shifting database dependent modules and scripts to t/db_dependent
[koha-ffzg.git] / t / db_dependent / lib / KohaTest / ImportBatch / GetImportRecordMarc.pm
1 package KohaTest::ImportBatch::GetImportRecordMarc;
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 record_does_not_exist
15
16 =cut
17
18 sub record_does_not_exist : Test( 1 ) {
19     my $self = shift;
20
21     my $id = '999999999999';
22     my $marc = GetImportRecordMarc( $id );
23     ok( ! defined( $marc ), 'this marc is undefined' );
24
25 }
26
27 sub record_does_exist : Test( 4 ) {
28     my $self = shift;
29
30     # we need an import_batch, so let GetZ3950BatchId create one:
31     my $new_batch_id = GetZ3950BatchId('foo');
32     ok( $new_batch_id, "got a new batch ID: $new_batch_id" );
33
34     my $sth = C4::Context->dbh->prepare(
35         "INSERT INTO import_records (import_batch_id, marc, marcxml)
36                                     VALUES (?, ?, ?)"
37     );
38     my $execute = $sth->execute(
39         $new_batch_id,    # batch_id
40         'marc',           # marc
41         'marcxml',        # marcxml
42     );
43     ok( $execute, 'succesfully executed' );
44     my $import_record_id = C4::Context->dbh->{'mysql_insertid'};
45     ok( $import_record_id, 'we got an import_record_id' );
46
47     my $marc = GetImportRecordMarc($import_record_id);
48     ok( defined($marc), 'this marc is defined' );
49 }
50
51 1;