b61ebfd0fa
Unit test added http://bugs.koha-community.org/show_bug.cgi?id=11876 Signed-off-by: Owen Leonard <oleonard@myacpl.org> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
72 lines
2 KiB
Perl
72 lines
2 KiB
Perl
#!/usr/bin/perl
|
|
|
|
use Modern::Perl;
|
|
|
|
use C4::Context;
|
|
|
|
use Test::More tests => 5;
|
|
|
|
BEGIN {
|
|
use_ok('C4::ImportBatch');
|
|
}
|
|
|
|
# Start transaction
|
|
my $dbh = C4::Context->dbh;
|
|
$dbh->{AutoCommit} = 0;
|
|
$dbh->{RaiseError} = 1;
|
|
|
|
# clear
|
|
$dbh->do('DELETE FROM import_batches');
|
|
|
|
my $sample_import_batch1 = {
|
|
matcher_id => 1,
|
|
template_id => 1,
|
|
branchcode => 'QRT',
|
|
overlay_action => 'create_new',
|
|
nomatch_action => 'create_new',
|
|
item_action => 'always_add',
|
|
import_status => 'staged',
|
|
batch_type => 'z3950',
|
|
file_name => 'test.mrc',
|
|
comments => 'test',
|
|
record_type => 'auth',
|
|
};
|
|
|
|
my $sample_import_batch2 = {
|
|
matcher_id => 2,
|
|
template_id => 2,
|
|
branchcode => 'QRZ',
|
|
overlay_action => 'create_new',
|
|
nomatch_action => 'create_new',
|
|
item_action => 'always_add',
|
|
import_status => 'staged',
|
|
batch_type => 'z3950',
|
|
file_name => 'test.mrc',
|
|
comments => 'test',
|
|
record_type => 'auth',
|
|
};
|
|
|
|
my $id_import_batch1 = C4::ImportBatch::AddImportBatch($sample_import_batch1);
|
|
my $id_import_batch2 = C4::ImportBatch::AddImportBatch($sample_import_batch2);
|
|
|
|
like( $id_import_batch1, '/^\d+$/', "AddImportBatch for sample_import_batch1 return an id" );
|
|
like( $id_import_batch2, '/^\d+$/', "AddImportBatch for sample_import_batch2 return an id" );
|
|
|
|
#Test GetImportBatch
|
|
my $importbatch2 = C4::ImportBatch::GetImportBatch( $id_import_batch2 );
|
|
delete $importbatch2->{upload_timestamp};
|
|
delete $importbatch2->{import_batch_id};
|
|
delete $importbatch2->{num_records};
|
|
delete $importbatch2->{num_items};
|
|
|
|
is_deeply( $importbatch2, $sample_import_batch2,
|
|
"GetImportBatch returns the right informations about $sample_import_batch2" );
|
|
|
|
my $importbatch1 = C4::ImportBatch::GetImportBatch( $id_import_batch1 );
|
|
delete $importbatch1->{upload_timestamp};
|
|
delete $importbatch1->{import_batch_id};
|
|
delete $importbatch1->{num_records};
|
|
delete $importbatch1->{num_items};
|
|
|
|
is_deeply( $importbatch1, $sample_import_batch1,
|
|
"GetImportBatch returns the right informations about $sample_import_batch1" );
|