From 7350505f9c0e486da1130e96e86db0ba1f262ce5 Mon Sep 17 00:00:00 2001 From: Andrew Moore Date: Thu, 31 Jul 2008 08:58:43 -0500 Subject: [PATCH] Bug 1953: updating bad unit test for C4::Items::GetItemsForInventory The tests I wrote for C4::Items::GetItemsForInventory confused the differences between biblionumber and itemnumber. That wasn't uncovered on my limited test database, but I uncovered it later. This fixes that problem by populating a $self->{'items'} list with details of any items added by KohaTest::add_biblios. Then, tests can probe there for the details of items they should expect to find when searching. Signed-off-by: Galen Charlton Signed-off-by: Joshua Ferraro --- t/lib/KohaTest.pm | 5 +++++ t/lib/KohaTest/Items/GetItemsForInventory.pm | 14 +++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/t/lib/KohaTest.pm b/t/lib/KohaTest.pm index 7da83614dd..d42141c6a6 100644 --- a/t/lib/KohaTest.pm +++ b/t/lib/KohaTest.pm @@ -582,6 +582,11 @@ sub add_biblios { is( $iteminfo[0], $biblionumber, "biblionumber is $biblionumber" ); is( $iteminfo[1], $biblioitemnumber, "biblioitemnumber is $biblioitemnumber" ); ok( $iteminfo[2], "itemnumber is $iteminfo[2]" ); + push @{ $self->{'items'} }, + { biblionumber => $iteminfo[0], + biblioitemnumber => $iteminfo[1], + itemnumber => $iteminfo[2], + }; } push @{$self->{'biblios'}}, $biblionumber; } diff --git a/t/lib/KohaTest/Items/GetItemsForInventory.pm b/t/lib/KohaTest/Items/GetItemsForInventory.pm index 03cb4a1907..a56057ec23 100644 --- a/t/lib/KohaTest/Items/GetItemsForInventory.pm +++ b/t/lib/KohaTest/Items/GetItemsForInventory.pm @@ -23,10 +23,10 @@ sub startup_90_add_item_get_callnumber : Test( startup => 13 ) { $self->add_biblios( add_items => 1 ); - ok( $self->{'biblios'}, 'An item has been aded' ) - or diag( Data::Dumper->Dump( [ $self->{'biblios'} ], ['biblios'] ) ); + ok( $self->{'items'}, 'An item has been aded' ) + or diag( Data::Dumper->Dump( [ $self->{'items'} ], ['items'] ) ); - my @biblioitems = C4::Biblio::GetBiblioItemByBiblioNumber( $self->{'biblios'}[0] ); + my @biblioitems = C4::Biblio::GetBiblioItemByBiblioNumber( $self->{'items'}[0]{'biblionumber'} ); ok( $biblioitems[0]->{'biblioitemnumber'}, '...and it has a biblioitemnumber' ) or diag( Data::Dumper->Dump( [ \@biblioitems ], ['biblioitems'] ) ); @@ -60,7 +60,7 @@ sub missing_parameters : Test( 1 ) { local $TODO = 'GetItemsForInventory should fail when missing required parameters'; my $items = C4::Items::GetItemsForInventory(); - ok( not $items, 'GetItemsForInventory fails when parameters are missing' ) + ok( ! defined $items, 'GetItemsForInventory fails when parameters are missing' ) or diag( Data::Dumper->Dump( [ $items ], [ 'items' ] ) ); } @@ -77,9 +77,9 @@ sub basic_usage : Test( 4 ) { isa_ok( $items, 'ARRAY', 'We were able to call GetItemsForInventory with our call number' ); is( scalar @$items, 1, '...and we found only one item' ); my $our_item = $items->[0]; - is( $our_item->{'itemnumber'}, $self->{'biblios'}[0], '...and the item we found has the right itemnumber' ); + is( $our_item->{'itemnumber'}, $self->{'items'}[0]{'itemnumber'}, '...and the item we found has the right itemnumber' ); - diag( Data::Dumper->Dump( [$items], ['items'] ) ); + # diag( Data::Dumper->Dump( [$items], ['items'] ) ); } =head3 date_last_seen @@ -103,7 +103,7 @@ sub date_last_seen : Test( 6 ) { isa_ok( $items, 'ARRAY', 'We were able to call GetItemsForInventory with our call number' ); is( scalar @$items, 1, '...and we found only one item' ); my $our_item = $items->[0]; - is( $our_item->{'itemnumber'}, $self->{'biblios'}[0], '...and the item we found has the right itemnumber' ); + is( $our_item->{'itemnumber'}, $self->{'items'}[0]{'itemnumber'}, '...and the item we found has the right itemnumber' ); # give a datelastseen of yesterday, and we should not get our item. $items = C4::Items::GetItemsForInventory( -- 2.39.5