From 955f4e7682e9e05e96faf0ce07e05337ab73958f Mon Sep 17 00:00:00 2001 From: simith Date: Thu, 30 Oct 2014 12:40:57 -0400 Subject: [PATCH] unit test added http://bugs.koha-community.org/show_bug.cgi?id=11876 --- t/db_dependent/ImportBatch.t | 75 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 t/db_dependent/ImportBatch.t diff --git a/t/db_dependent/ImportBatch.t b/t/db_dependent/ImportBatch.t new file mode 100644 index 0000000..c81fb51 --- /dev/null +++ b/t/db_dependent/ImportBatch.t @@ -0,0 +1,75 @@ +#!/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" ); + + + -- 1.9.1