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 <galen.charlton@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
This commit is contained in:
Andrew Moore 2008-07-31 08:58:43 -05:00 committed by Joshua Ferraro
parent 88889f38f5
commit 7350505f9c
2 changed files with 12 additions and 7 deletions

View file

@ -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;
}

View file

@ -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(