From 966e70e4b07d1254845748e7b4a846d0ad3ce44d Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 23 Jun 2014 16:36:43 -0300 Subject: [PATCH] Bug 12428: (QA followup) regression tests. Just that. Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/Items.t | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/t/db_dependent/Items.t b/t/db_dependent/Items.t index d1b15fb..dd8057b 100755 --- a/t/db_dependent/Items.t +++ b/t/db_dependent/Items.t @@ -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; -- 1.9.1