From 132d202183092db10d1ec7dffc86c7152aa58208 Mon Sep 17 00:00:00 2001
From: simith <simith@inlibro.com>
Date: Thu, 30 Oct 2014 12:40:57 -0400
Subject: [PATCH] [PASSED QA] Bug 11876 [Unit test] Add a diff view to staged MARC Records

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>
---
 t/db_dependent/ImportBatch.t |   72 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 72 insertions(+), 0 deletions(-)
 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..95e20cd
--- /dev/null
+++ b/t/db_dependent/ImportBatch.t
@@ -0,0 +1,72 @@
+#!/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.7.2.5