Bug 7634: Add tests

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@unc.edu.ar>
This commit is contained in:
Jonathan Druart 2015-09-02 14:46:02 +01:00 committed by Tomas Cohen Arazi
parent 704aed77ea
commit ae5ee62d59

View file

@ -34,10 +34,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;
@ -48,7 +49,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.");
@ -56,6 +57,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);
@ -67,6 +70,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;
};