Bug 12428: (QA followup) regression tests.
authorTomas Cohen Arazi <tomascohen@gmail.com>
Mon, 23 Jun 2014 19:36:43 +0000 (16:36 -0300)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Mon, 23 Jun 2014 19:41:23 +0000 (16:41 -0300)
Just that.

Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
t/db_dependent/Items.t

index d1b15fb..dd8057b 100755 (executable)
@@ -20,9 +20,11 @@ use Modern::Perl;
 
 use MARC::Record;
 use C4::Biblio;
+use C4::Branch;
 use Koha::Database;
+use Data::Printer;
 
-use Test::More tests => 4;
+use Test::More tests => 5;
 
 BEGIN {
     use_ok('C4::Items');
@@ -38,8 +40,7 @@ subtest 'General Add, Get and Del tests' => sub {
     $dbh->{AutoCommit} = 0;
     $dbh->{RaiseError} = 1;
 
-    # Helper biblio.
-    diag("Creating biblio instance for testing.");
+    # Create a biblio instance for testing
     my ($bibnum, $bibitemnum) = get_biblio();
 
     # Add an item.
@@ -143,6 +144,44 @@ subtest 'GetHiddenItemnumbers tests' => sub {
     $dbh->rollback;
 };
 
+subtest 'GetItemsInfo tests' => sub {
+
+    plan tests => 3;
+
+    # Start transaction
+    $dbh->{AutoCommit} = 0;
+    $dbh->{RaiseError} = 1;
+
+    my $homebranch    = 'CPL';
+    my $holdingbranch = 'MPL';
+
+    # Add a biblio
+    my $biblionumber = get_biblio();
+    # Add an item
+    my ($item_bibnum, $item_bibitemnum, $itemnumber)
+        = AddItem({
+                homebranch    => $homebranch,
+                holdingbranch => $holdingbranch
+            }, $biblionumber );
+
+    my $branch = GetBranchDetail( $homebranch );
+    $branch->{ opac_info } = "homebranch OPAC info";
+    ModBranch($branch);
+
+    $branch = GetBranchDetail( $holdingbranch );
+    $branch->{ opac_info } = "holdingbranch OPAC info";
+    ModBranch($branch);
+
+    my @results = GetItemsInfo( $biblionumber );
+    ok( @results, 'GetItemsInfo returns results');
+    is( $results[0]->{ home_branch_opac_info }, "homebranch OPAC info",
+        'GetItemsInfo returns the correct home branch OPAC info notice' );
+    is( $results[0]->{ holding_branch_opac_info }, "holdingbranch OPAC info",
+        'GetItemsInfo returns the correct holding branch OPAC info notice' );
+
+    $dbh->rollback;
+};
+
 subtest q{Test Koha::Database->schema()->resultset('Item')->itemtype()} => sub {
 
     plan tests => 2;