From 90729fbd328c969e3b1feddb80356748e175a009 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 2 Sep 2015 14:46:02 +0100 Subject: [PATCH] Bug 7634: Add tests Signed-off-by: Chris Cormack --- t/db_dependent/Items.t | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/t/db_dependent/Items.t b/t/db_dependent/Items.t index fb5d672..9197793 100755 --- a/t/db_dependent/Items.t +++ b/t/db_dependent/Items.t @@ -33,10 +33,11 @@ BEGIN { my $dbh = C4::Context->dbh; my $branches = GetBranches; my ($branch1, $branch2) = keys %$branches; +my $location = 'My Location'; subtest 'General Add, Get and Del tests' => sub { - plan tests => 6; + plan tests => 10; # Start transaction $dbh->{AutoCommit} = 0; @@ -47,7 +48,7 @@ subtest 'General Add, Get and Del tests' => sub { my ($bibnum, $bibitemnum) = get_biblio(); # Add an item. - my ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => $branch1, holdingbranch => $branch1 } , $bibnum); + my ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => $branch1, holdingbranch => $branch1, location => $location } , $bibnum); cmp_ok($item_bibnum, '==', $bibnum, "New item is linked to correct biblionumber."); cmp_ok($item_bibitemnum, '==', $bibitemnum, "New item is linked to correct biblioitemnumber."); @@ -55,6 +56,8 @@ subtest 'General Add, Get and Del tests' => sub { my $getitem = GetItem($itemnumber); cmp_ok($getitem->{'itemnumber'}, '==', $itemnumber, "Retrieved item has correct itemnumber."); cmp_ok($getitem->{'biblioitemnumber'}, '==', $item_bibitemnum, "Retrieved item has correct biblioitemnumber."); + is( $getitem->{location}, $location, "The location should not have been modified" ); + is( $getitem->{permanent_location}, $location, "The permanent_location should have been set to the location value" ); # Modify item; setting barcode. ModItem({ barcode => '987654321' }, $bibnum, $itemnumber); @@ -66,6 +69,11 @@ subtest 'General Add, Get and Del tests' => sub { my $getdeleted = GetItem($itemnumber); is($getdeleted->{'itemnumber'}, undef, "Item deleted as expected."); + ($item_bibnum, $item_bibitemnum, $itemnumber) = AddItem({ homebranch => $branch1, holdingbranch => $branch1, location => $location, permanent_location => 'my permanent location' } , $bibnum); + $getitem = GetItem($itemnumber); + is( $getitem->{location}, $location, "The location should not have been modified" ); + is( $getitem->{permanent_location}, 'my permanent location', "The permanent_location should not have modified" ); + $dbh->rollback; }; -- 2.5.1